Change the behaviour of -alt-grab and add X11-shortcuts
PATCH 1/1 Change the behaviour of -alt-grab and add X11-shortcuts
Hello,
this patch to sdl.c (qemu 0.9.1) changes the behavior of -alt-grab to be similar to VirtualBox.
The reason for this is to have an easy way for sending ctrl-alt-Fn and ctrl-alt-backspace to the guest. Since ctrl-alt-Fn and ctrl-alt-backspace are intercepted by X11 new shortcuts are added:
<grab_key>+<Fn>
<grab_key>+<backspace>
For this to work the alternative grab key is changed from <left_ctrl>+<left_alt>+<left_shift> to <right_ctrl>. When a ctrl-key is needed, the left ctrl-key can still be used (this also applies to combinations like ctrl-alt-delete for which the -alt-grab option was originally added).
Disclaimer: I'm not very familiar with the qemu sources and perhaps there is a nicer way for sending the keys to the guest.
sdl.c +16 -3
@@ -229,7 +229,7 @@if (!alt_grab) status =" - Press Ctrl-Alt to exit grab" ;else - status =" - Press Ctrl-Alt-Shift to exit grab" ; + status =" - Press Ctrl (right) to exit grab" ; }if (qemu_name)
@@ -367,8 +367,8 @@ mod_state = (SDL_GetModState () & gui_grab_code) == gui_grab_code; }else { - mod_state = (SDL_GetModState () & (gui_grab_code |KMOD_LSHIFT )) == - (gui_grab_code |KMOD_LSHIFT ); + mod_state = (SDL_GetModState () &KMOD_RCTRL ) == +KMOD_RCTRL ; } gui_key_modifier_pressed = mod_state;if (gui_key_modifier_pressed) {
@@ -390,6 +390,19 @@ } gui_keysym =1 ;break ; + case 0x3b ... 0x44: /* F1 .. F10 keys */ +case 0xe :/* backspace */ +/* like sendkey ctrl-alt-(fn|backspace) */ +/* key down */ +kbd_put_keycode (0x1d );/* left ctrl key */ +kbd_put_keycode (0x38 );/* left alt key */ +kbd_put_keycode (keycode); +/* key up */ +kbd_put_keycode (0x1d |0x80 ); +kbd_put_keycode (0x38 |0x80 ); +kbd_put_keycode (keycode|0x80 ); + gui_keysym =1 ; +break ;default :break ; }