6#include <AppKit/AppKit.h>
14#include <qguiapplication.h>
23 quint64 lower = [event data1];
24 quint64 upper = [event data2];
25 QCocoaPostMessageArgs *args =
reinterpret_cast<QCocoaPostMessageArgs *>(lower | (upper << 32));
28 id a1 = ([args->arg1 isKindOfClass:[NSNumber
class]]) ? (id)[args->arg1 longValue] : args->arg1;
29 id a2 = ([args->arg2 isKindOfClass:[NSNumber
class]]) ? (id)[args->arg2 longValue] : args->arg2;
30 switch (args->argCount) {
32 [args->target performSelector:args->selector];
35 [args->target performSelector:args->selector withObject:a1];
38 [args->target performSelector:args->selector withObject:a1 withObject:a2];
49 if (
qApp &&
qApp->eventDispatcher()->
50 filterNativeEvent(q_macLocalEventType,
static_cast<
void*>(event),
nullptr))
53 if (event.type == NSEventTypeApplicationDefined) {
54 switch (
static_cast<
short>(event.subtype)) {
55 case QtCocoaEventSubTypePostMessage:
56 qt_sendPostedMessage(event);
74 if (event.type == NSEventTypeKeyUp && (event.modifierFlags & NSEventModifierFlagCommand)) {
75 NSWindow *targetWindow = event.window;
76 if ([targetWindow.
class conformsToProtocol:@protocol(QNSWindowProtocol)])
77 [targetWindow sendEvent:event];
81@implementation QNSApplication
83- (
void)QT_MANGLE_NAMESPACE(qt_sendEvent_original):(NSEvent *)event
91- (
void)QT_MANGLE_NAMESPACE(qt_sendEvent_replacement):(NSEvent *)event
97 if (!qt_filterEvent(event)) {
98 [self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
99 qt_maybeSendKeyEquivalentUpEvent(event);
103- (
void)sendEvent:(NSEvent *)event
107 if (!qt_filterEvent(event)) {
108 [super sendEvent:event];
109 qt_maybeSendKeyEquivalentUpEvent(event);
117void qt_redirectNSApplicationSendEvent()
119 if (QCoreApplication::testAttribute(Qt::AA_PluginApplication))
125 if ([NSApp isMemberOfClass:[QNSApplication
class]]) {
135 qt_cocoa_change_implementation(
136 [NSApplication
class],
137 @selector(sendEvent:),
138 [QNSApplication
class],
139 @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_replacement):),
140 @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):));
145 if (QCoreApplication::testAttribute(Qt::AA_PluginApplication))
149 qt_cocoa_change_back_implementation([NSApplication
class],
150 @selector(sendEvent:),
151 @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):));
static bool qt_filterEvent(NSEvent *event)
static QT_USE_NAMESPACE void qt_sendPostedMessage(NSEvent *event)
static const QByteArray q_macLocalEventType
static void qt_maybeSendKeyEquivalentUpEvent(NSEvent *event)
void qt_resetNSApplicationSendEvent()