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 v3 2/2] ui/cocoa.m: send ctrl-alt key combinations to guest if not used by QEMU
Date: Thu, 2 Nov 2017 17:39:07 -0400 [thread overview]
Message-ID: <20171102213907.11443-2-programmingkidx@gmail.com> (raw)
In-Reply-To: <20171102213907.11443-1-programmingkidx@gmail.com>
Send control-alt key combinations to the guest if not used by the user interface.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
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
--
2.13.5 (Apple Git-94)
next prev parent reply other threads:[~2017-11-02 21:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-02 21:39 [Qemu-devel] [PATCH v3 1/2] ui/cocoa.m: move ungrab to ctrl-alt-g John Arbuckle
2017-11-02 21:39 ` John Arbuckle [this message]
2017-11-07 10:13 ` [Qemu-devel] [PATCH v3 2/2] ui/cocoa.m: send ctrl-alt key combinations to guest if not used by QEMU Peter Maydell
2017-11-07 10:10 ` [Qemu-devel] [PATCH v3 1/2] ui/cocoa.m: move ungrab to ctrl-alt-g Peter Maydell
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=20171102213907.11443-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.