diff --git a/crates/gpui/src/platform/windows/display.rs b/crates/gpui/src/platform/windows/display.rs index 720d459c1c..f26ba83590 100644 --- a/crates/gpui/src/platform/windows/display.rs +++ b/crates/gpui/src/platform/windows/display.rs @@ -199,11 +199,6 @@ impl WindowsDisplay { .collect() } - /// Check if this monitor is still online - pub fn is_connected(hmonitor: HMONITOR) -> bool { - available_monitors().iter().contains(&hmonitor) - } - pub fn physical_bounds(&self) -> Bounds { self.physical_bounds } diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 45bd3320c0..d0504c9cf3 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -812,34 +812,8 @@ impl WindowsWindowInner { Some(0) } - /// The following conditions will trigger this event: - /// 1. The monitor on which the window is located goes offline or changes resolution. - /// 2. Another monitor goes offline, is plugged in, or changes resolution. - /// - /// In either case, the window will only receive information from the monitor on which - /// it is located. - /// - /// For example, in the case of condition 2, where the monitor on which the window is - /// located has actually changed nothing, it will still receive this event. fn handle_display_change_msg(&self, handle: HWND) -> Option { - // NOTE: - // Even the `lParam` holds the resolution of the screen, we just ignore it. - // Because WM_DPICHANGED, WM_MOVE, WM_SIZE will come first, window reposition and resize - // are handled there. - // So we only care about if monitor is disconnected. - let previous_monitor = self.state.display.get(); - if WindowsDisplay::is_connected(previous_monitor.handle) { - // we are fine, other display changed - return None; - } - // display disconnected - // in this case, the OS will move our window to another monitor, and minimize it. - // we deminimize the window and query the monitor after moving - unsafe { - let _ = ShowWindow(handle, SW_SHOWNORMAL); - }; let new_monitor = unsafe { MonitorFromWindow(handle, MONITOR_DEFAULTTONULL) }; - // all monitors disconnected if new_monitor.is_invalid() { log::error!("No monitor detected!"); return None;