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:
parent
78dc458231
commit
6231df978b
7 changed files with 24 additions and 1 deletions
|
@ -188,6 +188,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
|
||||||
answers: &[&str],
|
answers: &[&str],
|
||||||
) -> Option<oneshot::Receiver<usize>>;
|
) -> Option<oneshot::Receiver<usize>>;
|
||||||
fn activate(&self);
|
fn activate(&self);
|
||||||
|
fn is_active(&self) -> bool;
|
||||||
fn set_title(&mut self, title: &str);
|
fn set_title(&mut self, title: &str);
|
||||||
fn set_edited(&mut self, edited: bool);
|
fn set_edited(&mut self, edited: bool);
|
||||||
fn show_character_palette(&self);
|
fn show_character_palette(&self);
|
||||||
|
|
|
@ -346,6 +346,11 @@ impl PlatformWindow for WaylandWindow {
|
||||||
// todo(linux)
|
// todo(linux)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo(linux)
|
||||||
|
fn is_active(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn set_title(&mut self, title: &str) {
|
fn set_title(&mut self, title: &str) {
|
||||||
self.0.toplevel.set_title(title.to_string());
|
self.0.toplevel.set_title(title.to_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,6 +406,11 @@ impl PlatformWindow for X11Window {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo(linux)
|
||||||
|
fn is_active(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn set_title(&mut self, title: &str) {
|
fn set_title(&mut self, title: &str) {
|
||||||
self.0
|
self.0
|
||||||
.xcb_connection
|
.xcb_connection
|
||||||
|
|
|
@ -916,6 +916,10 @@ impl PlatformWindow for MacWindow {
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_active(&self) -> bool {
|
||||||
|
unsafe { self.0.lock().native_window.isKeyWindow() == YES }
|
||||||
|
}
|
||||||
|
|
||||||
fn set_title(&mut self, title: &str) {
|
fn set_title(&mut self, title: &str) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let app = NSApplication::sharedApplication(nil);
|
let app = NSApplication::sharedApplication(nil);
|
||||||
|
|
|
@ -181,6 +181,10 @@ impl PlatformWindow for TestWindow {
|
||||||
.set_active_window(Some(self.clone()))
|
.set_active_window(Some(self.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_active(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn set_title(&mut self, title: &str) {
|
fn set_title(&mut self, title: &str) {
|
||||||
self.0.lock().title = Some(title.to_owned());
|
self.0.lock().title = Some(title.to_owned());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1389,6 +1389,10 @@ impl PlatformWindow for WindowsWindow {
|
||||||
unsafe { SetForegroundWindow(self.inner.hwnd) };
|
unsafe { SetForegroundWindow(self.inner.hwnd) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_active(&self) -> bool {
|
||||||
|
self.inner.hwnd == unsafe { GetActiveWindow() }
|
||||||
|
}
|
||||||
|
|
||||||
// todo(windows)
|
// todo(windows)
|
||||||
fn set_title(&mut self, title: &str) {
|
fn set_title(&mut self, title: &str) {
|
||||||
unsafe { SetWindowTextW(self.inner.hwnd, &HSTRING::from(title)) }
|
unsafe { SetWindowTextW(self.inner.hwnd, &HSTRING::from(title)) }
|
||||||
|
|
|
@ -421,7 +421,7 @@ impl Window {
|
||||||
let appearance = platform_window.appearance();
|
let appearance = platform_window.appearance();
|
||||||
let text_system = Arc::new(WindowTextSystem::new(cx.text_system().clone()));
|
let text_system = Arc::new(WindowTextSystem::new(cx.text_system().clone()));
|
||||||
let dirty = Rc::new(Cell::new(true));
|
let dirty = Rc::new(Cell::new(true));
|
||||||
let active = Rc::new(Cell::new(false));
|
let active = Rc::new(Cell::new(platform_window.is_active()));
|
||||||
let needs_present = Rc::new(Cell::new(false));
|
let needs_present = Rc::new(Cell::new(false));
|
||||||
let next_frame_callbacks: Rc<RefCell<Vec<FrameCallback>>> = Default::default();
|
let next_frame_callbacks: Rc<RefCell<Vec<FrameCallback>>> = Default::default();
|
||||||
let last_input_timestamp = Rc::new(Cell::new(Instant::now()));
|
let last_input_timestamp = Rc::new(Cell::new(Instant::now()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue