diff mbox series

[PULL,6/7] ui/cocoa: Subclass NSApplication so we can implement sendEvent

Message ID 20190304164958.9362-7-peter.maydell@linaro.org
State Accepted
Commit 61a2ed447e1c0a05c4bb568c579a2d64c2d9c232
Headers show
Series cocoa queue | expand

Commit Message

Peter Maydell March 4, 2019, 4:49 p.m. UTC
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 <peter.maydell@linaro.org>

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>

Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>

Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>

Message-id: 20190225102433.22401-7-peter.maydell@linaro.org
Message-id: 20190214102816.3393-7-peter.maydell@linaro.org
---
 ui/cocoa.m | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

-- 
2.20.1
diff mbox series

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 1b54d42aba6..00e3db69c91 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -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();