* [Qemu-devel] [PULL 0/3] cocoa queue
@ 2017-11-07 10:15 Peter Maydell
2017-11-07 10:16 ` [Qemu-devel] [PULL 1/3] ui/cocoa.m: Make scrolling work again in GUI monitor windows Peter Maydell
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Peter Maydell @ 2017-11-07 10:15 UTC (permalink / raw)
To: qemu-devel; +Cc: programmingkidx
Cocoa patches for rc0.
The following changes since commit 299d1ea9bb56bd9f45f905125489bdd7d543a1aa:
Merge remote-tracking branch 'remotes/yongbok/tags/mips-20171106' into staging (2017-11-06 16:13:10 +0000)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-cocoa-20171107
for you to fetch changes up to ef2088f9af16d3a19f5f094da160dd8ba52231a9:
ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them (2017-11-07 10:14:14 +0000)
----------------------------------------------------------------
cocoa queue:
* make scrolling work in GUI monitor windows
* change ungrab to ctrl-alt-g (matching gtk)
* pass unused ctrl-alt combos to guest
----------------------------------------------------------------
John Arbuckle (2):
ui/cocoa.m: Make scrolling work again in GUI monitor windows
ui/cocoa.m: move ungrab to ctrl-alt-g
Peter Maydell (1):
ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them
ui/cocoa.m | 135 +++++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 86 insertions(+), 49 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PULL 1/3] ui/cocoa.m: Make scrolling work again in GUI monitor windows
2017-11-07 10:15 [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
@ 2017-11-07 10:16 ` Peter Maydell
2017-11-07 10:16 ` [Qemu-devel] [PULL 2/3] ui/cocoa.m: move ungrab to ctrl-alt-g Peter Maydell
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2017-11-07 10:16 UTC (permalink / raw)
To: qemu-devel; +Cc: programmingkidx
From: John Arbuckle <programmingkidx@gmail.com>
Make scrolling in the monitor work, by correctly passing through
control+key combinations.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Message-id: 20171101154607.1582-1-programmingkidx@gmail.com
[PMM: fixed coding style nits; cleaned up commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
ui/cocoa.m | 98 ++++++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 66 insertions(+), 32 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2794f60..2f76dac 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -281,6 +281,7 @@ static void handleAnyDeviceErrors(Error * err)
- (void) grabMouse;
- (void) ungrabMouse;
- (void) toggleFullScreen:(id)sender;
+- (void) handleMonitorInput:(NSEvent *)event;
- (void) handleEvent:(NSEvent *)event;
- (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled;
/* The state surrounding mouse grabbing is potentially confusing.
@@ -554,6 +555,70 @@ QemuCocoaView *cocoaView;
qemu_input_event_send_key_qcode(dcl->con, keycode, false);
}
+// Does the work of sending input to the monitor
+- (void) handleMonitorInput:(NSEvent *)event
+{
+ int keysym = 0;
+ int control_key = 0;
+
+ // if the control key is down
+ if ([event modifierFlags] & NSEventModifierFlagControl) {
+ control_key = 1;
+ }
+
+ /* translates Macintosh keycodes to QEMU's keysym */
+
+ int without_control_translation[] = {
+ [0 ... 0xff] = 0, // invalid key
+
+ [kVK_UpArrow] = QEMU_KEY_UP,
+ [kVK_DownArrow] = QEMU_KEY_DOWN,
+ [kVK_RightArrow] = QEMU_KEY_RIGHT,
+ [kVK_LeftArrow] = QEMU_KEY_LEFT,
+ [kVK_Home] = QEMU_KEY_HOME,
+ [kVK_End] = QEMU_KEY_END,
+ [kVK_PageUp] = QEMU_KEY_PAGEUP,
+ [kVK_PageDown] = QEMU_KEY_PAGEDOWN,
+ [kVK_ForwardDelete] = QEMU_KEY_DELETE,
+ [kVK_Delete] = QEMU_KEY_BACKSPACE,
+ };
+
+ int with_control_translation[] = {
+ [0 ... 0xff] = 0, // invalid key
+
+ [kVK_UpArrow] = QEMU_KEY_CTRL_UP,
+ [kVK_DownArrow] = QEMU_KEY_CTRL_DOWN,
+ [kVK_RightArrow] = QEMU_KEY_CTRL_RIGHT,
+ [kVK_LeftArrow] = QEMU_KEY_CTRL_LEFT,
+ [kVK_Home] = QEMU_KEY_CTRL_HOME,
+ [kVK_End] = QEMU_KEY_CTRL_END,
+ [kVK_PageUp] = QEMU_KEY_CTRL_PAGEUP,
+ [kVK_PageDown] = QEMU_KEY_CTRL_PAGEDOWN,
+ };
+
+ if (control_key != 0) { /* If the control key is being used */
+ if ([event keyCode] < ARRAY_SIZE(with_control_translation)) {
+ keysym = with_control_translation[[event keyCode]];
+ }
+ } else {
+ if ([event keyCode] < ARRAY_SIZE(without_control_translation)) {
+ keysym = without_control_translation[[event keyCode]];
+ }
+ }
+
+ // if not a key that needs translating
+ if (keysym == 0) {
+ NSString *ks = [event characters];
+ if ([ks length] > 0) {
+ keysym = [ks characterAtIndex:0];
+ }
+ }
+
+ if (keysym) {
+ kbd_put_keysym(keysym);
+ }
+}
+
- (void) handleEvent:(NSEvent *)event
{
COCOA_DEBUG("QemuCocoaView: handleEvent\n");
@@ -641,38 +706,7 @@ QemuCocoaView *cocoaView;
// handlekeys for Monitor
} else {
- int keysym = 0;
- switch([event keyCode]) {
- case 115:
- keysym = QEMU_KEY_HOME;
- break;
- case 117:
- keysym = QEMU_KEY_DELETE;
- break;
- case 119:
- keysym = QEMU_KEY_END;
- break;
- case 123:
- keysym = QEMU_KEY_LEFT;
- break;
- case 124:
- keysym = QEMU_KEY_RIGHT;
- break;
- case 125:
- keysym = QEMU_KEY_DOWN;
- break;
- case 126:
- keysym = QEMU_KEY_UP;
- break;
- default:
- {
- NSString *ks = [event characters];
- if ([ks length] > 0)
- keysym = [ks characterAtIndex:0];
- }
- }
- if (keysym)
- kbd_put_keysym(keysym);
+ [self handleMonitorInput: event];
}
break;
case NSEventTypeKeyUp:
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PULL 2/3] ui/cocoa.m: move ungrab to ctrl-alt-g
2017-11-07 10:15 [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
2017-11-07 10:16 ` [Qemu-devel] [PULL 1/3] ui/cocoa.m: Make scrolling work again in GUI monitor windows Peter Maydell
@ 2017-11-07 10:16 ` Peter Maydell
2017-11-08 12:04 ` Programmingkid
2017-11-07 10:16 ` [Qemu-devel] [PULL 3/3] ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them Peter Maydell
2017-11-07 12:53 ` [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
3 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2017-11-07 10:16 UTC (permalink / raw)
To: qemu-devel; +Cc: programmingkidx
From: John Arbuckle <programmingkidx@gmail.com>
Currently the cocoa user interface relis on the user pushing
control-alt to ungrab the mouse. This is patch changes the key
combination to control-alt-g to be in line with the GTK user
interface.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Message-id: 20171102213907.11443-1-programmingkidx@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
ui/cocoa.m | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2f76dac..f39c792 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -674,10 +674,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]);
@@ -690,14 +686,23 @@ 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) {
-
- // enable graphic console
- case Q_KEY_CODE_1 ... Q_KEY_CODE_9: // '1' to '9' keys
- console_select(keycode - Q_KEY_CODE_1);
- break;
+ 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;
+ }
}
// handle keys for graphic console
@@ -840,9 +845,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) {
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PULL 3/3] ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them
2017-11-07 10:15 [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
2017-11-07 10:16 ` [Qemu-devel] [PULL 1/3] ui/cocoa.m: Make scrolling work again in GUI monitor windows Peter Maydell
2017-11-07 10:16 ` [Qemu-devel] [PULL 2/3] ui/cocoa.m: move ungrab to ctrl-alt-g Peter Maydell
@ 2017-11-07 10:16 ` Peter Maydell
2017-11-07 12:53 ` [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
3 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2017-11-07 10:16 UTC (permalink / raw)
To: qemu-devel; +Cc: programmingkidx
Send those ctrl-alt key combos that QEMU doesn't treat specially to
the guest rather than ignoring them.
All the case where we do special handling of ctrl-alt-X exit the
event handling using a "return" statement, so we can simply allow
the rest to fall through into the normal key handling by deleting
the now-spurious "else".
We take the opportunity to clean up some oddly-formatted and
now rather uninformative comments by removing them.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
ui/cocoa.m | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index f39c792..330cceb 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -704,12 +704,10 @@ QemuCocoaView *cocoaView;
return;
}
}
+ }
- // handle keys for graphic console
- } else if (qemu_console_is_graphic(NULL)) {
+ if (qemu_console_is_graphic(NULL)) {
qemu_input_event_send_key_qcode(dcl->con, keycode, true);
-
- // handlekeys for Monitor
} else {
[self handleMonitorInput: event];
}
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PULL 0/3] cocoa queue
2017-11-07 10:15 [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
` (2 preceding siblings ...)
2017-11-07 10:16 ` [Qemu-devel] [PULL 3/3] ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them Peter Maydell
@ 2017-11-07 12:53 ` Peter Maydell
3 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2017-11-07 12:53 UTC (permalink / raw)
To: QEMU Developers; +Cc: G 3
On 7 November 2017 at 10:15, Peter Maydell <peter.maydell@linaro.org> wrote:
> Cocoa patches for rc0.
>
> The following changes since commit 299d1ea9bb56bd9f45f905125489bdd7d543a1aa:
>
> Merge remote-tracking branch 'remotes/yongbok/tags/mips-20171106' into staging (2017-11-06 16:13:10 +0000)
>
> are available in the git repository at:
>
> git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-cocoa-20171107
>
> for you to fetch changes up to ef2088f9af16d3a19f5f094da160dd8ba52231a9:
>
> ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them (2017-11-07 10:14:14 +0000)
>
> ----------------------------------------------------------------
> cocoa queue:
> * make scrolling work in GUI monitor windows
> * change ungrab to ctrl-alt-g (matching gtk)
> * pass unused ctrl-alt combos to guest
>
> ----------------------------------------------------------------
> John Arbuckle (2):
> ui/cocoa.m: Make scrolling work again in GUI monitor windows
> ui/cocoa.m: move ungrab to ctrl-alt-g
>
> Peter Maydell (1):
> ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them
>
> ui/cocoa.m | 135 +++++++++++++++++++++++++++++++++++++++----------------------
> 1 file changed, 86 insertions(+), 49 deletions(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PULL 2/3] ui/cocoa.m: move ungrab to ctrl-alt-g
2017-11-07 10:16 ` [Qemu-devel] [PULL 2/3] ui/cocoa.m: move ungrab to ctrl-alt-g Peter Maydell
@ 2017-11-08 12:04 ` Programmingkid
2017-11-08 14:27 ` Eric Blake
0 siblings, 1 reply; 7+ messages in thread
From: Programmingkid @ 2017-11-08 12:04 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
> On Nov 7, 2017, at 5:16 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> From: John Arbuckle <programmingkidx@gmail.com>
>
> Currently the cocoa user interface relis on the user pushing
I would change "relis" to "relies" here.
> control-alt to ungrab the mouse. This is patch changes the key
> combination to control-alt-g to be in line with the GTK user
> interface.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> Message-id: 20171102213907.11443-1-programmingkidx@gmail.com
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> ui/cocoa.m | 31 ++++++++++++++++++-------------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 2f76dac..f39c792 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -674,10 +674,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]);
> @@ -690,14 +686,23 @@ 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) {
> -
> - // enable graphic console
> - case Q_KEY_CODE_1 ... Q_KEY_CODE_9: // '1' to '9' keys
> - console_select(keycode - Q_KEY_CODE_1);
> - break;
> + 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;
> + }
> }
>
> // handle keys for graphic console
> @@ -840,9 +845,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) {
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PULL 2/3] ui/cocoa.m: move ungrab to ctrl-alt-g
2017-11-08 12:04 ` Programmingkid
@ 2017-11-08 14:27 ` Eric Blake
0 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2017-11-08 14:27 UTC (permalink / raw)
To: Programmingkid, Peter Maydell; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
On 11/08/2017 06:04 AM, Programmingkid wrote:
>
>> On Nov 7, 2017, at 5:16 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> From: John Arbuckle <programmingkidx@gmail.com>
>>
>> Currently the cocoa user interface relis on the user pushing
>
> I would change "relis" to "relies" here.
Too late; it's already commit 5929e36c
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-11-08 14:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-07 10:15 [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
2017-11-07 10:16 ` [Qemu-devel] [PULL 1/3] ui/cocoa.m: Make scrolling work again in GUI monitor windows Peter Maydell
2017-11-07 10:16 ` [Qemu-devel] [PULL 2/3] ui/cocoa.m: move ungrab to ctrl-alt-g Peter Maydell
2017-11-08 12:04 ` Programmingkid
2017-11-08 14:27 ` Eric Blake
2017-11-07 10:16 ` [Qemu-devel] [PULL 3/3] ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them Peter Maydell
2017-11-07 12:53 ` [Qemu-devel] [PULL 0/3] cocoa queue Peter Maydell
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).