Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Fix cursor styles not applying to panel-backed windows (#58493)
Floyd Wang96165ec62647
diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rsindex 7ecfccfa1cc..b0abd8ffb7e 100644--- a/crates/gpui_macos/src/window.rs+++ b/crates/gpui_macos/src/window.rs@@ -321,17 +321,15 @@ pub(crate) fn convert_mouse_position(position: NSPoint, window_height: Pixels) -/// thread because it reads the active AppKit window and updates GPUI window state associated/// with Objective-C objects.pub(crate) unsafe fn set_active_window_cursor_style(style: CursorStyle) {- // SAFETY: The caller guarantees AppKit main-thread access. The class check ensures the+ // SAFETY: The caller guarantees AppKit main-thread access. `is_gpui_window` ensures the// window has our WINDOW_STATE_IVAR before reading it.unsafe {let app = NSApplication::sharedApplication(nil);let key_window: id = msg_send![app, keyWindow];let main_window: id = msg_send![app, mainWindow];- let active_window = if !key_window.is_null()- && msg_send![key_window, isKindOfClass: WINDOW_CLASS]- {+ let active_window = if !key_window.is_null() && is_gpui_window(key_window) {Some(key_window)- } else if !main_window.is_null() && msg_send![main_window, isKindOfClass: WINDOW_CLASS] {+ } else if !main_window.is_null() && is_gpui_window(main_window) {Some(main_window)} else {None@@ -1828,6 +1826,14 @@ fn get_scale_factor(native_window: id) -> f32 {if factor == 0.0 { 2. } else { factor }}+/// Returns whether `window` is one of GPUI's managed windows.+unsafe fn is_gpui_window(window: id) -> bool {+ unsafe {+ msg_send![window, isKindOfClass: WINDOW_CLASS]+ || msg_send![window, isKindOfClass: PANEL_CLASS]+ }+}+unsafe fn get_window_state(object: &Object) -> Arc<Mutex<MacWindowState>> {unsafe {let raw: *mut c_void = *object.get_ivar(WINDOW_STATE_IVAR);