diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index c1b175dd843..3601fcae46e 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -116,10 +116,14 @@ impl RawInput { pub fn take(&mut self) -> Self { Self { viewport_id: self.viewport_id, - viewports: self.viewports.clone(), + viewports: self + .viewports + .iter_mut() + .map(|(id, info)| (*id, info.take())) + .collect(), screen_rect: self.screen_rect.take(), max_texture_side: self.max_texture_side.take(), - time: self.time.take(), + time: self.time, predicted_dt: self.predicted_dt, modifiers: self.modifiers, events: std::mem::take(&mut self.events), @@ -247,6 +251,23 @@ impl ViewportInfo { .any(|&event| event == ViewportEvent::Close) } + /// Helper: move [`Self::events`], clone the other fields. + pub fn take(&mut self) -> Self { + Self { + parent: self.parent, + title: self.title.clone(), + events: std::mem::take(&mut self.events), + native_pixels_per_point: self.native_pixels_per_point, + monitor_size: self.monitor_size, + inner_rect: self.inner_rect, + outer_rect: self.outer_rect, + minimized: self.minimized, + maximized: self.maximized, + fullscreen: self.fullscreen, + focused: self.focused, + } + } + pub fn ui(&self, ui: &mut crate::Ui) { let Self { parent,