diff --git a/CHANGELOG.md b/CHANGELOG.md index 43c609d0..271cbea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - On X11, fix key modifiers being incorrectly reported. - On X11, fix window creation hanging when another window is fullscreen. - On Windows, fix focusing unfocused windows when switching from fullscreen to windowed. +- On X11, fix reporting incorrect DPI factor when waking from suspend. # 0.20.0 Alpha 4 (2019-10-18) diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index 2758aa35..87c644f0 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -406,14 +406,16 @@ impl EventProcessor { let last_hidpi_factor = shared_state_lock.last_monitor.hidpi_factor; let new_hidpi_factor = { let window_rect = util::AaRect::new(new_outer_position, new_inner_size); - monitor = wt.xconn.get_monitor_for_window(Some(window_rect)); - let new_hidpi_factor = monitor.hidpi_factor; + let new_monitor = wt.xconn.get_monitor_for_window(Some(window_rect)); - // Avoid caching an invalid dummy monitor handle - if monitor.id != 0 { + if new_monitor.is_dummy() { + // Avoid updating monitor using a dummy monitor handle + last_hidpi_factor + } else { + monitor = new_monitor; shared_state_lock.last_monitor = monitor.clone(); + monitor.hidpi_factor } - new_hidpi_factor }; if last_hidpi_factor != new_hidpi_factor { events.dpi_changed = diff --git a/src/platform_impl/linux/x11/monitor.rs b/src/platform_impl/linux/x11/monitor.rs index 1fe2fd20..2612643e 100644 --- a/src/platform_impl/linux/x11/monitor.rs +++ b/src/platform_impl/linux/x11/monitor.rs @@ -143,6 +143,11 @@ impl MonitorHandle { } } + pub(crate) fn is_dummy(&self) -> bool { + // Zero is an invalid XID value; no real monitor will have it + self.id == 0 + } + pub fn name(&self) -> Option { Some(self.name.clone()) } diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index f967a100..5829cc0e 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -651,7 +651,7 @@ impl UnownedWindow { }; // Don't set fullscreen on an invalid dummy monitor handle - if monitor.id == 0 { + if monitor.is_dummy() { return None; }