From patchwork Thu Nov 2 21:39:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 10039333 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 AEA2660291 for ; Thu, 2 Nov 2017 21:40:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D7D328CE5 for ; Thu, 2 Nov 2017 21:40:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EF1E29224; Thu, 2 Nov 2017 21:40:18 +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 1D2A928CE5 for ; Thu, 2 Nov 2017 21:40:18 +0000 (UTC) Received: from localhost ([::1]:33982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eANDl-0002qQ-Ce for patchwork-qemu-devel@patchwork.kernel.org; Thu, 02 Nov 2017 17:40:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eANCq-0002pZ-BW for qemu-devel@nongnu.org; Thu, 02 Nov 2017 17:39:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eANCo-0008Vy-0L for qemu-devel@nongnu.org; Thu, 02 Nov 2017 17:39:20 -0400 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]:53239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eANCn-0008Vq-S0 for qemu-devel@nongnu.org; Thu, 02 Nov 2017 17:39:17 -0400 Received: by mail-io0-x241.google.com with SMTP id f20so2124721ioj.9 for ; Thu, 02 Nov 2017 14:39:17 -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:in-reply-to:references; bh=CxyRobSKEngF62h5NPE41t5rKR33ghXqdGKUL+In25k=; b=S2qdkO40XNqQNZRoEhyjY/HO6yD8glDcrjTIo3e8/vWC8HoeCCv9+EA9d5gUOMpMyd wI4Y5A5AQarTj4khqFDSm/ocytmwQP7O7V4m1ZbEPjkkUm/8oqvzFwOFOVq+SAPRk3CI mWL0Oh0/OmKl4C/IjD/NPXQC5iFRJ+RIaWTlqtnykMisxgHYZmO80XdwNlYKVvnbPxBJ o5XHs7Wzg/V5+cfZ6Zm8jZ5gUHFPfWHuAsPaZii6I5ubUbO1l8s4S/qwjCdgxQY83ZGd JgVRbAhj+OSimzOmo3xL3hfdOb1OmY65zsTo0350oUvJEvGOjzoonFMs3D/InSewAjhF K41A== 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:in-reply-to :references; bh=CxyRobSKEngF62h5NPE41t5rKR33ghXqdGKUL+In25k=; b=Sv8xtwNnlD7x0dL/eRWuCmmulYrSZjwupeXiBlPkAA6b4/68he/XHVozDfxRY0HHxM mQcvvHipiw6wZaSA23hHOQg1q3gFN6O0a1V1LsPHE+N3+5fogJhfkc5SZcND6nIBIL6X xBU21L/81QsaXEihWEejjDQAOIIxX+Uwzqwc9Iw8254u/su6YAEa9JirkfF6lCxMz8k8 XEpkFoFOWWh3c2ejpC9EivUKbLj7twPq1zBowp7XcJkNItlABwqX9WUsMUnQoKqDxCzE Qlv3Qe8U9yb5W5uPdZb75Z0HTAdDPAyyBTfRMMCJJcEqgu4S7NYXvoIor3lHINJOr8MF /pSw== X-Gm-Message-State: AMCzsaXu+kyUY9nxUbI8rqzCwpl7dOIaq9+nJDeU57JjXcdo5APSNbdj sNd5TdwOGMy0fq14kT5gZak= X-Google-Smtp-Source: ABhQp+TG0F9nVfMjGkje+eUHjAlL6ZbsxT6DmzL/ENSwoqW4Nbdz3DvxgBrFgx4p1EmJMz7pz48BQw== X-Received: by 10.107.164.105 with SMTP id n102mr6481837ioe.45.1509658757252; Thu, 02 Nov 2017 14:39:17 -0700 (PDT) Received: from localhost.localdomain (d14-69-20-184.try.wideopenwest.com. [69.14.184.20]) by smtp.gmail.com with ESMTPSA id i62sm1933083ioe.31.2017.11.02.14.39.16 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 02 Nov 2017 14:39:16 -0700 (PDT) From: John Arbuckle To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Thu, 2 Nov 2017 17:39:07 -0400 Message-Id: <20171102213907.11443-2-programmingkidx@gmail.com> X-Mailer: git-send-email 2.13.5 (Apple Git-94) In-Reply-To: <20171102213907.11443-1-programmingkidx@gmail.com> References: <20171102213907.11443-1-programmingkidx@gmail.com> 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 v3 2/2] ui/cocoa.m: send ctrl-alt key combinations to guest if not used by QEMU 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Send control-alt key combinations to the guest if not used by the user interface. Signed-off-by: John Arbuckle --- v3 changes: - Code is now keyboard layout aware v2 changes: - changed logic to use existing if case ui/cocoa.m | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index e06aa9c65f..030479f4cd 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -619,29 +619,28 @@ - (void) handleEvent:(NSEvent *)event return; } - // default - - // handle control + alt Key Combos (ctrl+alt+[1..9,g] is reserved for QEMU) - if (([event modifierFlags] & NSEventModifierFlagControl) && ([event modifierFlags] & NSEventModifierFlagOption)) { + // console selection + if (([event modifierFlags] & NSEventModifierFlagControl) && + ([event modifierFlags] & NSEventModifierFlagOption) && + ([[event charactersIgnoringModifiers] length] == 1) && + (isdigit([[event charactersIgnoringModifiers] characterAtIndex: 0]))) { NSString *keychar = [event charactersIgnoringModifiers]; - if ([keychar length] == 1) { - char key = [keychar characterAtIndex:0]; - switch (key) { - - // enable graphic console - case '1' ... '9': - console_select(key - '0' - 1); /* ascii math */ - return; - - // release the mouse grab - case 'g': - [self ungrabMouse]; - return; - } - } + char key = [keychar characterAtIndex:0]; + console_select(key - '0' - 1); /* ascii math */ + return; + } + + // mouse ungrab + else if (([event modifierFlags] & NSEventModifierFlagControl) && + ([event modifierFlags] & NSEventModifierFlagOption) && + ([[event charactersIgnoringModifiers] length] == 1) && + ([[event charactersIgnoringModifiers] characterAtIndex: 0] == 'g')) { + [self ungrabMouse]; + return; + } - // handle keys for graphic console - } else if (qemu_console_is_graphic(NULL)) { + // send to guest + else if (qemu_console_is_graphic(NULL)) { qemu_input_event_send_key_qcode(dcl->con, keycode, true); // handlekeys for Monitor