summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index b9d24b5..e50bdd3 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -1103,22 +1103,27 @@ QWidget *qt_mac_getTargetForMouseEvent(
if (returnWidgetUnderMouse)
*returnWidgetUnderMouse = widgetUnderMouse;
- // Resolve the target for the mouse event. Default will be widgetUnderMouse, except
- // if there is a popup-"grab", mousegrab, or button-down-"grab":
+ // Resolve the target for the mouse event. Default will be
+ // widgetUnderMouse, except if there is a grab (popup/mouse/button-down):
if (popup && !mouseGrabber) {
- if (!popup->isAncestorOf(widgetUnderMouse)) {
- // The popup will always grab the mouse unless the
- // mouse is over a child, or the user scrolls:
+ // We special case handling of popups, since they have an implicitt mouse grab.
+ QWidget *candidate = buttonDownNotBlockedByModal ? qt_button_down : widgetUnderMouse;
+ if (!popup->isAncestorOf(candidate)) {
+ // INVARIANT: we have a popup, but the candidate is not
+ // in it. But the popup will grab the mouse anyway,
+ // except if the user scrolls:
if (eventType == QEvent::Wheel)
return 0;
returnLocalPoint = popup->mapFromGlobal(returnGlobalPoint);
return popup;
- } else if (popup == widgetUnderMouse) {
+ } else if (popup == candidate) {
+ // INVARIANT: The candidate is the popup itself, and not a child:
returnLocalPoint = popup->mapFromGlobal(returnGlobalPoint);
return popup;
} else {
- returnLocalPoint = widgetUnderMouse->mapFromGlobal(returnGlobalPoint);
- return widgetUnderMouse;
+ // INVARIANT: The candidate is a child inside the popup:
+ returnLocalPoint = candidate->mapFromGlobal(returnGlobalPoint);
+ return candidate;
}
}