From 3a54b24c9bf6523b40a009b41b0b8fc8fb1cc316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 10 Jan 2024 22:51:28 +0000 Subject: [PATCH] Bug 1872997 - [cocoa] Don't trigger mouseenter/leave events for windows that ignore mouse events. r=mac-reviewers,mstange In the patches above, we make some tooltips (which ignore mouse events) actually overlap the mouse. That should be fine (and is fine on other platforms) but Cocoa still sends mouseenter/leave events which confuse the front-end. This fixes that. Differential Revision: https://phabricator.services.mozilla.com/D197905 --- widget/cocoa/nsChildView.mm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 3d1bdf1bfd14..c59d2be82d09 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -5001,12 +5001,15 @@ void ChildViewMouseTracker::OnDestroyWindow(NSWindow* aWindow) { } void ChildViewMouseTracker::MouseEnteredWindow(NSEvent* aEvent) { - sWindowUnderMouse = [aEvent window]; - ReEvaluateMouseEnterState(aEvent); + NSWindow* window = aEvent.window; + if (!window.ignoresMouseEvents) { + sWindowUnderMouse = window; + ReEvaluateMouseEnterState(aEvent); + } } void ChildViewMouseTracker::MouseExitedWindow(NSEvent* aEvent) { - if (sWindowUnderMouse == [aEvent window]) { + if (sWindowUnderMouse == aEvent.window) { sWindowUnderMouse = nil; [sLastMouseMoveEvent release]; sLastMouseMoveEvent = nil;