Skip to content

Commit

Permalink
When handling mouseMove on MacOS, check that the current peer is the …
Browse files Browse the repository at this point in the history
…topmost NSView before forwarding the events. Without this, a Component created via addDocumentWindow() with the nativeWindowToAttachTo argument set (i.e., creating a sub-NSView) would receive incorrect mouseExit events, as both it *and* its parent component would handle these mouseMove events, rapidly sending enter/exit messages back and forth between the two windows while the mouse moved.
  • Loading branch information
emezeske committed Oct 10, 2024
1 parent 83dc660 commit 252e8c1
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,15 @@ void redirectMouseMove (NSEvent* ev)
NSPoint windowPos = [ev locationInWindow];
NSPoint screenPos = [[ev window] convertRectToScreen: NSMakeRect (windowPos.x, windowPos.y, 1.0f, 1.0f)].origin;

if (isWindowAtPoint ([ev window], screenPos))
sendMouseEvent (ev);
else
if (isWindowAtPoint ([ev window], screenPos)) {
if ([[[ev window] contentView] hitTest: windowPos] == view) {
sendMouseEvent (ev);
}
} else {
// moved into another window which overlaps this one, so trigger an exit
handleMouseEvent (MouseInputSource::InputSourceType::mouse, MouseInputSource::offscreenMousePos, ModifierKeys::currentModifiers,
getMousePressure (ev), MouseInputSource::defaultOrientation, getMouseTime (ev));
}

showArrowCursorIfNeeded();
}
Expand Down

0 comments on commit 252e8c1

Please sign in to comment.