summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-07-01 12:34:21 (GMT)
committerPrasanth Ullattil <prasanth.ullattil@nokia.com>2009-07-02 14:58:12 (GMT)
commit097476afe24d69bac65b84b70ed2f93e88875b40 (patch)
tree15449591ab6aa79e7eec120da3190938a5682769 /src/gui
parent3473453dda9f40bf94733bc971b0cc1658e7c3c8 (diff)
downloadQt-097476afe24d69bac65b84b70ed2f93e88875b40.zip
Qt-097476afe24d69bac65b84b70ed2f93e88875b40.tar.gz
Qt-097476afe24d69bac65b84b70ed2f93e88875b40.tar.bz2
Implement hitTest
Cocoa calls hitTest on our view to determine if the view should get the mouse press. We always said, "yes" and did all the logic ourselves. Turns out that we can say "no" if I'm transparent to mouse events and remove all that code where we do all the work ourselves. Big maintenance win! For the time being I've kept the "transparentViewForEvent" method since it might be useful for others, but no one is using it at the moment and we may just kill it soon. HitTest should handle this situation correctly.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm17
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm44
2 files changed, 7 insertions, 54 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 17e3313..81e06a9 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -554,6 +554,13 @@ extern "C" {
return !qwidget->testAttribute(Qt::WA_MacNoClickThrough);
}
+- (NSView *)hitTest:(NSPoint)aPoint
+{
+ if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents))
+ return nil; // You cannot hit a transparent for mouse event widget.
+ return [super hitTest:aPoint];
+}
+
- (void)updateTrackingAreas
{
QMacCocoaAutoReleasePool pool;
@@ -794,16 +801,6 @@ extern "C" {
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([theEvent modifierFlags]);
QWidget *widgetToGetMouse = qwidget;
- if (widgetToGetMouse->testAttribute(Qt::WA_TransparentForMouseEvents)) {
- // Simulate passing the event through since Cocoa doesn't do that for us.
- // Start by building a tree up.
- NSView *candidateView = [self viewUnderTransparentForMouseView:self
- widget:widgetToGetMouse
- withWindowPoint:windowPoint];
- if (candidateView != nil) {
- widgetToGetMouse = QWidget::find(WId(candidateView));
- }
- }
// Mouse wheel deltas seem to tick in at increments of 0.1. Qt widgets
// expect the delta to be a multiple of 120.
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 2dd4fdf..241ea44 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -851,50 +851,6 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev
NSPoint localPoint = [tmpView convertPoint:windowPoint fromView:nil];
QPoint qlocalPoint(localPoint.x, localPoint.y);
- if (widgetToGetMouse->testAttribute(Qt::WA_TransparentForMouseEvents)) {
- // Simulate passing the event through since Cocoa doesn't do that for us.
- // Start by building a tree up.
- NSView *candidateView = [theView viewUnderTransparentForMouseView:tmpView
- widget:widgetToGetMouse
- withWindowPoint:windowPoint];
- if (candidateView != nil) {
- // Fast-track our views, since dispatching trough the normal ways
- // would just end up going through here anyway.
- if ([candidateView isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) {
- return qt_mac_handleMouseEvent(candidateView, theEvent, eventType, button);
- } else {
- switch (eventType) {
- default:
- qWarning("not handled! %d", eventType);
- break;
- case QEvent::MouseMove:
- [candidateView mouseMoved:theEvent];
- break;
- case QEvent::MouseButtonPress:
- if (button == Qt::LeftButton)
- [candidateView mouseDown:theEvent];
- else if (button == Qt::RightButton)
- [candidateView rightMouseDown:theEvent];
- else
- [candidateView otherMouseDown:theEvent];
- break;
- case QEvent::MouseButtonRelease:
- if (button == Qt::LeftButton)
- [candidateView mouseUp:theEvent];
- else if (button == Qt::RightButton)
- [candidateView rightMouseUp:theEvent];
- else
- [candidateView otherMouseUp:theEvent];
- break;
- }
- return true; // We've done the dispatching, no need go further.
- }
- }
- // Nothing below me return false
- return false;
- }
-
-
EventRef carbonEvent = static_cast<EventRef>(const_cast<void *>([theEvent eventRef]));
if (qt_mac_sendMacEventToWidget(widgetToGetMouse, carbonEvent))
return true;