From nobody Sun May 5 03:32:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529377098890654.7987306112516; Mon, 18 Jun 2018 19:58:18 -0700 (PDT) Received: from localhost ([::1]:38810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6qY-0008BZ-5M for importer@patchew.org; Mon, 18 Jun 2018 22:58:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5v1-0003K3-Kq for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:58:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ux-0005lc-PT for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:58:51 -0400 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]:54968) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ux-0005lH-K7 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:58:47 -0400 Received: by mail-it0-x244.google.com with SMTP id 76-v6so14949846itx.4 for ; Mon, 18 Jun 2018 18:58:47 -0700 (PDT) Received: from localhost.localdomain ([69.14.184.20]) by smtp.gmail.com with ESMTPSA id g17-v6sm4331494iti.1.2018.06.18.18.58.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 18 Jun 2018 18:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=s8l4GvO+eAVsnjCXJrvqr4SQNzn6Kendmb1zEHX7wHw=; b=QQItlYJhXICAmun1EJUyQzvb3qUd92zC+UDtWbIPHmDBNYkeu5bSZHbnAfxiwhQz9e G7ca8KeMtwpfvbtMQk4xTh2g94TNNoq6c9+BPSLSuTeBKvtsMiIpkuFjhdrjg9sIaW3/ CXib0UuMhPYhiS3jcAVBNBfBGNv7CZIo8f8RC9ScyP2xUvRBBOmQr8p7VSmIBuTXfwvp L0AT/nRBSxVuVtN3WZRYDJInktk3CLTmMaHMcEO15l1IxANA1EMQraxBW8lQZF7B1BPK 4ulLkFfwWaUUIWFhxLmFKYN+yaw/1+k1BwLJsupmyvADMD78Rblh+ufE1mBoRlTY/AJ+ j76w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=s8l4GvO+eAVsnjCXJrvqr4SQNzn6Kendmb1zEHX7wHw=; b=o5yMwzlBMMD2/+Kek7AfjqHUzi3zm6mcdFZSfZonp8QzOblKYMjKbsQ+bW8+xd8p0Z OFEoNPjMJHklLhZULcpAj1I9I79AX1KypU4GDnw3IotUPVqNUZvBsxJLgZbtO7tgi7fM aRB+0fBj79jjL58+pk+A3AOpkGv6aiBjbU7yc6wLr1HQsMFDXHi/Fbkeesk837oYW/dH Xy7v8SOTyttSzyzEdBIxxoKiF9Qlyu0msdL0KE8FB5fGHkf995xED9WAbz49LbNsn07r 8is21O6ROfKuVTQhTuazonw+lXshjJYC+o+bIQCI4udpAmVPSa3k+F6LuUYdOz+AL3Ui QlIA== X-Gm-Message-State: APt69E3AybT6BxJjWErQ29bLNEnP2Q/xEt9IhHbeIQAfJCe5Wf+TFiG0 rYz9/+nyAvyUG6mgujsfIdo= X-Google-Smtp-Source: ADUXVKJzEil0LbutA3QaIbujLUYde5S7AkcigOZbRD57+DSj7PyMnYrkLQdv0OkaY4sr/v3dNXFGTg== X-Received: by 2002:a24:3c8:: with SMTP id e191-v6mr12321771ite.70.1529373526887; Mon, 18 Jun 2018 18:58:46 -0700 (PDT) From: John Arbuckle To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 21:58:32 -0400 Message-Id: <20180619015832.7398-1-programmingkidx@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::244 Subject: [Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When the user pushes Command-F in QEMU while the mouse is ungrabbed, QEMU goes into full screen mode. When the user finally releases the command key, it is sent to the guest as an event. The makes the guest operating system think the command key is down when it is really up. To prevent this situati= on from happening, we simply drop the first command key event after the user h= as gone into full screen mode using Command-F. Signed-off-by: John Arbuckle --- ui/cocoa.m | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 2991ed4..024aba2 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -287,6 +287,7 @@ static void handleAnyDeviceErrors(Error * err) BOOL isFullscreen; BOOL isAbsoluteEnabled; BOOL isMouseDeassociated; + BOOL prevent_stuck_command_key; } - (void) switchSurface:(DisplaySurface *)surface; - (void) grabMouse; @@ -330,7 +331,7 @@ QemuCocoaView *cocoaView; screen.bitsPerPixel =3D 32; screen.width =3D frameRect.size.width; screen.height =3D frameRect.size.height; - + prevent_stuck_command_key =3D NO; } return self; } @@ -552,6 +553,14 @@ QemuCocoaView *cocoaView; } =20 - (void) toggleModifier: (int)keycode { + + /* Prevents the command key from being sent to the guest */ + if ((keycode =3D=3D Q_KEY_CODE_META_L || keycode =3D=3D Q_KEY_CODE_MET= A_R) && + prevent_stuck_command_key =3D=3D YES) { + prevent_stuck_command_key =3D NO; + return; + } + // Toggle the stored state. modifiers_state[keycode] =3D !modifiers_state[keycode]; // Send a keyup or keydown depending on the state. @@ -691,6 +700,13 @@ QemuCocoaView *cocoaView; =20 // forward command key combos to the host UI unless the mouse = is grabbed if (!isMouseGrabbed && ([event modifierFlags] & NSEventModifie= rFlagCommand)) { + /* + * Prevent the command key from being stuck down in the gu= est + * when using Command-F for full screen mode + */ + if (keycode =3D=3D Q_KEY_CODE_F) { + prevent_stuck_command_key =3D YES; + } [NSApp sendEvent:event]; return; } --=20 2.7.2