cocoa queue:
* make scrolling work in GUI monitor windows * change ungrab to ctrl-alt-g (matching gtk) * pass unused ctrl-alt combos to guest -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABCAAGBQJaAYekAAoJEDwlJe0UNgzeNHAP/3TIuXoH/HNnFrVWpbKxx4Bj V9n4yUNNZhEJneipwDF6knws+OXR2EwolkapUymKgD4wCwQp6rga6gfeytp7ArOw A4MX0WGGAROFmbO4fWabOe7YbFM7rYSy+vPNPL/7hEhypYS6/FKULFoWHEG+Dbv8 XaORoDnmCheUe7hJlc+56GiQ+fYJfN5kocKMnujeo8lq86Rba9iIbZcThCDFtea3 4CtJE6/1SMpmJLQf6sIQRRBkXPGWGv1qtWis4FcRSk0sYn4OEMcM3eapDZUlJASO cBpOeoHI1L64BbyfQklBhi0v+5Nek32KZNJiY49kwSL0JKRtBMhBVKkDtnNXpaLm eA5WiwsQttYCqnyBUCWqybExGjzBjUy0TCClSMUdu1G47Wf5a1OzMtqY2CzXVgaF 0l2ZAOtIud6KACIr9D9ti+z4kTLDhddvg3NOSZA7RTo1hspUZv2Of/+97Ao1MBFk gmrC7zm94OwOQXzwPpu38XJBD8Gtxu8O3TNCD2DrWmAcS7zamRE2IP41wjHqUuCz fTihyds3ng0BtBYeRyzVQ5Hdd9UCNk8CB/SLKkz7/U1Vt1PiiuAi5kxQ97WvYHsg 8fRpmgU+wTUjIbp+Ww8tsGZkzInmSjfEGjBsm6MjwWgntEIVD1WqieEZMfk4rAZ8 7k/MR5amCS9nn3IF5uAI =RIdQ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/pmaydell/tags/pull-cocoa-20171107' into staging cocoa queue: * make scrolling work in GUI monitor windows * change ungrab to ctrl-alt-g (matching gtk) * pass unused ctrl-alt combos to guest # gpg: Signature made Tue 07 Nov 2017 10:15:00 GMT # gpg: using RSA key 0x3C2525ED14360CDE # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" # gpg: aka "Peter Maydell <pmaydell@gmail.com>" # gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" # Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83 15CF 3C25 25ED 1436 0CDE * remotes/pmaydell/tags/pull-cocoa-20171107: ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them ui/cocoa.m: move ungrab to ctrl-alt-g ui/cocoa.m: Make scrolling work again in GUI monitor windows Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
5853e92207
135
ui/cocoa.m
135
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");
|
||||
|
@ -609,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]);
|
||||
|
@ -625,54 +686,30 @@ 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) {
|
||||
NSString *keychar = [event charactersIgnoringModifiers];
|
||||
if ([keychar length] == 1) {
|
||||
char key = [keychar characterAtIndex:0];
|
||||
switch (key) {
|
||||
|
||||
// enable graphic console
|
||||
case Q_KEY_CODE_1 ... Q_KEY_CODE_9: // '1' to '9' keys
|
||||
console_select(keycode - Q_KEY_CODE_1);
|
||||
break;
|
||||
}
|
||||
// enable graphic console
|
||||
case '1' ... '9':
|
||||
console_select(key - '0' - 1); /* ascii math */
|
||||
return;
|
||||
|
||||
// handle keys for graphic console
|
||||
} else if (qemu_console_is_graphic(NULL)) {
|
||||
qemu_input_event_send_key_qcode(dcl->con, keycode, true);
|
||||
|
||||
// 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];
|
||||
// release the mouse grab
|
||||
case 'g':
|
||||
[self ungrabMouse];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (keysym)
|
||||
kbd_put_keysym(keysym);
|
||||
}
|
||||
|
||||
if (qemu_console_is_graphic(NULL)) {
|
||||
qemu_input_event_send_key_qcode(dcl->con, keycode, true);
|
||||
} else {
|
||||
[self handleMonitorInput: event];
|
||||
}
|
||||
break;
|
||||
case NSEventTypeKeyUp:
|
||||
|
@ -806,9 +843,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) {
|
||||
|
|
Loading…
Reference in a new issue