From patchwork Fri Sep 18 21:46:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 519587 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 51EC4140909 for ; Sat, 19 Sep 2015 07:46:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=eenId6lI; dkim-atps=neutral Received: from localhost ([::1]:42101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd3UX-00077d-85 for incoming@patchwork.ozlabs.org; Fri, 18 Sep 2015 17:46:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd3UG-0006pn-Uy for qemu-devel@nongnu.org; Fri, 18 Sep 2015 17:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zd3UB-0005Pk-Ve for qemu-devel@nongnu.org; Fri, 18 Sep 2015 17:46:32 -0400 Received: from mail-qg0-x236.google.com ([2607:f8b0:400d:c04::236]:34124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zd3UB-0005Pg-PI for qemu-devel@nongnu.org; Fri, 18 Sep 2015 17:46:27 -0400 Received: by qgez77 with SMTP id z77so50066674qge.1 for ; Fri, 18 Sep 2015 14:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:date:message-id:to:mime-version; bh=TzAE/MQmh81lt7EpyWxcSvYxi2OAdJk2HfA+RSvWsAA=; b=eenId6lI7GkHfYeTuHSFtlyZWfKr6VSFaGM7cBm9ndT6ih12IMNZtefdkhp9xxLg6F 3SkEhjgssW6xv8yKQvcKzAOYABOf4PIFNqeMNn6qGSzMm6ZqesAIe4NgUuUzZvkHvv5y NAflFgNy5ZnP1TI4rW+apfWYsRvVZbABOo+9bsXvTf5nATj6rSJuFrCZrPZXuXltfL9r 5653u8iACaPQebHuot9xWyIxBLBIk1MCfXwoZ5Z9aQSvGRgyF5GWVYJkoSIud8dP49l8 qZ/tGpvckvINRxwZDTA+sZpLdfC0pKE3BnAg12BF2dNMjSaZzRrMTzVVwRHFZb+LdMeN A4dQ== X-Received: by 10.140.133.69 with SMTP id 66mr9771090qhf.12.1442612787325; Fri, 18 Sep 2015 14:46:27 -0700 (PDT) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id f107sm4488490qge.23.2015.09.18.14.46.18 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Sep 2015 14:46:26 -0700 (PDT) From: Programmingkid Date: Fri, 18 Sep 2015 17:46:08 -0400 Message-Id: <4D622DB1-AB63-4FDE-8B40-30FE9897E510@gmail.com> To: Peter Maydell , qemu-devel qemu-devel Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::236 Subject: [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck key situation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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");