summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2011-02-08 12:37:52 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2011-02-08 12:50:09 (GMT)
commit7526131cd169b208ed499e62cd493b3d48598a6e (patch)
tree8256982f92031a45c407e442a37470a407b088ba
parentd7b6e0c40bc92318b90d18909442a711defbdcdf (diff)
downloadQt-7526131cd169b208ed499e62cd493b3d48598a6e.zip
Qt-7526131cd169b208ed499e62cd493b3d48598a6e.tar.gz
Qt-7526131cd169b208ed499e62cd493b3d48598a6e.tar.bz2
Cocoa: Mouse-grabbing in pop-up menus on OS X isn't working
The reason is that we special case handling of popups, but have forgotten to check for mouse grabs. This patch checks the grabs, also for popups
-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;
}
}