mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
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
@ -188,6 +188,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
|
||||
answers: &[&str],
|
||||
) -> Option<oneshot::Receiver<usize>>;
|
||||
fn activate(&self);
|
||||
fn is_active(&self) -> bool;
|
||||
fn set_title(&mut self, title: &str);
|
||||
fn set_edited(&mut self, edited: bool);
|
||||
fn show_character_palette(&self);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)) }
|
||||
|
@ -421,7 +421,7 @@ impl Window {
|
||||
let appearance = platform_window.appearance();
|
||||
let text_system = Arc::new(WindowTextSystem::new(cx.text_system().clone()));
|
||||
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 next_frame_callbacks: Rc<RefCell<Vec<FrameCallback>>> = Default::default();
|
||||
let last_input_timestamp = Rc::new(Cell::new(Instant::now()));
|
||||
|
Loading…
Reference in New Issue
Block a user