Commit 7c206a754afa8657bc5b4562b45aacd5cdab4817
1 parent
2efc3265
(Joachim Henke)
- suppress unwanted kernel logs - avoids passing modifier keys to the guest OS when typing in the Monitor - fixes the bug that the mouse cursor grab is released with _any_ modifier key (should be only ctrl+alt) - removes some code redundancies git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1721 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
23 additions
and
20 deletions
cocoa.m
| @@ -375,36 +375,39 @@ static void cocoa_refresh(DisplayState *ds) | @@ -375,36 +375,39 @@ static void cocoa_refresh(DisplayState *ds) | ||
| 375 | case NSFlagsChanged: | 375 | case NSFlagsChanged: |
| 376 | { | 376 | { |
| 377 | int keycode = cocoa_keycode_to_qemu([event keyCode]); | 377 | int keycode = cocoa_keycode_to_qemu([event keyCode]); |
| 378 | - modifiers_state[keycode] = (modifiers_state[keycode] == 0) ? 1 : 0; | ||
| 379 | - | ||
| 380 | - if ( modifiers_state[keycode] ) { /* Keydown */ | ||
| 381 | - if (keycode & 0x80) | ||
| 382 | - kbd_put_keycode(0xe0); | ||
| 383 | - kbd_put_keycode(keycode & 0x7f); | ||
| 384 | - } else { /* Keyup */ | ||
| 385 | - if (keycode & 0x80) | ||
| 386 | - kbd_put_keycode(0xe0); | ||
| 387 | - kbd_put_keycode(keycode | 0x80); | ||
| 388 | - } | ||
| 389 | - | ||
| 390 | - /* emulate caps lock and num lock keyup */ | ||
| 391 | - if ((keycode == 58) || (keycode == 69)) | 378 | + |
| 379 | + if (keycode) | ||
| 392 | { | 380 | { |
| 393 | - modifiers_state[keycode] = 0; | ||
| 394 | - if (keycode & 0x80) | ||
| 395 | - kbd_put_keycode(0xe0); | ||
| 396 | - kbd_put_keycode(keycode | 0x80); | 381 | + if (keycode == 58 || keycode == 69) { |
| 382 | + /* emulate caps lock and num lock keydown and keyup */ | ||
| 383 | + kbd_put_keycode(keycode); | ||
| 384 | + kbd_put_keycode(keycode | 0x80); | ||
| 385 | + } else if (is_active_console(vga_console)) { | ||
| 386 | + if (keycode & 0x80) | ||
| 387 | + kbd_put_keycode(0xe0); | ||
| 388 | + if (modifiers_state[keycode] == 0) { | ||
| 389 | + /* keydown */ | ||
| 390 | + kbd_put_keycode(keycode & 0x7f); | ||
| 391 | + modifiers_state[keycode] = 1; | ||
| 392 | + } else { | ||
| 393 | + /* keyup */ | ||
| 394 | + kbd_put_keycode(keycode | 0x80); | ||
| 395 | + modifiers_state[keycode] = 0; | ||
| 396 | + } | ||
| 397 | + } | ||
| 397 | } | 398 | } |
| 398 | - | 399 | + |
| 399 | /* release Mouse grab when pressing ctrl+alt */ | 400 | /* release Mouse grab when pressing ctrl+alt */ |
| 400 | if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) | 401 | if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) |
| 402 | + { | ||
| 401 | [window setTitle: @"QEMU"]; | 403 | [window setTitle: @"QEMU"]; |
| 402 | [NSCursor unhide]; | 404 | [NSCursor unhide]; |
| 403 | CGAssociateMouseAndMouseCursorPosition ( TRUE ); | 405 | CGAssociateMouseAndMouseCursorPosition ( TRUE ); |
| 404 | grab = 0; | 406 | grab = 0; |
| 407 | + } | ||
| 405 | } | 408 | } |
| 406 | break; | 409 | break; |
| 407 | - | 410 | + |
| 408 | case NSKeyDown: | 411 | case NSKeyDown: |
| 409 | { | 412 | { |
| 410 | int keycode = cocoa_keycode_to_qemu([event keyCode]); | 413 | int keycode = cocoa_keycode_to_qemu([event keyCode]); |