From patchwork Sun Jan 12 22:52:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 23146 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AE70D20A64 for ; Sun, 12 Jan 2014 23:11:55 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id nd7sf3534483qeb.1 for ; Sun, 12 Jan 2014 15:11:54 -0800 (PST) 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:cc: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=egdqyzWjys8H9HljY2FGQtlnXoaoGZXE4ajr8+t7jzI=; b=Bvc361KgfIEyuJ1lYPAJNkBxRPHh4reQeNCXCZbmrkBfo4G5fXPf2bQO6ewdT8smM1 nimyP7bmypBPTPLPSxR485swhZtahJP67+wlkqrR3ovho/BauCLDNyM5wmx6XjLERaRo 6JbsxidvfaKutRZ0jj/SU2+uUmp1JOCmm/tIjgsqXajkfW4C19msCSIdvXXLpEPVOXX3 T+TqegeHA1ByKiMBZ954pR0wz1Qd0/ftUHHqG1W14D/LH8gMZwj4TSkq9QoCv1iBRD8k buxz7HTRchxsAIlokvdRTQZ/Mu5bq2YZZPkFgNQgFvoEctn1t2tkfTw6r4xigBiIGG4s 5DyQ== X-Gm-Message-State: ALoCoQnhbL98sqaLDuJIP/aPe+BpTXgRWJEgThLec1J+hYmNyGh0VqueoFeiuUHEWJPZdfFBzUH7 X-Received: by 10.58.186.202 with SMTP id fm10mr1355090vec.37.1389568314865; Sun, 12 Jan 2014 15:11:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.122.101 with SMTP id lr5ls719898qeb.82.gmail; Sun, 12 Jan 2014 15:11:54 -0800 (PST) X-Received: by 10.58.243.37 with SMTP id wv5mr1844vec.41.1389568314724; Sun, 12 Jan 2014 15:11:54 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id n8si1253593vdv.133.2014.01.12.15.11.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 15:11:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id db12so805732veb.13 for ; Sun, 12 Jan 2014 15:11:54 -0800 (PST) X-Received: by 10.58.186.198 with SMTP id fm6mr16156159vec.16.1389568314642; Sun, 12 Jan 2014 15:11:54 -0800 (PST) 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.59.13.131 with SMTP id ey3csp93436ved; Sun, 12 Jan 2014 15:11:54 -0800 (PST) X-Received: by 10.49.129.131 with SMTP id nw3mr15431577qeb.21.1389568313960; Sun, 12 Jan 2014 15:11:53 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f9si20369456qar.158.2014.01.12.15.11.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 12 Jan 2014 15:11:53 -0800 (PST) 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]:39764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2TwF-0001hi-UY for patch@linaro.org; Sun, 12 Jan 2014 17:55:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Ttm-00064q-MQ for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2Ttl-00056d-EI for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:54 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:44745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Ttl-00055e-5x for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:53 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1W2TtW-00085b-Vo; Sun, 12 Jan 2014 22:52:38 +0000 From: Peter Maydell To: Anthony Liguori Date: Sun, 12 Jan 2014 22:52:30 +0000 Message-Id: <1389567158-31066-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1389567158-31066-1-git-send-email-peter.maydell@linaro.org> References: <1389567158-31066-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 Cc: Blue Swirl , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PULL 1/9] ui/cocoa: Pass command key through to guest when VM has mousegrab 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=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=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 The guest might want to be able to use the command key for its won purposes (as command if it is MacOS X, or for the Windows key if it is a PC guest, for instance). In line with other UI frontends, pass it through if the guest has mousegrab, and only use it for UI menu accelerators if not grabbed. Thanks to John Arbuckle for reporting this problem, helping us work through what the best solution would be and providing a patch which was the initial inspiration for this one. Reported-by: John Arbuckle Signed-off-by: Peter Maydell Message-id: 1386543546-31919-2-git-send-email-peter.maydell@linaro.org --- ui/cocoa.m | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 2524f18..34b58d5 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -129,8 +129,8 @@ int keymap[] = 14, // 51 0x33 0x0e BKSP QZ_BACKSPACE 0, // 52 0x34 Undefined 1, // 53 0x35 0x01 ESC QZ_ESCAPE - 0, // 54 0x36 QZ_RMETA - 0, // 55 0x37 QZ_LMETA + 220, // 54 0x36 0xdc E0,5C R GUI QZ_RMETA + 219, // 55 0x37 0xdb E0,5B L GUI QZ_LMETA 42, // 56 0x38 0x2a L SHFT QZ_LSHIFT 58, // 57 0x39 0x3a CAPS QZ_CAPSLOCK 56, // 58 0x3A 0x38 L ALT QZ_LALT @@ -206,8 +206,6 @@ int keymap[] = /* Aditional 104 Key XP-Keyboard Scancodes from http://www.computer-engineering.org/ps2keyboard/scancodes1.html */ /* - 219 // 0xdb e0,5b L GUI - 220 // 0xdc e0,5c R GUI 221 // 0xdd e0,5d APPS // E0,2A,E0,37 PRNT SCRN // E1,1D,45,E1,9D,C5 PAUSE @@ -493,6 +491,12 @@ QemuCocoaView *cocoaView; switch ([event type]) { case NSFlagsChanged: keycode = cocoa_keycode_to_qemu([event keyCode]); + + if ((keycode == 219 || keycode == 220) && !isMouseGrabed) { + /* Don't pass command key changes to guest unless mouse is grabbed */ + keycode = 0; + } + if (keycode) { if (keycode == 58 || keycode == 69) { // emulate caps lock and num lock keydown and keyup kbd_put_keycode(keycode); @@ -516,15 +520,15 @@ QemuCocoaView *cocoaView; } break; case NSKeyDown: + keycode = cocoa_keycode_to_qemu([event keyCode]); - // forward command Key Combos - if ([event modifierFlags] & NSCommandKeyMask) { + // forward command key combos to the host UI unless the mouse is grabbed + if (!isMouseGrabed && ([event modifierFlags] & NSCommandKeyMask)) { [NSApp sendEvent:event]; return; } // default - keycode = cocoa_keycode_to_qemu([event keyCode]); // handle control + alt Key Combos (ctrl+alt is reserved for QEMU) if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { @@ -580,6 +584,13 @@ QemuCocoaView *cocoaView; break; case NSKeyUp: keycode = cocoa_keycode_to_qemu([event keyCode]); + + // don't pass the guest a spurious key-up if we treated this + // command-key combo as a host UI action + if (!isMouseGrabed && ([event modifierFlags] & NSCommandKeyMask)) { + return; + } + if (qemu_console_is_graphic(NULL)) { if (keycode & 0x80) kbd_put_keycode(0xe0);