diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 764fc1c3..3871fd85 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -697,7 +697,7 @@ async fn run_instance
( id, core::Event::Window(window::Event::Opened { position: window.position(), - size: window.size(), + size: window.logical_size(), }), )); @@ -796,7 +796,9 @@ async fn run_instance
( } // Window was resized between redraws - if window.surface_size != physical_size { + if window.surface_version + != window.state.surface_version() + { let ui = user_interfaces .remove(&id) .expect("Remove user interface"); @@ -814,7 +816,8 @@ async fn run_instance
( physical_size.height, ); - window.surface_size = physical_size; + window.surface_version = + window.state.surface_version(); } let redraw_event = core::Event::Window( @@ -1483,11 +1486,7 @@ fn run_action<'a, P, C>( } window::Action::GetSize(id, channel) => { if let Some(window) = window_manager.get_mut(id) { - let size = window - .raw - .inner_size() - .to_logical(f64::from(window.state.scale_factor())); - + let size = window.logical_size(); let _ = channel.send(Size::new(size.width, size.height)); } } @@ -1761,7 +1760,7 @@ fn run_action<'a, P, C>( }; let cache = ui.into_cache(); - let size = window.size(); + let size = window.logical_size(); let _ = interfaces.insert( id, diff --git a/winit/src/window.rs b/winit/src/window.rs index 5d66913f..101556f8 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -58,6 +58,7 @@ where ) -> &mut Window
{
let state = State::new(program, id, &window, system_theme);
let surface_size = state.physical_size();
+ let surface_version = state.surface_version();
let surface = compositor.create_surface(
window.clone(),
surface_size.width,
@@ -74,7 +75,7 @@ where
state,
exit_on_close_request,
surface,
- surface_size,
+ surface_version,
renderer,
mouse_interaction: mouse::Interaction::None,
redraw_at: None,
@@ -166,7 +167,7 @@ where
pub exit_on_close_request: bool,
pub mouse_interaction: mouse::Interaction,
pub surface: C::Surface,
- pub surface_size: Size ,
@@ -154,6 +149,7 @@ where
size,
window.scale_factor() as f32 * self.scale_factor,
);
+ self.surface_version += 1;
}
WindowEvent::ScaleFactorChanged {
scale_factor: new_scale_factor,
@@ -165,6 +161,7 @@ where
size,
*new_scale_factor as f32 * self.scale_factor,
);
+ self.surface_version += 1;
}
WindowEvent::CursorMoved { position, .. }
| WindowEvent::Touch(Touch {
@@ -192,11 +189,6 @@ where
}
}
- /// Synchronizes the [`State`] with its [`Program`] and its respective
- /// window.
- ///
- /// Normally, a [`Program`] should be synchronized with its [`State`]
- /// and window after calling [`Program::update`].
pub fn synchronize(
&mut self,
program: &program::Instance ,