qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck key situation
@ 2015-09-18 21:46 Programmingkid
  2015-09-19 15:07 ` Peter Maydell
  2015-09-23 18:04 ` Peter Maydell
  0 siblings, 2 replies; 6+ messages in thread
From: Programmingkid @ 2015-09-18 21:46 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1888 bytes --]

When the user puts QEMU in the background while holding down a key, QEMU will 
not receive the keyup event when the user lets go of the key. When the user goes
back to QEMU, QEMU will think the key is still down causing stuck key symptoms.
This patch fixes this problem by releasing all keys when QEMU goes into the
background. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

---
 ui/cocoa.m |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 334e6f6..d07b22d 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -69,6 +69,7 @@ char **gArgv;
 bool stretch_video;
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
+int modifiers_state[256];
 
 // keymap conversion
 int keymap[] =
@@ -274,7 +275,6 @@ static void handleAnyDeviceErrors(Error * err)
     NSWindow *fullScreenWindow;
     float cx,cy,cw,ch,cdx,cdy;
     CGDataProviderRef dataProviderRef;
-    int modifiers_state[256];
     BOOL isMouseGrabbed;
     BOOL isFullscreen;
     BOOL isAbsoluteEnabled;
@@ -933,6 +933,21 @@ QemuCocoaView *cocoaView;
     return YES;
 }
 
+/* Called when QEMU goes into the background */
+- (void) applicationWillResignActive: (NSNotification *)aNotification
+{
+    COCOA_DEBUG("QemuCocoaAppController: applicationWillResignActive\n");
+    int keycode, index;
+    const int max_index = 126; /* This is the size of the keymap array */
+
+    /* Release all the keys to prevent a stuck key situation */
+    for(index = 0; index <= max_index; index++) {
+        keycode = keymap[index];
+        modifiers_state[keycode] = 0;
+        qemu_input_event_send_key_number(dcl->con, keycode, false);
+    }
+}
+
 - (void)startEmulationWithArgc:(int)argc argv:(char**)argv
 {
     COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
-- 
1.7.5.4


[-- Attachment #2: Type: text/html, Size: 10335 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-23 21:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-18 21:46 [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck key situation Programmingkid
2015-09-19 15:07 ` Peter Maydell
2015-09-19 15:11   ` Programmingkid
2015-09-23 18:04 ` Peter Maydell
2015-09-23 21:44   ` Programmingkid
2015-09-23 21:46     ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).