windows: Revert "Fix hide, activate method on Windows to hide/show application" (#18571)

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
This commit is contained in:
Junkui Zhang 2024-10-01 18:58:40 +08:00 committed by GitHub
parent 7ce8797d78
commit 6336248c1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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>,
@ -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) {