Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dpi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub struct LogicalUnit<P>(pub P);
impl<P> LogicalUnit<P> {
/// Represents a maximum logical unit that is equal to [`f64::MAX`].
pub const MAX: LogicalUnit<f64> = LogicalUnit::new(f64::MAX);
/// Represents a minimum logical unit of [`f64::MAX`].
/// Represents a minimum logical unit of [`f64::MIN`].
pub const MIN: LogicalUnit<f64> = LogicalUnit::new(f64::MIN);
/// Represents a logical unit of `0_f64`.
pub const ZERO: LogicalUnit<f64> = LogicalUnit::new(0.0);
Expand Down Expand Up @@ -228,7 +228,7 @@ pub struct PhysicalUnit<P>(pub P);
impl<P> PhysicalUnit<P> {
/// Represents a maximum physical unit that is equal to [`f64::MAX`].
pub const MAX: LogicalUnit<f64> = LogicalUnit::new(f64::MAX);
/// Represents a minimum physical unit of [`f64::MAX`].
/// Represents a minimum physical unit of [`f64::MIN`].
pub const MIN: LogicalUnit<f64> = LogicalUnit::new(f64::MIN);
/// Represents a physical unit of `0_f64`.
pub const ZERO: LogicalUnit<f64> = LogicalUnit::new(0.0);
Expand Down Expand Up @@ -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));
Expand Down
7 changes: 5 additions & 2 deletions winit-android/src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub struct EventLoop {
primary_pointer: Option<FingerId>,
ignore_volume_keys: bool,
combining_accent: Option<char>,
scale_factor: f64,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -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(),
Expand All @@ -161,6 +163,7 @@ impl EventLoop {
cause: StartCause::Init,
ignore_volume_keys: attributes.ignore_volume_keys,
combining_accent: None,
scale_factor,
})
}

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion winit-common/src/core_foundation/main_run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
2 changes: 2 additions & 0 deletions winit/src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down