From e3a63f688e99f94606d8f71c024561431c7a699e Mon Sep 17 00:00:00 2001 From: WaterWhisperer Date: Fri, 31 Jul 2026 14:59:56 +0800 Subject: [PATCH 1/4] Apple: Fix main run loop observer removal --- winit-common/src/core_foundation/main_run_loop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winit-common/src/core_foundation/main_run_loop.rs b/winit-common/src/core_foundation/main_run_loop.rs index e72043c802..cafa38a38e 100644 --- a/winit-common/src/core_foundation/main_run_loop.rs +++ b/winit-common/src/core_foundation/main_run_loop.rs @@ -131,6 +131,6 @@ impl MainRunLoop { /// This is also done automatically when the [`MainRunLoopObserver`] is dropped. pub fn remove_observer(&self, observer: &MainRunLoopObserver, mode: &CFRunLoopMode) { // Same as in `add_observer`, accessing the main loop's observer is fine. - self.main_run_loop.add_observer(Some(&observer.observer), Some(mode)); + self.main_run_loop.remove_observer(Some(&observer.observer), Some(mode)); } } From 3f640ac2c63303d264b2a707f604e827f3047a98 Mon Sep 17 00:00:00 2001 From: WaterWhisperer Date: Fri, 31 Jul 2026 15:00:11 +0800 Subject: [PATCH 2/4] Android: Track scale factor changes --- winit-android/src/event_loop.rs | 7 +++++-- winit/src/changelog/unreleased.md | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/winit-android/src/event_loop.rs b/winit-android/src/event_loop.rs index 8ffb1a3a94..9c1ee47116 100644 --- a/winit-android/src/event_loop.rs +++ b/winit-android/src/event_loop.rs @@ -110,6 +110,7 @@ pub struct EventLoop { primary_pointer: Option, ignore_volume_keys: bool, combining_accent: Option, + scale_factor: f64, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -143,6 +144,7 @@ impl EventLoop { let event_loop_proxy = Arc::new(EventLoopProxy::new(android_app.create_waker())); let redraw_flag = SharedFlag::new(); + let scale_factor = scale_factor(android_app); Ok(Self { android_app: android_app.clone(), @@ -161,6 +163,7 @@ impl EventLoop { cause: StartCause::Init, ignore_volume_keys: attributes.ignore_volume_keys, combining_accent: None, + scale_factor, }) } @@ -207,9 +210,9 @@ impl EventLoop { app.window_event(&self.window_target, GLOBAL_WINDOW, event); }, MainEvent::ConfigChanged { .. } => { - let old_scale_factor = scale_factor(&self.android_app); let scale_factor = scale_factor(&self.android_app); - if (scale_factor - old_scale_factor).abs() < f64::EPSILON { + if (scale_factor - self.scale_factor).abs() > f64::EPSILON { + self.scale_factor = scale_factor; let new_surface_size = Arc::new(Mutex::new(screen_size(&self.android_app))); let event = event::WindowEvent::ScaleFactorChanged { surface_size_writer: SurfaceSizeWriter::new(Arc::downgrade( diff --git a/winit/src/changelog/unreleased.md b/winit/src/changelog/unreleased.md index 8586523413..d714f38d58 100644 --- a/winit/src/changelog/unreleased.md +++ b/winit/src/changelog/unreleased.md @@ -98,6 +98,8 @@ changelog entry. ### Fixed +- On Android, only emit `ScaleFactorChanged` when the scale factor actually + changes. - On Windows, fix a freeze that occurs when the keyboard layout is switched by tools such as Punto Switcher. The `WM_INPUTLANGCHANGE` message is now handled to refresh the cached keyboard layout, while still deferring to From 0350b6c5bbb08236c43fc43a40f59cfe617e9b2a Mon Sep 17 00:00:00 2001 From: WaterWhisperer Date: Fri, 31 Jul 2026 15:00:32 +0800 Subject: [PATCH 3/4] dpi: Fix MIN constant documentation --- dpi/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dpi/src/lib.rs b/dpi/src/lib.rs index d1dea21f66..894bf6bf7d 100644 --- a/dpi/src/lib.rs +++ b/dpi/src/lib.rs @@ -134,7 +134,7 @@ pub struct LogicalUnit

(pub P); impl

LogicalUnit

{ /// Represents a maximum logical unit that is equal to [`f64::MAX`]. pub const MAX: LogicalUnit = LogicalUnit::new(f64::MAX); - /// Represents a minimum logical unit of [`f64::MAX`]. + /// Represents a minimum logical unit of [`f64::MIN`]. pub const MIN: LogicalUnit = LogicalUnit::new(f64::MIN); /// Represents a logical unit of `0_f64`. pub const ZERO: LogicalUnit = LogicalUnit::new(0.0); @@ -228,7 +228,7 @@ pub struct PhysicalUnit

(pub P); impl

PhysicalUnit

{ /// Represents a maximum physical unit that is equal to [`f64::MAX`]. pub const MAX: LogicalUnit = LogicalUnit::new(f64::MAX); - /// Represents a minimum physical unit of [`f64::MAX`]. + /// Represents a minimum physical unit of [`f64::MIN`]. pub const MIN: LogicalUnit = LogicalUnit::new(f64::MIN); /// Represents a physical unit of `0_f64`. pub const ZERO: LogicalUnit = LogicalUnit::new(0.0); @@ -322,7 +322,7 @@ pub enum PixelUnit { impl PixelUnit { /// Represents a maximum logical unit that is equal to [`f64::MAX`]. pub const MAX: PixelUnit = PixelUnit::Logical(LogicalUnit::new(f64::MAX)); - /// Represents a minimum logical unit of [`f64::MAX`]. + /// Represents a minimum logical unit of [`f64::MIN`]. pub const MIN: PixelUnit = PixelUnit::Logical(LogicalUnit::new(f64::MIN)); /// Represents a logical unit of `0_f64`. pub const ZERO: PixelUnit = PixelUnit::Logical(LogicalUnit::new(0.0)); From 5a65af8f8fe8058036a096553576d71a145e1beb Mon Sep 17 00:00:00 2001 From: WaterWhisperer Date: Tue, 11 Aug 2026 11:44:20 +0800 Subject: [PATCH 4/4] Android: Compare scale factors exactly --- winit-android/src/event_loop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winit-android/src/event_loop.rs b/winit-android/src/event_loop.rs index 9c1ee47116..50744486b9 100644 --- a/winit-android/src/event_loop.rs +++ b/winit-android/src/event_loop.rs @@ -211,7 +211,7 @@ impl EventLoop { }, MainEvent::ConfigChanged { .. } => { let scale_factor = scale_factor(&self.android_app); - if (scale_factor - self.scale_factor).abs() > f64::EPSILON { + if scale_factor != self.scale_factor { self.scale_factor = scale_factor; let new_surface_size = Arc::new(Mutex::new(screen_size(&self.android_app))); let event = event::WindowEvent::ScaleFactorChanged {