Windows: fix initial active status (#9694)

Separate from #9451

On Windows, a new window may already active immediate after creation.

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
白山風露
2024-03-25 11:44:18 -07:00
committed by GitHub
co-authored by Mikayla
parent 78dc458231
commit 6231df978b
7 changed files with 24 additions and 1 deletions
@@ -346,6 +346,11 @@ impl PlatformWindow for WaylandWindow {
// todo(linux)
}
// todo(linux)
fn is_active(&self) -> bool {
false
}
fn set_title(&mut self, title: &str) {
self.0.toplevel.set_title(title.to_string());
}
@@ -406,6 +406,11 @@ impl PlatformWindow for X11Window {
.unwrap();
}
// todo(linux)
fn is_active(&self) -> bool {
false
}
fn set_title(&mut self, title: &str) {
self.0
.xcb_connection
+4
View File
@@ -916,6 +916,10 @@ impl PlatformWindow for MacWindow {
.detach();
}
fn is_active(&self) -> bool {
unsafe { self.0.lock().native_window.isKeyWindow() == YES }
}
fn set_title(&mut self, title: &str) {
unsafe {
let app = NSApplication::sharedApplication(nil);
+4
View File
@@ -181,6 +181,10 @@ impl PlatformWindow for TestWindow {
.set_active_window(Some(self.clone()))
}
fn is_active(&self) -> bool {
false
}
fn set_title(&mut self, title: &str) {
self.0.lock().title = Some(title.to_owned());
}
@@ -1389,6 +1389,10 @@ impl PlatformWindow for WindowsWindow {
unsafe { SetForegroundWindow(self.inner.hwnd) };
}
fn is_active(&self) -> bool {
self.inner.hwnd == unsafe { GetActiveWindow() }
}
// todo(windows)
fn set_title(&mut self, title: &str) {
unsafe { SetWindowTextW(self.inner.hwnd, &HSTRING::from(title)) }