Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Changed platform mouse moved handling to only fire on active or popup windows
Mikayla Maki8af1294ba51d
diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rsindex 4104b0ebf89..0da2e4351e4 100644--- a/crates/gpui/src/platform/mac/window.rs+++ b/crates/gpui/src/platform/mac/window.rs@@ -316,6 +316,7 @@ enum ImeState {struct WindowState {id: usize,native_window: id,+ kind: WindowKind,event_callback: Option<Box<dyn FnMut(Event) -> bool>>,activate_callback: Option<Box<dyn FnMut(bool)>>,resize_callback: Option<Box<dyn FnMut()>>,@@ -337,7 +338,6 @@ struct WindowState {ime_state: ImeState,//Retains the last IME Textime_text: Option<String>,- accepts_first_mouse: bool,}struct InsertText {@@ -422,6 +422,7 @@ impl Window {let window = Self(Rc::new(RefCell::new(WindowState {id,native_window,+ kind: options.kind,event_callback: None,resize_callback: None,should_close_callback: None,@@ -437,7 +438,6 @@ impl Window {scene_to_render: Default::default(),renderer: Renderer::new(true, fonts),last_fresh_keydown: None,- accepts_first_mouse: options.kind == WindowKind::PopUp,traffic_light_position: options.titlebar.as_ref()@@ -985,7 +985,11 @@ extern "C" fn handle_view_event(this: &Object, _: Sel, native_event: id) {.detach();}- Event::MouseMoved(_) if !is_active => return,+ Event::MouseMoved(_)+ if !(is_active || window_state_borrow.kind == WindowKind::PopUp) =>+ {+ return+ }Event::MouseUp(MouseButtonEvent {button: MouseButton::Left,@@ -1408,7 +1412,7 @@ extern "C" fn accepts_first_mouse(this: &Object, _: Sel, _: id) -> BOOL {unsafe {let state = get_window_state(this);let state_borrow = state.as_ref().borrow();- return state_borrow.accepts_first_mouse as BOOL;+ return state_borrow.kind == WindowKind::PopUp;}}diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 8735f33fbe6..9665db6be60 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -31,14 +31,18 @@ use futures::{};use gpui::{actions,+ color::Color,elements::*,- geometry::vector::Vector2F,+ geometry::{+ rect::RectF,+ vector::{vec2f, Vector2F},+ },impl_actions, impl_internal_actions,keymap_matcher::KeymapContext,platform::{CursorStyle, WindowOptions},AnyModelHandle, AnyViewHandle, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,MouseButton, MutableAppContext, PathPromptOptions, PromptLevel, RenderContext, SizeConstraint,- Task, View, ViewContext, ViewHandle, WeakViewHandle,+ Task, View, ViewContext, ViewHandle, WeakViewHandle, WindowBounds, WindowKind,};use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};use language::LanguageRegistry;