Send control-alt key combinations to the guest if not used by the user interface.
Signed-off-by: John Arbuckle <programmingk...@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)