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)); diff --git a/winit-android/src/event_loop.rs b/winit-android/src/event_loop.rs index 8ffb1a3a94..50744486b9 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 { + 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-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)); } } 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