From patchwork Fri Aug 16 00:38:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 267527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 830812C019D for ; Fri, 16 Aug 2013 10:38:33 +1000 (EST) Received: from localhost ([::1]:56136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VA83j-0005A4-DO for incoming@patchwork.ozlabs.org; Thu, 15 Aug 2013 20:38:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VA83R-00059x-Ux for qemu-devel@nongnu.org; Thu, 15 Aug 2013 20:38:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VA83Q-0004tW-PY for qemu-devel@nongnu.org; Thu, 15 Aug 2013 20:38:13 -0400 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]:35759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VA83Q-0004qV-GK; Thu, 15 Aug 2013 20:38:12 -0400 Received: by mail-wi0-f174.google.com with SMTP id j17so288618wiw.7 for ; Thu, 15 Aug 2013 17:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=/lynA3hxGA0r9uykJEWGm2nqqNXT0gR64OxRgeWzVE8=; b=Tm9ZU/48I5raDZo/CGJmQ4DyhR6Wr2+5DG/NKPLOwY72G3mUftZoC26sCAk/ydNfRT 1rKlNG8L2Z3bfAJeb4q/X2LSrge5rz5iUzgDVjdjBcwAV7pbB8BWoPNG/YBThFi4wO65 ByAjqMVoEH+VT8puEPFjEcLn4B1oB/C2B4QF7Li+UOqmxuHiu1eRa2SXkGZ7nYFFfZwE ysLe3C6B5AsncK7+LXMOSIugcTQlrx16Nb1iF0XEqgefZqFgymDCAHhrXvLEiOGaNsne xR16/kjVyS00PTm6NVbaEfu/f00JmPtNz6JuYcewJz7urDsHx+TLOXRoGlRf4hkz/KDZ b6ew== MIME-Version: 1.0 X-Received: by 10.180.93.136 with SMTP id cu8mr3517001wib.1.1376613491560; Thu, 15 Aug 2013 17:38:11 -0700 (PDT) Received: by 10.194.81.100 with HTTP; Thu, 15 Aug 2013 17:38:11 -0700 (PDT) Date: Thu, 15 Aug 2013 20:38:11 -0400 Message-ID: From: G 3 To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, afaerber@suse.de X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22e Subject: [Qemu-devel] [PATCH] Adds the ability to use the command key in the guest operating system. 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 Signed-off-by: John Arbuckle Deciding when and how to send the command key has not been easy. A simple protocol that this patch implements is send the command key to the guest operating system when the mouse is grabbed. Otherwise send the command key to QEMU. --- ui/cocoa.m | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) - // handle control + alt Key Combos (ctrl+alt is reserved for QEMU) if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { switch (keycode) { diff --git a/ui/cocoa.m b/ui/cocoa.m index be49179..9a57f57 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 + 219,// 54 0x36 QZ_RMETA + 219,// 55 0x37 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 @@ -512,21 +512,24 @@ QemuCocoaView *cocoaView; } // release Mouse grab when pressing ctrl+alt - if (!isFullscreen && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { + if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) { [self ungrabMouse]; } break; case NSKeyDown: + keycode = cocoa_keycode_to_qemu([event keyCode]); - // forward command Key Combos + // if command key is down if ([event modifierFlags] & NSCommandKeyMask) { - [NSApp sendEvent:event]; - return; + if (isMouseGrabed == YES) { // if sending the command key to the guest + kbd_put_keycode(219); // send command key + kbd_put_keycode(keycode); // send any other key + } else { // if sending the command key to QEMU + [NSApp sendEvent:event]; + return; + } } - // default - keycode = cocoa_keycode_to_qemu([event keyCode]);