summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-23 16:56:03 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-24 12:20:25 (GMT)
commitaae81f370f6afede95064bc75eb7ee6ac13b1c30 (patch)
tree63bc99549ca84bce95f082f1de9fe129aab05b27 /src/gui/kernel
parentd3bea65eae71a21a7b9893317c4dbafba20f17c8 (diff)
downloadQt-aae81f370f6afede95064bc75eb7ee6ac13b1c30.zip
Qt-aae81f370f6afede95064bc75eb7ee6ac13b1c30.tar.gz
Qt-aae81f370f6afede95064bc75eb7ee6ac13b1c30.tar.bz2
Fixes implicit grabbing in Qt/Cocoa
When delivering mouse events in Qt/Cocoa set the implicit mouse grabber and deliver the event to it and do not try to propagate the event to the parent view. Reviewed-by: Prasanth
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm51
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm8
2 files changed, 29 insertions, 30 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 0445a16..3da783f 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -83,6 +83,7 @@ extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp
extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm
extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp
extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm
+extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
{
@@ -695,6 +696,9 @@ extern "C" {
- (void)mouseDown:(NSEvent *)theEvent
{
+ if (!qt_button_down)
+ qt_button_down = qwidget;
+
qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::LeftButton);
// Don't call super here. This prevents us from getting the mouseUp event,
// which we need to send even if the mouseDown event was not accepted.
@@ -704,75 +708,62 @@ extern "C" {
- (void)mouseUp:(NSEvent *)theEvent
{
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::LeftButton);
+ qt_button_down = 0;
- if (!mouseOK)
- [super mouseUp:theEvent];
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::LeftButton);
}
- (void)rightMouseDown:(NSEvent *)theEvent
{
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::RightButton);
+ if (!qt_button_down)
+ qt_button_down = qwidget;
- if (!mouseOK)
- [super rightMouseDown:theEvent];
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::RightButton);
}
- (void)rightMouseUp:(NSEvent *)theEvent
{
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::RightButton);
+ qt_button_down = 0;
- if (!mouseOK)
- [super rightMouseUp:theEvent];
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::RightButton);
}
- (void)otherMouseDown:(NSEvent *)theEvent
{
- Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, mouseButton);
+ if (!qt_button_down)
+ qt_button_down = qwidget;
- if (!mouseOK)
- [super otherMouseDown:theEvent];
+ Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, mouseButton);
}
- (void)otherMouseUp:(NSEvent *)theEvent
{
- Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, mouseButton);
-
- if (!mouseOK)
- [super otherMouseUp:theEvent];
+ qt_button_down = 0;
+ Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, mouseButton);
}
- (void)mouseDragged:(NSEvent *)theEvent
{
qMacDnDParams()->view = self;
qMacDnDParams()->theEvent = theEvent;
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
-
- if (!mouseOK)
- [super mouseDragged:theEvent];
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
}
- (void)rightMouseDragged:(NSEvent *)theEvent
{
qMacDnDParams()->view = self;
qMacDnDParams()->theEvent = theEvent;
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
-
- if (!mouseOK)
- [super rightMouseDragged:theEvent];
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
}
- (void)otherMouseDragged:(NSEvent *)theEvent
{
qMacDnDParams()->view = self;
qMacDnDParams()->theEvent = theEvent;
- bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
-
- if (!mouseOK)
- [super otherMouseDragged:theEvent];
+ qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
}
- (void)scrollWheel:(NSEvent *)theEvent
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index c0fb8aa..2bf1465 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -899,6 +899,14 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev
widgetToGetMouse =
[static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(tmpView) qt_qwidget];
}
+ } else {
+ extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
+ if (!mac_mouse_grabber && qt_button_down) {
+ // if there is no explicit grabber, and the mouse was grabbed
+ // implicitely (i.e. a mousebutton was pressed)
+ widgetToGetMouse = qt_button_down;
+ tmpView = qt_mac_nativeview_for(widgetToGetMouse);
+ }
}
NSPoint localPoint = [tmpView convertPoint:windowPoint fromView:nil];