summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaapplication.mm
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2012-10-18 11:15:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-09 04:09:09 +0100
commit7aae8c0f0fd566b0b1414548469cb0b5c0c9ec46 (patch)
tree2e5c8039bcd8fdb63f0b4a47a462d89c20a1eb9f /src/plugins/platforms/cocoa/qcocoaapplication.mm
parent593b8f7f0b35ddc424d8ccbd5df11fcf2442858e (diff)
Support native event filter for Mac OS X
Ported from Qt 4 implementation, updated with QAbstractEventDispatcher::filterNativeEvent() call. Tested with an example. Change-Id: I3271f8a565d06d80b7b48ba81728bcdb7b1c32e3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaapplication.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm
index 5b646d8942..a50c480f1f 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm
@@ -75,6 +75,7 @@
#include <qcocoaapplication.h>
+#include <qcocoaintrospection.h>
#include <qcocoaapplicationdelegate.h>
#include <qcocoahelpers.h>
#include <qguiapplication.h>
@@ -107,8 +108,6 @@ QT_USE_NAMESPACE
- (void)qt_sendPostedMessage:(NSEvent *)event
{
- Q_UNUSED(event);
-/*
// WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5!
// That is why we need to split the address in two parts:
quint64 lower = [event data1];
@@ -131,14 +130,14 @@ QT_USE_NAMESPACE
}
delete args;
-*/
}
+static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSEvent");
+
- (BOOL)qt_filterEvent:(NSEvent *)event
{
- Q_UNUSED(event);
-/*
- if (qApp && qApp->macEventFilter(0, reinterpret_cast<EventRef>(event)))
+ if (qApp && qApp->eventDispatcher()->
+ filterNativeEvent(q_macLocalEventType, static_cast<void*>(event), 0))
return true;
if ([event type] == NSApplicationDefined) {
@@ -150,13 +149,13 @@ QT_USE_NAMESPACE
break;
}
}
-*/
+
return false;
}
@end
-@implementation QNSApplication
+@implementation QT_MANGLE_NAMESPACE(QNSApplication)
- (void)qt_sendEvent_original:(NSEvent *)event
{
@@ -190,8 +189,7 @@ QT_BEGIN_NAMESPACE
void qt_redirectNSApplicationSendEvent()
{
-/*
- if ([NSApp isMemberOfClass:[QNSApplication class]]) {
+ if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
// No need to change implementation since Qt
// already controls a subclass of NSApplication
return;
@@ -204,10 +202,16 @@ void qt_redirectNSApplicationSendEvent()
qt_cocoa_change_implementation(
[NSApplication class],
@selector(sendEvent:),
- [QNSApplication class],
+ [QT_MANGLE_NAMESPACE(QNSApplication) class],
@selector(qt_sendEvent_replacement:),
@selector(qt_sendEvent_original:));
- */
}
+void qt_resetNSApplicationSendEvent()
+{
+ qt_cocoa_change_back_implementation([NSApplication class],
+ @selector(sendEvent:),
+ @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):));
+}
+
QT_END_NAMESPACE