qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Arbuckle <programmingkidx@gmail.com>
To: peter.maydell@linaro.org, qemu-devel@nongnu.org
Cc: John Arbuckle <programmingkidx@gmail.com>
Subject: [Qemu-devel] [PATCH v2 2/2] ui/cocoa.m: send ctrl-alt key combinations to guest if not used by QEMU
Date: Thu,  5 Oct 2017 10:55:57 -0400	[thread overview]
Message-ID: <20171005145557.5746-3-programmingkidx@gmail.com> (raw)
In-Reply-To: <20171005145557.5746-1-programmingkidx@gmail.com>

Send control-alt key combinations to the guest if not used by the user interface.

---
v2 changes:
- changed logic to use existing if case

 ui/cocoa.m | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index d3e7907103..828d507d57 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -619,25 +619,22 @@ - (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)) {
-                switch (keycode) {
-
-                    // enable graphic console
-                    case Q_KEY_CODE_1 ... Q_KEY_CODE_9: // '1' to '9' keys
-                        console_select(keycode - 11);
-                        break;
+            // console selection
+            if (([event modifierFlags] & NSEventModifierFlagControl) &&
+                ([event modifierFlags] & NSEventModifierFlagOption) &&
+                (keycode >= Q_KEY_CODE_1 && keycode <= Q_KEY_CODE_9)) {
+                console_select(keycode - 11);
+            }
 
-                    // release the mouse grab
-                    case Q_KEY_CODE_G:
-                        [self ungrabMouse];
-                        break;
-                }
+            // mouse ungrab
+            else if (([event modifierFlags] & NSEventModifierFlagControl) &&
+                     ([event modifierFlags] & NSEventModifierFlagOption) &&
+                     (keycode == Q_KEY_CODE_G)) {
+                [self ungrabMouse];
+            }
 
-            // 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
-- 
2.13.5 (Apple Git-94)

  parent reply	other threads:[~2017-10-05 14:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-05 14:55 [Qemu-devel] [PATCH v2 0/2] ui/cocoa.m: enable guest to see control-alt key combinations John Arbuckle
2017-10-05 14:55 ` [Qemu-devel] [PATCH v2 1/2] ui/cocoa.m: move ungrab to ctrl-alt-g John Arbuckle
2017-11-02  9:10   ` Peter Maydell
2017-11-02 15:20     ` Programmingkid
2017-11-02 16:06       ` BALATON Zoltan
2017-11-02 21:42         ` Programmingkid
2017-11-02 16:09       ` Peter Maydell
2017-10-05 14:55 ` John Arbuckle [this message]
2017-10-31 14:38   ` [Qemu-devel] [PATCH v2 2/2] ui/cocoa.m: send ctrl-alt key combinations to guest if not used by QEMU Peter Maydell
2017-10-31 14:52     ` Peter Maydell
2017-11-01 15:11       ` Programmingkid
2017-10-05 16:39 ` [Qemu-devel] [PATCH v2 0/2] ui/cocoa.m: enable guest to see control-alt key combinations no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171005145557.5746-3-programmingkidx@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).