From 6336248c1a90d23f08678bf6d30fd84bc1638625 Mon Sep 17 00:00:00 2001 From: Junkui Zhang <364772080@qq.com> Date: Tue, 1 Oct 2024 18:58:40 +0800 Subject: [PATCH] windows: Revert "Fix `hide`, `activate` method on Windows to hide/show application" (#18571) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR reverts the changes introduced via #18164. As shown in the video below, once you `hide` the app, there is essentially no way to bring it back. I must emphasize that the window logic on Windows is entirely different from macOS. On macOS, when you `hide` an app, its icon always remains visible in the dock, and you can always bring the hidden app back by clicking that icon. However, on Windows, there is no such mechanism—the app is literally hidden. I think the `hide` feature should be macOS-only. https://github.com/user-attachments/assets/65c8a007-eedb-4444-9499-787b50f2d1e9 Release Notes: - N/A --- crates/gpui/src/platform/windows/platform.rs | 24 ++------------------ 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index 7f6677973b..e90b2c6ef1 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -33,8 +33,6 @@ use crate::*; pub(crate) struct WindowsPlatform { state: RefCell, raw_window_handles: RwLock>, - // The window handles that are hided by `hide` method. - hidden_windows: RwLock>, // The below members will never change throughout the entire lifecycle of the app. icon: HICON, main_receiver: flume::Receiver, @@ -102,7 +100,6 @@ impl WindowsPlatform { Self { state, raw_window_handles, - hidden_windows: RwLock::new(SmallVec::new()), icon, main_receiver, dispatch_event, @@ -298,26 +295,9 @@ impl Platform for WindowsPlatform { } } - fn activate(&self, _ignoring_other_apps: bool) { - let mut state = self.hidden_windows.write(); - state.iter().for_each(|handle| unsafe { - ShowWindow(*handle, SW_SHOW).ok().log_err(); - }); - state.clear(); - } + fn activate(&self, _ignoring_other_apps: bool) {} - fn hide(&self) { - let mut state = self.hidden_windows.write(); - self.raw_window_handles - .read() - .iter() - .for_each(|handle| unsafe { - if IsWindowVisible(*handle).as_bool() { - state.push(*handle); - ShowWindow(*handle, SW_HIDE).ok().log_err(); - } - }); - } + fn hide(&self) {} // todo(windows) fn hide_other_apps(&self) {