diff options
Diffstat (limited to 'engine/src/windowing/window.rs')
| -rw-r--r-- | engine/src/windowing/window.rs | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/engine/src/windowing/window.rs b/engine/src/windowing/window.rs index 6f8ea6c..1f67130 100644 --- a/engine/src/windowing/window.rs +++ b/engine/src/windowing/window.rs @@ -225,17 +225,17 @@ impl Window self.scale_factor } - pub(crate) fn new( + pub(super) fn new( winit_window: &winit::window::Window, - creation_attrs: &CreationAttributes, + window_settings: &super::WindowSettings, ) -> Self { let inner_size = PhysicalSize::from(winit_window.inner_size()); Self { - title: creation_attrs.title.clone().into_owned(), - cursor_visible: creation_attrs.cursor_visible, - cursor_grab_mode: creation_attrs.cursor_grab_mode, + title: window_settings.title.clone().into_string(), + cursor_visible: window_settings.cursor_visible, + cursor_grab_mode: window_settings.cursor_grab_mode, inner_size, wid: Id::from_inner(winit_window.id()), scale_factor: winit_window.scale_factor(), @@ -243,10 +243,30 @@ impl Window } } - pub(crate) fn apply(&self, winit_window: &winit::window::Window) + pub(super) fn apply_to_settings(&self, settings: &mut super::WindowSettings) -> bool { - winit_window.set_title(&self.title); - winit_window.set_cursor_visible(self.cursor_visible); + let mut is_settings_changed = false; + + if self.title != *settings.title { + settings.title = self.title.clone().into_boxed_str(); + is_settings_changed = true; + } + + // For cursor visibility specifically, we especially do not want to set it unless + // it has changed. This is because of glitchiness that occurs on Windows when + // simultaneously the cursor is confined to the window, the window is drag resized + // and the cursor is made invisible. + if self.cursor_visible != settings.cursor_visible { + settings.cursor_visible = self.cursor_visible; + is_settings_changed = true; + } + + if self.cursor_grab_mode != settings.cursor_grab_mode { + settings.cursor_grab_mode = self.cursor_grab_mode; + is_settings_changed = true; + } + + is_settings_changed } pub(crate) fn set_scale_factor(&mut self, scale_factor: f64) |
