From nobody Sat May 18 15:38:11 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 153058330163843.06561093058315; Mon, 2 Jul 2018 19:01:41 -0700 (PDT) Received: from localhost ([::1]:37322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faAdR-0006zb-1T for importer@patchew.org; Mon, 02 Jul 2018 22:01:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faAcU-0006bT-2u for qemu-devel@nongnu.org; Mon, 02 Jul 2018 22:00:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faAcP-0004db-4P for qemu-devel@nongnu.org; Mon, 02 Jul 2018 22:00:42 -0400 Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]:46634) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1faAcO-0004cj-V4 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 22:00:37 -0400 Received: by mail-io0-x22b.google.com with SMTP id p7-v6so295902ioh.13 for ; Mon, 02 Jul 2018 19:00:36 -0700 (PDT) Received: from localhost.localdomain ([69.14.184.20]) by smtp.gmail.com with ESMTPSA id l65-v6sm115995ita.8.2018.07.02.19.00.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 19:00:34 -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=CUfbpUO9B1/JUdRuE4p2m2peEVpaozQnxIWitN5n/SU=; b=Zuf6J62PJWnqmSjm7Cp4Sm08Ztx+Z7+jQJT8k/kX7JQoLFd2/Gt49FPLNKtubrg8xu 9Tn9KiivIA789nhzwLw+GHortd/kCMNAaqrN9p8cb76nqbBQ2bW2SZLOnt3VONgktoq4 MtH7LK0ClXG/wmEXUTCIHiYSPxjZjnwURgcW3P/E0ZTzKRygBWUvQJ9+Qw+1zyTgGw+U jaXxW7ZpWRbUhCU4n3j2uUBzD5iYTgNRc4eCNXVJR1z/dL19Ex+lwBxONtYwv4/usFl+ Zbc7Umo29ev+AD3rmvTI1dTia4HsOhCOt9vP/iIm36hY78O047m/OITKEHFgSLOgu+EN Ntyg== 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=CUfbpUO9B1/JUdRuE4p2m2peEVpaozQnxIWitN5n/SU=; b=IhZWpx9Spi32kJkH6c9Gd4e3MZtpp0ihWK/QhUodVGOSuZuqegNGajvf9makD6HQ2C QGwXph+6oEdzmr/b2Xgn3Fjjki8UZY7UmmqRp0aoPKOayu+nUC3W17YMrxFO3Kkw3bBp xnkiiNwMOmqbPefJTQCSR0irvdcyIMxbTVu1iLZkKIrHnW2tYShjLqEOkV4YJbGxF/In KUkR8dRbJBtCfMzwvEpDL+K/jl/BfMk+gyw8PYhHSsDC1sGpP7oy6Z2bxdDlOdP/4B/P wjfywCr3GMJmmkYLKWOeR42LpxHYh4mMoc3Fv/TPxh4w01v090pLnlol134kqQR56AfB iuWw== X-Gm-Message-State: APt69E1eU6gv0dHHT51CqFHDJBtQHqfT9EzDjkYSsiO2c9SbgQgh7Jm2 qrQvb/HkSjcwOC4ehqa3jHg= X-Google-Smtp-Source: AAOMgpdS4OSF51LM6LpUQIzA0KN12DbS2Kp6QtyVQxUpzWF28rJoAsO7dJWj7FFrVMcThXuag+2E7w== X-Received: by 2002:a5e:8c15:: with SMTP id n21-v6mr22886353ioj.217.1530583235934; Mon, 02 Jul 2018 19:00:35 -0700 (PDT) From: John Arbuckle To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 2 Jul 2018 22:00:17 -0400 Message-Id: <20180703020017.1032-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:c06::22b Subject: [Qemu-devel] [PATCH v2] 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 --- v2 changes: Code changes now confined to the handleEvent: method. ui/cocoa.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 2991ed4..9be4811 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -637,6 +637,7 @@ QemuCocoaView *cocoaView; int buttons =3D 0; int keycode =3D 0; bool mouse_event =3D false; + static bool switched_to_fullscreen =3D false; NSPoint p =3D [event locationInWindow]; =20 switch ([event type]) { @@ -681,7 +682,11 @@ QemuCocoaView *cocoaView; keycode =3D=3D Q_KEY_CODE_NUM_LOCK) { [self toggleStatefulModifier:keycode]; } else if (qemu_console_is_graphic(NULL)) { - [self toggleModifier:keycode]; + if (switched_to_fullscreen) { + switched_to_fullscreen =3D false; + } else { + [self toggleModifier:keycode]; + } } } =20 @@ -691,6 +696,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 to switch to full screen mode. + */ + if (keycode =3D=3D Q_KEY_CODE_F) { + switched_to_fullscreen =3D true; + } [NSApp sendEvent:event]; return; } --=20 2.7.2