Deciding when and how to send the command key has not been easy. A simple protocol that this patch implements is send the command key to the guest operating system when the mouse is grabbed. Otherwise send the command key to QEMU.
---
ui/cocoa.m | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index be49179..9a57f57 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -129,8 +129,8 @@ int keymap[] =
14, // 51 0x33 0x0e BKSP QZ_BACKSPACE
0, // 52 0x34 Undefined
1, // 53 0x35 0x01 ESC QZ_ESCAPE
- 0, // 54 0x36 QZ_RMETA
- 0, // 55 0x37 QZ_LMETA
+ 219,// 54 0x36 QZ_RMETA
+ 219,// 55 0x37 QZ_LMETA
42, // 56 0x38 0x2a L SHFT QZ_LSHIFT
58, // 57 0x39 0x3a CAPS QZ_CAPSLOCK
56, // 58 0x3A 0x38 L ALT QZ_LALT
@@ -512,21 +512,24 @@ QemuCocoaView *cocoaView;
}
// release Mouse grab when pressing ctrl+alt
- if (!isFullscreen && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) {
+ if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) {
[self ungrabMouse];
}
break;
case NSKeyDown:
+ keycode = cocoa_keycode_to_qemu([event keyCode]);
- // forward command Key Combos
+ // if command key is down
if ([event modifierFlags] & NSCommandKeyMask) {
- [NSApp sendEvent:event];
- return;
+ if (isMouseGrabed == YES) { // if sending the command key to the guest
+ kbd_put_keycode(219); // send command key
+ kbd_put_keycode(keycode); // send any other key
+ } else { // if sending the command key to QEMU
+ [NSApp sendEvent:event];
+ return;
+ }
}
- // default
- keycode = cocoa_keycode_to_qemu([event keyCode]);
-
// handle control + alt Key Combos (ctrl+alt is reserved for QEMU)
if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) {
switch (keycode) {
--
1.7.5.4