From 3aa3880e6982e57e5682562f3c6a7295b8c2e806 Mon Sep 17 00:00:00 2001 From: Osspial Date: Sun, 5 Jan 2020 16:57:32 -0500 Subject: [PATCH] Add changelog entry --- CHANGELOG.md | 10 ++++++++-- src/dpi.rs | 4 ++-- src/event.rs | 4 ++-- src/platform_impl/ios/app_state.rs | 2 +- src/platform_impl/ios/window.rs | 2 +- src/platform_impl/linux/wayland/event_loop.rs | 2 +- src/platform_impl/linux/x11/event_processor.rs | 4 ++-- src/platform_impl/macos/app_state.rs | 2 +- src/platform_impl/windows/event_loop.rs | 4 ++-- src/window.rs | 2 +- 10 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7684b9c2..24265513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Unreleased - On X11, fix `ModifiersChanged` emitting incorrect modifier change events +- **Breaking**: Overhaul how Winit handles DPI: + + Window functions and events now return `PhysicalSize` instead of `LogicalSize`. + + Functions that take `Size` or `Position` types can now take either `Logical` or `Physical` types. + + `hidpi_factor` has been renamed to `scale_factor`. + + `HiDpiFactorChanged` has been renamed to `ScaleFactorChanged`, and lets you control how the OS + resizes the window in response to the change. + + On X11, deprecate `WINIT_HIDPI_FACTOR` environment variable in favor of `WINIT_X11_SCALE_FACTOR`. + + `Size` and `Position` types are generic over their exact pixel type. # 0.20.0 Alpha 6 (2020-01-03) @@ -47,8 +55,6 @@ - On X11, generate synthetic key events for keys held when a window gains or loses focus. - On X11, issue a `CursorMoved` event when a `Touch` event occurs, as X11 implicitly moves the cursor for such events. -- Rename `hidpi_factor` to `scale_factor` -- On X11, deprecate `WINIT_HIDPI_FACTOR` environment variable in favor of `WINIT_X11_SCALE_FACTOR` # 0.20.0 Alpha 4 (2019-10-18) diff --git a/src/dpi.rs b/src/dpi.rs index e800a104..2057d012 100644 --- a/src/dpi.rs +++ b/src/dpi.rs @@ -52,12 +52,12 @@ //! //! ### Events //! -//! Winit will dispatch a [`DpiChanged`](crate::event::WindowEvent::DpiChanged) +//! Winit will dispatch a [`ScaleFactorChanged`](crate::event::WindowEvent::ScaleFactorChanged) //! event whenever a window's scale factor has changed. This can happen if the user drags their //! window from a standard-resolution monitor to a high-DPI monitor, or if the user changes their //! DPI settings. This gives you a chance to rescale your application's UI elements and adjust how //! the platform changes the window's size to reflect the new scale factor. If a window hasn't -//! received a [`DpiChanged`](crate::event::WindowEvent::DpiChanged) event, +//! received a [`ScaleFactorChanged`](crate::event::WindowEvent::ScaleFactorChanged) event, //! then its scale factor is `1.0`. //! //! ## How is the scale factor calculated? diff --git a/src/event.rs b/src/event.rs index 4a61f319..9f30e881 100644 --- a/src/event.rs +++ b/src/event.rs @@ -305,7 +305,7 @@ pub enum WindowEvent<'a> { /// by the OS, but it can be changed to any value. /// /// For more information about DPI in general, see the [`dpi`](crate::dpi) module. - DpiChanged { + ScaleFactorChanged { scale_factor: f64, new_inner_size: &'a mut PhysicalSize, }, @@ -397,7 +397,7 @@ impl<'a> WindowEvent<'a> { }), Touch(touch) => Some(Touch(touch)), ThemeChanged(theme) => Some(ThemeChanged(theme)), - DpiChanged { .. } => None, + ScaleFactorChanged { .. } => None, } } } diff --git a/src/platform_impl/ios/app_state.rs b/src/platform_impl/ios/app_state.rs index a6f3608b..0d388c50 100644 --- a/src/platform_impl/ios/app_state.rs +++ b/src/platform_impl/ios/app_state.rs @@ -865,7 +865,7 @@ fn handle_hidpi_proxy( let new_inner_size = &mut size; let event = Event::WindowEvent { window_id: RootWindowId(window_id.into()), - event: WindowEvent::DpiChanged { + event: WindowEvent::ScaleFactorChanged { scale_factor, new_inner_size, }, diff --git a/src/platform_impl/ios/window.rs b/src/platform_impl/ios/window.rs index 2ae48664..a5d3e893 100644 --- a/src/platform_impl/ios/window.rs +++ b/src/platform_impl/ios/window.rs @@ -398,7 +398,7 @@ impl Window { }; app_state::set_key_window(window); - // Like the Windows and macOS backends, we send a `DpiChanged` and `Resized` + // Like the Windows and macOS backends, we send a `ScaleFactorChanged` and `Resized` // event on window creation if the DPI factor != 1.0 let dpi_factor: CGFloat = msg_send![view, contentScaleFactor]; let scale_factor: f64 = dpi_factor.into(); diff --git a/src/platform_impl/linux/wayland/event_loop.rs b/src/platform_impl/linux/wayland/event_loop.rs index 3bd0e4cd..1ceedf19 100644 --- a/src/platform_impl/linux/wayland/event_loop.rs +++ b/src/platform_impl/linux/wayland/event_loop.rs @@ -734,7 +734,7 @@ impl EventLoop { callback(Event::WindowEvent { window_id, - event: WindowEvent::DpiChanged { + event: WindowEvent::ScaleFactorChanged { scale_factor: dpi, new_inner_size: &mut new_inner_size, }, diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index daf97383..0becc2e8 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -427,7 +427,7 @@ impl EventProcessor { callback(Event::WindowEvent { window_id, - event: WindowEvent::DpiChanged { + event: WindowEvent::ScaleFactorChanged { scale_factor: new_scale_factor, new_inner_size: &mut new_inner_size, }, @@ -1148,7 +1148,7 @@ impl EventProcessor { callback(Event::WindowEvent { window_id, - event: WindowEvent::DpiChanged { + event: WindowEvent::ScaleFactorChanged { scale_factor: new_monitor.scale_factor, new_inner_size: &mut new_inner_size, }, diff --git a/src/platform_impl/macos/app_state.rs b/src/platform_impl/macos/app_state.rs index 6625d517..1cb4e505 100644 --- a/src/platform_impl/macos/app_state.rs +++ b/src/platform_impl/macos/app_state.rs @@ -192,7 +192,7 @@ impl Handler { let new_inner_size = &mut size; let event = Event::WindowEvent { window_id: WindowId(get_window_id(*ns_window)), - event: WindowEvent::DpiChanged { + event: WindowEvent::ScaleFactorChanged { scale_factor, new_inner_size, }, diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index 200ba47b..53e937a0 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -1415,7 +1415,7 @@ unsafe extern "system" fn public_window_callback( // Only sent on Windows 8.1 or newer. On Windows 7 and older user has to log out to change // DPI, therefore all applications are closed while DPI is changing. winuser::WM_DPICHANGED => { - use crate::event::WindowEvent::DpiChanged; + use crate::event::WindowEvent::ScaleFactorChanged; // This message actually provides two DPI values - x and y. However MSDN says that // "you only need to use either the X-axis or the Y-axis value when scaling your @@ -1499,7 +1499,7 @@ unsafe extern "system" fn public_window_callback( let _ = subclass_input.send_event_unbuffered(Event::WindowEvent { window_id: RootWindowId(WindowId(window)), - event: DpiChanged { + event: ScaleFactorChanged { scale_factor: new_dpi_factor, new_inner_size: &mut new_physical_inner_size, }, diff --git a/src/window.rs b/src/window.rs index 1ee76d4f..073ed2fd 100644 --- a/src/window.rs +++ b/src/window.rs @@ -371,7 +371,7 @@ impl Window { /// See the [`dpi`](crate::dpi) module for more information. /// /// Note that this value can change depending on user action (for example if the window is - /// moved to another screen); as such, tracking `WindowEvent::DpiChanged` events is + /// moved to another screen); as such, tracking `WindowEvent::ScaleFactorChanged` events is /// the most robust way to track the DPI you need to use to draw. /// /// ## Platform-specific