Skip to content

Commit

Permalink
windows: Revert "Fix hide, activate method on Windows to hide/sho…
Browse files Browse the repository at this point in the history
…w application" (zed-industries#18571)

This PR reverts the changes introduced via zed-industries#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
  • Loading branch information
JunkuiZhang authored and noaccOS committed Oct 19, 2024
1 parent f2bcb9e commit cc54977
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions crates/gpui/src/platform/windows/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ use crate::*;
pub(crate) struct WindowsPlatform {
state: RefCell<WindowsPlatformState>,
raw_window_handles: RwLock<SmallVec<[HWND; 4]>>,
// The window handles that are hided by `hide` method.
hidden_windows: RwLock<SmallVec<[HWND; 4]>>,
// The below members will never change throughout the entire lifecycle of the app.
icon: HICON,
main_receiver: flume::Receiver<Runnable>,
Expand Down Expand Up @@ -102,7 +100,6 @@ impl WindowsPlatform {
Self {
state,
raw_window_handles,
hidden_windows: RwLock::new(SmallVec::new()),
icon,
main_receiver,
dispatch_event,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cc54977

Please sign in to comment.