summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorYan Shapochnik <shapochniky@seapine.com>2012-10-09 18:14:48 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-15 07:09:08 (GMT)
commitd8473681955bd96f8dd9cb22ad2597a9b7479d80 (patch)
tree89bc428b5c245fdc38d2360b269197d45245666e /src/gui
parenta0107b783df9b61221ea57b79fefb8fa77f917ed (diff)
downloadQt-d8473681955bd96f8dd9cb22ad2597a9b7479d80.zip
Qt-d8473681955bd96f8dd9cb22ad2597a9b7479d80.tar.gz
Qt-d8473681955bd96f8dd9cb22ad2597a9b7479d80.tar.bz2
Mangle QNSApplication and methods into a namespace
Ensure Qt's native implementation of sendEvent: calls the proper Qt event filters and passes them along to the correct QApplication instance thus guaranteeing that macEventFilter() is properly called when a non namespaced and a namespaced Qt exists in one process. Change-Id: I61543d6ef68b09cfb40c9d263aaaf5ead5ece24b Reviewed-by: Yan Shapochnik <shapochniky@seapine.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qcocoaapplication_mac.mm25
-rw-r--r--src/gui/kernel/qcocoaapplication_mac_p.h4
2 files changed, 16 insertions, 13 deletions
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm
index 16ac578..dbdecfa 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/gui/kernel/qcocoaapplication_mac.mm
@@ -110,7 +110,7 @@ QT_USE_NAMESPACE
| NSFontPanelStrikethroughEffectModeMask;
}
-- (void)qt_sendPostedMessage:(NSEvent *)event
+- (void)QT_MANGLE_NAMESPACE(qt_sendPostedMessage):(NSEvent *)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:
@@ -136,15 +136,18 @@ QT_USE_NAMESPACE
delete args;
}
-- (BOOL)qt_filterEvent:(NSEvent *)event
+- (BOOL)QT_MANGLE_NAMESPACE(qt_filterEvent):(NSEvent *)event
{
+ if (!qApp)
+ return false;
+
if (qApp->macEventFilter(0, reinterpret_cast<EventRef>(event)))
return true;
if ([event type] == NSApplicationDefined) {
switch ([event subtype]) {
case QtCocoaEventSubTypePostMessage:
- [NSApp qt_sendPostedMessage:event];
+ [NSApp QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
return true;
default:
break;
@@ -157,7 +160,7 @@ QT_USE_NAMESPACE
@implementation QT_MANGLE_NAMESPACE(QNSApplication)
-- (void)qt_sendEvent_original:(NSEvent *)event
+- (void)QT_MANGLE_NAMESPACE(qt_sendEvent_original):(NSEvent *)event
{
Q_UNUSED(event);
// This method will only be used as a signature
@@ -165,21 +168,21 @@ QT_USE_NAMESPACE
// containing the original [NSApplication sendEvent:] implementation
}
-- (void)qt_sendEvent_replacement:(NSEvent *)event
+- (void)QT_MANGLE_NAMESPACE(qt_sendEvent_replacement):(NSEvent *)event
{
// This method (or its implementation to be precise) will
// be called instead of sendEvent if redirection occurs.
// 'self' will then be an instance of NSApplication
// (and not QNSApplication)
- if (![NSApp qt_filterEvent:event])
- [self qt_sendEvent_original:event];
+ if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
+ [self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
}
- (void)sendEvent:(NSEvent *)event
{
// This method will be called if
// no redirection occurs
- if (![NSApp qt_filterEvent:event])
+ if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
[super sendEvent:event];
}
@@ -214,15 +217,15 @@ void qt_redirectNSApplicationSendEvent()
[NSApplication class],
@selector(sendEvent:),
[QNSApplication class],
- @selector(qt_sendEvent_replacement:),
- @selector(qt_sendEvent_original:));
+ @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_replacement):),
+ @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):));
}
void qt_resetNSApplicationSendEvent()
{
qt_cocoa_change_back_implementation([NSApplication class],
@selector(sendEvent:),
- @selector(qt_sendEvent_original:));
+ @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):));
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcocoaapplication_mac_p.h b/src/gui/kernel/qcocoaapplication_mac_p.h
index 8b5284a..0167323 100644
--- a/src/gui/kernel/qcocoaapplication_mac_p.h
+++ b/src/gui/kernel/qcocoaapplication_mac_p.h
@@ -100,8 +100,8 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate)
- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader);
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel;
-- (void)qt_sendPostedMessage:(NSEvent *)event;
-- (BOOL)qt_filterEvent:(NSEvent *)event;
+- (void)QT_MANGLE_NAMESPACE(qt_sendPostedMessage):(NSEvent *)event;
+- (BOOL)QT_MANGLE_NAMESPACE(qt_filterEvent):(NSEvent *)event;
@end
@interface QT_MANGLE_NAMESPACE(QNSApplication) : NSApplication {