Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Mikayla Maki27a80a1c94c5
diff --git a/crates/gpui/src/platform/mac/event.rs b/crates/gpui/src/platform/mac/event.rsindex 2f29898c26d..68827213721 100644--- a/crates/gpui/src/platform/mac/event.rs+++ b/crates/gpui/src/platform/mac/event.rs@@ -125,6 +125,7 @@ impl Event {button,position: vec2f(native_event.locationInWindow().x as f32,+ // MacOS screen coordinates are relative to bottom leftwindow_height - native_event.locationInWindow().y as f32,),modifiers: read_modifiers(native_event),@@ -150,6 +151,7 @@ impl Event {button,position: vec2f(native_event.locationInWindow().x as f32,+ // MacOS view coordinates are relative to bottom leftwindow_height - native_event.locationInWindow().y as f32,),modifiers: read_modifiers(native_event),diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rsindex f1b7f75c03f..ae9db6a3969 100644--- a/crates/gpui/src/platform/mac/platform.rs+++ b/crates/gpui/src/platform/mac/platform.rs@@ -697,27 +697,20 @@ impl platform::Platform for MacPlatform {}fn set_cursor_style(&self, style: CursorStyle, window_id: usize, screen_position: &Vector2F) {- let top_most = Window::window_id_under(screen_position);- if top_most.is_none() {- return;- }- if top_most.unwrap() != window_id {- return;- }-- dbg!(top_most.unwrap(), window_id);-- dbg!(style);-- unsafe {- let cursor: id = match style {- CursorStyle::Arrow => msg_send![class!(NSCursor), arrowCursor],- CursorStyle::ResizeLeftRight => msg_send![class!(NSCursor), resizeLeftRightCursor],- CursorStyle::ResizeUpDown => msg_send![class!(NSCursor), resizeUpDownCursor],- CursorStyle::PointingHand => msg_send![class!(NSCursor), pointingHandCursor],- CursorStyle::IBeam => msg_send![class!(NSCursor), IBeamCursor],- };- let _: () = msg_send![cursor, set];+ if Some(window_id) == Window::window_id_under(screen_position) {+ dbg!(screen_position, style);+ unsafe {+ let cursor: id = match style {+ CursorStyle::Arrow => msg_send![class!(NSCursor), arrowCursor],+ CursorStyle::ResizeLeftRight => {+ msg_send![class!(NSCursor), resizeLeftRightCursor]+ }+ CursorStyle::ResizeUpDown => msg_send![class!(NSCursor), resizeUpDownCursor],+ CursorStyle::PointingHand => msg_send![class!(NSCursor), pointingHandCursor],+ CursorStyle::IBeam => msg_send![class!(NSCursor), IBeamCursor],+ };+ let _: () = msg_send![cursor, set];+ }}}diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rsindex 032b88507bc..067dd691157 100644--- a/crates/gpui/src/platform/mac/window.rs+++ b/crates/gpui/src/platform/mac/window.rs@@ -52,6 +52,8 @@ use std::{time::Duration,};+use super::geometry::Vector2FExt;+const WINDOW_STATE_IVAR: &str = "windowState";static mut WINDOW_CLASS: *const Class = ptr::null();@@ -564,11 +566,13 @@ impl Window {unsafe {let app = NSApplication::sharedApplication(nil);- let point = NSPoint::new(screen_position.x() as f64, screen_position.y() as f64);- let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:point belowWindowWithWindowNumber:0 as NSInteger];+ let point = screen_position.to_ns_point();+ let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:point belowWindowWithWindowNumber:0];+// For some reason this API doesn't work when our two windows are on top of each otherlet top_most_window: id = msg_send![app, windowWithWindowNumber: window_number];- dbg!(top_most_window);++ // dbg!(top_most_window);let is_panel: BOOL = msg_send![top_most_window, isKindOfClass: PANEL_CLASS];let is_window: BOOL = msg_send![top_most_window, isKindOfClass: WINDOW_CLASS];if is_panel | is_window {@@ -779,7 +783,7 @@ impl platform::Window for Window {fn screen_position(&self, view_position: &Vector2F) -> Vector2F {let self_borrow = self.0.borrow_mut();unsafe {- let point = NSPoint::new(view_position.x() as f64, view_position.y() as f64);+ let point = view_position.to_ns_point();let screen_point: NSPoint =msg_send![self_borrow.native_window, convertPointToScreen: point];vec2f(screen_point.x as f32, screen_point.y as f32)diff --git a/crates/gpui/src/presenter.rs b/crates/gpui/src/presenter.rsindex f74eef463a7..1b16574cb87 100644--- a/crates/gpui/src/presenter.rs+++ b/crates/gpui/src/presenter.rs@@ -317,6 +317,9 @@ impl Presenter {}}+ dbg!("*******");+ dbg!(position);+ dbg!(event_reused);if let Some(screen_position) = cx.screen_position(self.window_id, position) {cx.platform().set_cursor_style(style_to_assign,