From patchwork Thu Jul 20 14:36:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 9855101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 58659600F5 for ; Thu, 20 Jul 2017 14:37:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4752D28727 for ; Thu, 20 Jul 2017 14:37:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A9E5287B2; Thu, 20 Jul 2017 14:37:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0A6628727 for ; Thu, 20 Jul 2017 14:37:37 +0000 (UTC) Received: from localhost ([::1]:38354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYCa8-00012s-AW for patchwork-qemu-devel@patchwork.kernel.org; Thu, 20 Jul 2017 10:37:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYCZ8-00012b-IQ for qemu-devel@nongnu.org; Thu, 20 Jul 2017 10:36:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYCZ4-0006oI-JP for qemu-devel@nongnu.org; Thu, 20 Jul 2017 10:36:34 -0400 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]:36743) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYCZ4-0006nz-FE for qemu-devel@nongnu.org; Thu, 20 Jul 2017 10:36:30 -0400 Received: by mail-io0-x241.google.com with SMTP id z74so563953ioz.3 for ; Thu, 20 Jul 2017 07:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :cc:to; bh=zYG5NQeSxUkEfUy/yMv8FpwZsnvn1KteG9dxP1JzSm0=; b=dzkk0G7rK+//i3fHE5rIBVFfWQT/+JL4y8TgKLvPkyMNvPa19WwVgL23+wVS9vAHBf +6A/bNsiGoe0hQPw+VmHs1/FZ8fqLct6w51BLOMBPCRfd/KJrB5QgvtQwJMoTf60zu7b MHi+P+so07sRpgcxIdUtSWkPX5cCbYs+ZbtRk3grsiq1cWpjdwzuAO7SzKT2GARuR7EM laeksPNEJ10wg7r9KGZSksgiHyAk3eR0rUXwzXOoBVst+Xkg7gB48hsPHyqyvyilM3ky fZlAA8ry4w8pxpbNwuoc2Mass6P27Axg9+rX7YxHyT/lNSXjnc7ikO5S4X6dZNjXoz5L mL9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:cc:to; bh=zYG5NQeSxUkEfUy/yMv8FpwZsnvn1KteG9dxP1JzSm0=; b=QTF0icIK/MQwCCwnbliaXxVAA7auJtpF6rsdSmShZ61ZuXHVtfWiFhfPBGnrQ9PGQI cI9C/Ck0aRZwRwBK+NolT/MnuY5njj2Jfj2E1fLFri7V1oOvdCDBCE1EiDLxR9CNlssw jXr1TpPXDibjAUJWFS+l5wW4XQsEVApF4E3vWGFEplFWS1U03tjMa3t/78Kf3K6JE4bH im768tohTLjPBGqK6elZaYyqyQLrVwDK6LiyF9vizuedSffBaRKFC440mH4RxX2wVrux mmqvwDF2S+vwqq8l52+qyrIwyRvHtnUXfokyoEBZx66ZmRThCIg2Jo5JR96GBUrTRD9a TqWA== X-Gm-Message-State: AIVw112XbIureVMPmWxYFnhrH6NHPeI9eHE8AGwRoakyCcgK22ehaaYk YCZgARNy3Is8eg== X-Received: by 10.107.183.206 with SMTP id h197mr3742403iof.125.1500561387056; Thu, 20 Jul 2017 07:36:27 -0700 (PDT) Received: from [192.168.0.10] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id p69sm1241437iod.4.2017.07.20.07.36.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jul 2017 07:36:26 -0700 (PDT) From: Programmingkid Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Message-Id: <7843ECF8-2CA7-485F-B3D2-38A55D13D80D@gmail.com> Date: Thu, 20 Jul 2017 10:36:25 -0400 To: Peter Maydell , Gerd Hoffmann X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::241 Subject: [Qemu-devel] [PATCH] ui/cocoa.m: change mouse grab to control-alt-g 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: "qemu-devel@nongnu.org qemu-devel" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The GTK interface uses Control-Alt-G to ungrab the mouse. This patch changes the ungrab keys in the Cocoa interface to be consistent with the GTK interface. This patch has the added benefit of being able to send Control-Alt key combinations to the guest (like Control-Alt-Delete used in Windows). Signed-off-by: John Arbuckle --- ui/cocoa.m | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 93e56d0..d64c7b9 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -609,10 +609,6 @@ QemuCocoaView *cocoaView; } } - // release Mouse grab when pressing ctrl+alt - if (([event modifierFlags] & NSEventModifierFlagControl) && ([event modifierFlags] & NSEventModifierFlagOption)) { - [self ungrabMouse]; - } break; case NSEventTypeKeyDown: keycode = cocoa_keycode_to_qemu([event keyCode]); @@ -625,7 +621,7 @@ QemuCocoaView *cocoaView; // default - // handle control + alt Key Combos (ctrl+alt is reserved for QEMU) + // handle control + alt Key Combos (ctrl+alt+[1..9,g] is reserved for QEMU) if (([event modifierFlags] & NSEventModifierFlagControl) && ([event modifierFlags] & NSEventModifierFlagOption)) { switch (keycode) { @@ -633,6 +629,18 @@ QemuCocoaView *cocoaView; case Q_KEY_CODE_1 ... Q_KEY_CODE_9: // '1' to '9' keys console_select(keycode - 11); break; + + // release the mouse grab + case Q_KEY_CODE_G: + [self ungrabMouse]; + break; + + // send to the guest + default: + qemu_input_event_send_key_qcode(dcl->con, Q_KEY_CODE_CTRL, true); + qemu_input_event_send_key_qcode(dcl->con, Q_KEY_CODE_ALT, true); + qemu_input_event_send_key_qcode(dcl->con, keycode, true); + break; } // handle keys for graphic console @@ -806,9 +814,9 @@ QemuCocoaView *cocoaView; if (!isFullscreen) { if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt to release Mouse)", qemu_name]]; + [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]]; else - [normalWindow setTitle:@"QEMU - (Press ctrl + alt to release Mouse)"]; + [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"]; } [self hideCursor]; if (!isAbsoluteEnabled) {