summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2009-03-26 16:55:39 +0100
committerDavid Boddie <dboddie@trolltech.com>2009-03-26 16:55:39 +0100
commit213d9224b81fd3350266e304b40f7469fbc0c695 (patch)
treed7b975121376b809c189b91ca2d6734ebe87d41d
parent0e459b6b5a4a8d900c675cdcb5312535de2fe535 (diff)
parentf5ef0eb1a6543abdd29e07c23de7fa1128f6d623 (diff)
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into 4.5
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm102
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm18
-rw-r--r--src/gui/kernel/qwidget_mac.mm2
3 files changed, 121 insertions, 1 deletions
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index 6aeee34400..c17b30c9e3 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -43,10 +43,14 @@
#ifdef QT_MAC_USE_COCOA
#import <private/qt_cocoa_helpers_mac_p.h>
#import <private/qcocoawindow_mac_p.h>
+#import <private/qcocoawindowdelegate_mac_p.h>
+#import <private/qcocoaview_mac_p.h>
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
#include <QtGui/QWidget>
+extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
+
QT_USE_NAMESPACE
@implementation QT_MANGLE_NAMESPACE(QCocoaPanel)
@@ -60,14 +64,110 @@ QT_USE_NAMESPACE
return !(isPopup || isToolTip);
}
+/***********************************************************************
+ BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
+ This is a bit unfortunate, but thanks to the dynamic dispatch we
+ have to duplicate this code or resort to really silly forwarding methods
+**************************************************************************/
+
+/*
+ The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
+ get hit. We automatically say we can be first responder if we are a window.
+ So, the handling should get handled by the view. This is here more as a
+ last resort (i.e., this is code that can potentially be removed).
+ */
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ if (!keyOK)
+ [super keyDown:theEvent];
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ if (!keyOK)
+ [super keyUp:theEvent];
+}
+
+- (void)flagsChanged:(NSEvent *)theEvent
+{
+ qt_dispatchModifiersChanged(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ [super flagsChanged:theEvent];
+}
+
+
+- (void)tabletProximity:(NSEvent *)tabletEvent
+{
+ qt_dispatchTabletProximityEvent(tabletEvent);
+}
+
- (void)sendEvent:(NSEvent *)event
{
[self retain];
- [super sendEvent:event];
+
+ QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
+ QCocoaView *view = static_cast<QCocoaView *>(qt_mac_nativeview_for(widget));
+ Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
+
+ // sometimes need to redirect mouse events to the popup.
+ QWidget *popup = qAppInstance()->activePopupWidget();
+ if (popup && popup != widget) {
+ switch([event type])
+ {
+ case NSLeftMouseDown:
+ qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton);
+ // 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.
+ // (this is standard Qt behavior.)
+ break;
+ case NSRightMouseDown:
+ case NSOtherMouseDown:
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton))
+ [super sendEvent:event];
+ break;
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonRelease, mouseButton))
+ [super sendEvent:event];
+ break;
+ case NSMouseMoved:
+ qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, Qt::NoButton);
+ break;
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->view = view;
+ [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->theEvent = event;
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, mouseButton))
+ [super sendEvent:event];
+ break;
+ default:
+ [super sendEvent:event];
+ break;
+ }
+ } else {
+ [super sendEvent:event];
+ }
qt_mac_dispatchNCMouseMessage(self, event, [self QT_MANGLE_NAMESPACE(qt_qwidget)], leftButtonIsRightButton);
+
+
[self release];
}
+
+- (BOOL)makeFirstResponder:(NSResponder *)responder
+{
+ if (responder == nil)
+ return NO;
+ return [super makeFirstResponder:responder];
+}
+
+/***********************************************************************
+ END Copy and Paste between QCocoaWindow and QCocoaPanel
+***********************************************************************/
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 6b304440a7..ba121cd682 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -86,6 +86,12 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
return YES;
}
+/***********************************************************************
+ BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
+ This is a bit unfortunate, but thanks to the dynamic dispatch we
+ have to duplicate this code or resort to really silly forwarding methods
+**************************************************************************/
+
/*
The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
get hit. We automatically say we can be first responder if we are a window.
@@ -173,6 +179,18 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
[self release];
}
+
+- (BOOL)makeFirstResponder:(NSResponder *)responder
+{
+ if (responder == nil)
+ return NO;
+ return [super makeFirstResponder:responder];
+}
+
+/***********************************************************************
+ END Copy and Paste between QCocoaWindow and QCocoaPanel
+***********************************************************************/
+
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index f599b7cf25..7a586e1f90 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2514,6 +2514,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
updateIsOpaque();
+ if (q->hasFocus())
+ setFocus_sys();
if (!topLevel && initializeWindow)
setWSGeometry();