]> Git Repo - qemu.git/commitdiff
ui/cocoa: Subclass NSApplication so we can implement sendEvent
authorPeter Maydell <[email protected]>
Mon, 25 Feb 2019 10:24:32 +0000 (10:24 +0000)
committerPeter Maydell <[email protected]>
Mon, 4 Mar 2019 16:47:31 +0000 (16:47 +0000)
When we switch away from our custom event handling, we still want to
be able to have first go at any events our application receives,
because in full-screen mode we want to send key events to the guest,
even if they would be menu item activation events. There are several
ways we could do that, but one simple approach is to subclass
NSApplication so we can implement a custom sendEvent method.
Do that, but for the moment have our sendEvent just invoke the
superclass method.

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Reviewed-by: Roman Bolshakov <[email protected]>
Tested-by: Roman Bolshakov <[email protected]>
Message-id: 20190225102433[email protected]
Message-id: 20190214102816[email protected]

ui/cocoa.m

index 1b54d42aba6fb645d31d2fec73e02cffb31ab0b8..00e3db69c917c552ea963b9e0eade419e36268e6 100644 (file)
@@ -1482,6 +1482,17 @@ QemuCocoaView *cocoaView;
 
 @end
 
+@interface QemuApplication : NSApplication
+@end
+
+@implementation QemuApplication
+- (void)sendEvent:(NSEvent *)event
+{
+    COCOA_DEBUG("QemuApplication: sendEvent\n");
+    [super sendEvent: event];
+}
+@end
+
 static void create_initial_menus(void)
 {
     // Add menus
@@ -1695,7 +1706,7 @@ int main (int argc, const char * argv[]) {
     ProcessSerialNumber psn = { 0, kCurrentProcess };
     TransformProcessType(&psn, kProcessTransformToForegroundApplication);
 
-    [NSApplication sharedApplication];
+    [QemuApplication sharedApplication];
 
     create_initial_menus();
 
This page took 0.033242 seconds and 4 git commands to generate.