From 658460cc2bf72b145cc27beffdd69a03a8634389 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Wed, 16 Sep 2026 13:41:43 +0000 Subject: [PATCH] gpui_macos: Fix hover feedback when another application is focused (#64301) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up #64234 If Zed is inactive, hovering over it produces no hover effects. While this matches other apps like Slack, I think it’s better to preserve existing behavior. This change keeps the bug fix of the original PR. This PR uses `ActiveAlways` for normal windows, matching popup windows. Release Notes: - N/A - [GPUI] N/A --- crates/gpui_macos/src/window.rs | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rs index 0867385a65..bd4996011f 100644 --- a/crates/gpui_macos/src/window.rs +++ b/crates/gpui_macos/src/window.rs @@ -1204,15 +1204,7 @@ impl MacWindow { } else { native_window.setLevel_(NSNormalWindowLevel); native_window.setAcceptsMouseMovedEvents_(NO); - add_mouse_tracking_area( - tracking_view, - NSTrackingAreaOptions::MouseEnteredAndExited - | NSTrackingAreaOptions::MouseMoved - // Track while this application is active, even if another - // window in the application has focus. - | NSTrackingAreaOptions::ActiveInActiveApp - | NSTrackingAreaOptions::InVisibleRect, - ); + add_mouse_tracking_area(tracking_view); } if let Some(tabbing_identifier) = tabbing_identifier { @@ -1225,15 +1217,7 @@ impl MacWindow { // `AnchoredPopup` is rejected in `MacPlatform::open_window`, grouped here only // for exhaustiveness. WindowKind::PopUp | WindowKind::AnchoredPopup(_) => { - add_mouse_tracking_area( - tracking_view, - NSTrackingAreaOptions::MouseEnteredAndExited - | NSTrackingAreaOptions::MouseMoved - // Track even when another application is active, e.g. so - // notification windows can respond to hover. - | NSTrackingAreaOptions::ActiveAlways - | NSTrackingAreaOptions::InVisibleRect, - ); + add_mouse_tracking_area(tracking_view); native_window.setLevel_(NSPopUpWindowLevel); let _: () = msg_send![ @@ -2483,7 +2467,14 @@ extern "C" fn dealloc_view(this: &Object, _: Sel) { } } -fn add_mouse_tracking_area(native_view: &Objc2NSView, options: NSTrackingAreaOptions) { +fn add_mouse_tracking_area(native_view: &Objc2NSView) { + let options = NSTrackingAreaOptions::MouseEnteredAndExited + | NSTrackingAreaOptions::MouseMoved + // Track even when another application is active so visible + // windows can respond to hover without being focused. + | NSTrackingAreaOptions::ActiveAlways + | NSTrackingAreaOptions::InVisibleRect; + // SAFETY: NSView provides the tracking-event callbacks, and the owner is // the same view that retains the tracking area. No user info is supplied. let tracking_area = unsafe {