From patchwork Fri Sep 25 22:18:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 54182 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 74C2F218DB for ; Fri, 25 Sep 2015 22:20:13 +0000 (UTC) Received: by laff1 with SMTP id f1sf45191692laf.2 for ; Fri, 25 Sep 2015 15:20:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=eIq5xNOyJZLJKBJzUSEymgskdA6AyhhlEELgt0ZRjKM=; b=CbvqXh2kdWTfFATyfQ/XAicUTq9uo1jYyUA+nSyBvE8DfFLpHhxXSZwVM+W9xdt9jg PAV5CY8zvkdSKLqwi5kz9VzgQ+heWuZrQD2bE7jTWshIY9v0yF/3du+PvdsozEQzcYHf X9S6rW3yf9RrqkkpMRfJmwnBSkmp8MnxDDIyPgTSUJZ7+mdCkRrG/YWwXh9Jm9lAHh3l SaCw6ziHMopoEeMUsbNWZ3rbF36Ga7+d+lLWPtNDW6LTwuyjXmGzUpMr0iBtNILyZ2oi rqHc9KQoj7FV2mefYExpS5jEjpr5XHWXecbbc7kTTNtptxDocFvCz8+rPoS688YbNuE8 VBVA== X-Gm-Message-State: ALoCoQnZ2LQlGL1wAHMj/VWSJCrGQrbQGIL3ij4J3zofHDOXB42C1fZ1Ynw3VrMd2HKOPDQz+FJj X-Received: by 10.112.130.41 with SMTP id ob9mr1290275lbb.17.1443219611724; Fri, 25 Sep 2015 15:20:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.38.206 with SMTP id m197ls241721lfm.55.gmail; Fri, 25 Sep 2015 15:20:11 -0700 (PDT) X-Received: by 10.25.150.83 with SMTP id y80mr1487330lfd.119.1443219611586; Fri, 25 Sep 2015 15:20:11 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id dr7si2588691lbc.106.2015.09.25.15.20.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Sep 2015 15:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lahh2 with SMTP id h2so111194851lah.0 for ; Fri, 25 Sep 2015 15:20:11 -0700 (PDT) X-Received: by 10.152.5.133 with SMTP id s5mr2340351las.19.1443219611351; Fri, 25 Sep 2015 15:20:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp291336lbq; Fri, 25 Sep 2015 15:20:10 -0700 (PDT) X-Received: by 10.107.136.213 with SMTP id s82mr8781281ioi.111.1443219609475; Fri, 25 Sep 2015 15:20:09 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j20si4238168ioe.208.2015.09.25.15.20.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 25 Sep 2015 15:20:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:50743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfbLc-0000wL-VA for patch@linaro.org; Fri, 25 Sep 2015 18:20:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfbKY-0008I7-CZ for qemu-devel@nongnu.org; Fri, 25 Sep 2015 18:19:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfbKX-0007Rg-J8 for qemu-devel@nongnu.org; Fri, 25 Sep 2015 18:19:02 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:35102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfbKX-0007Mt-DU for qemu-devel@nongnu.org; Fri, 25 Sep 2015 18:19:01 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZfbKP-0003zW-10 for qemu-devel@nongnu.org; Fri, 25 Sep 2015 23:18:53 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 25 Sep 2015 23:18:51 +0100 Message-Id: <1443219532-15309-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1443219532-15309-1-git-send-email-peter.maydell@linaro.org> References: <1443219532-15309-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 2/3] 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: John Arbuckle 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 down keys when QEMU goes into the background. Signed-off-by: John Arbuckle Message-id: 7A3FA6EE-84C8-4422-A786-C899B7229D32@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- ui/cocoa.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ui/cocoa.m b/ui/cocoa.m index 7c64e1a..d436780 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -304,6 +304,7 @@ static void handleAnyDeviceErrors(Error * err) - (float) cdx; - (float) cdy; - (QEMUScreen) gscreen; +- (void) raiseAllKeys; @end QemuCocoaView *cocoaView; @@ -798,6 +799,24 @@ QemuCocoaView *cocoaView; - (float) cdx {return cdx;} - (float) cdy {return cdy;} - (QEMUScreen) gscreen {return screen;} + +/* + * Makes the target think all down keys are being released. + * This prevents a stuck key problem, since we will not see + * key up events for those keys after we have lost focus. + */ +- (void) raiseAllKeys +{ + int index; + const int max_index = ARRAY_SIZE(modifiers_state); + + for (index = 0; index < max_index; index++) { + if (modifiers_state[index]) { + modifiers_state[index] = 0; + qemu_input_event_send_key_number(dcl->con, index, false); + } + } +} @end @@ -955,6 +974,13 @@ QemuCocoaView *cocoaView; return NO; } +/* Called when QEMU goes into the background */ +- (void) applicationWillResignActive: (NSNotification *)aNotification +{ + COCOA_DEBUG("QemuCocoaAppController: applicationWillResignActive\n"); + [cocoaView raiseAllKeys]; +} + - (void)startEmulationWithArgc:(int)argc argv:(char**)argv { COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");