Commit 3780e197e4e32f0e6341bdc9a1943d0842b48ec6

Authored by ths
1 parent 731345e1

Add alternate grab key, by Michael Mohr.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2990 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 3 changed files with 27 additions and 5 deletions
... ... @@ -223,8 +223,12 @@ static void sdl_update_caption(void)
223 223  
224 224 if (!vm_running)
225 225 status = " [Stopped]";
226   - else if (gui_grab)
227   - status = " - Press Ctrl-Alt to exit grab";
  226 + else if (gui_grab) {
  227 + if (!alt_grab)
  228 + status = " - Press Ctrl-Alt to exit grab";
  229 + else
  230 + status = " - Press Ctrl-Alt-Shift to exit grab";
  231 + }
228 232  
229 233 if (qemu_name)
230 234 snprintf(buf, sizeof(buf), "QEMU (%s)%s", qemu_name, status);
... ... @@ -357,8 +361,13 @@ static void sdl_refresh(DisplayState *ds)
357 361 case SDL_KEYDOWN:
358 362 case SDL_KEYUP:
359 363 if (ev->type == SDL_KEYDOWN) {
360   - mod_state = (SDL_GetModState() & gui_grab_code) ==
361   - gui_grab_code;
  364 + if (!alt_grab) {
  365 + mod_state = (SDL_GetModState() & gui_grab_code) ==
  366 + gui_grab_code;
  367 + } else {
  368 + mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
  369 + (gui_grab_code | KMOD_LSHIFT);
  370 + }
362 371 gui_key_modifier_pressed = mod_state;
363 372 if (gui_key_modifier_pressed) {
364 373 int keycode;
... ... @@ -419,7 +428,12 @@ static void sdl_refresh(DisplayState *ds)
419 428 }
420 429 }
421 430 } else if (ev->type == SDL_KEYUP) {
422   - mod_state = (ev->key.keysym.mod & gui_grab_code);
  431 + if (!alt_grab) {
  432 + mod_state = (ev->key.keysym.mod & gui_grab_code);
  433 + } else {
  434 + mod_state = (ev->key.keysym.mod &
  435 + (gui_grab_code | KMOD_LSHIFT));
  436 + }
423 437 if (!mod_state) {
424 438 if (gui_key_modifier_pressed) {
425 439 gui_key_modifier_pressed = 0;
... ...
... ... @@ -196,6 +196,7 @@ int nb_option_roms;
196 196 int semihosting_enabled = 0;
197 197 int autostart = 1;
198 198 const char *qemu_name;
  199 +int alt_grab = 0;
199 200 #ifdef TARGET_SPARC
200 201 unsigned int nb_prom_envs = 0;
201 202 const char *prom_envs[MAX_PROM_ENVS];
... ... @@ -6553,6 +6554,7 @@ void help(void)
6553 6554 "-snapshot write to temporary files instead of disk image files\n"
6554 6555 #ifdef CONFIG_SDL
6555 6556 "-no-frame open SDL window without a frame and window decorations\n"
  6557 + "-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n"
6556 6558 "-no-quit disable SDL window close capability\n"
6557 6559 #endif
6558 6560 #ifdef TARGET_I386
... ... @@ -6736,6 +6738,7 @@ enum {
6736 6738 QEMU_OPTION_loadvm,
6737 6739 QEMU_OPTION_full_screen,
6738 6740 QEMU_OPTION_no_frame,
  6741 + QEMU_OPTION_alt_grab,
6739 6742 QEMU_OPTION_no_quit,
6740 6743 QEMU_OPTION_pidfile,
6741 6744 QEMU_OPTION_no_kqemu,
... ... @@ -6829,6 +6832,7 @@ const QEMUOption qemu_options[] = {
6829 6832 { "full-screen", 0, QEMU_OPTION_full_screen },
6830 6833 #ifdef CONFIG_SDL
6831 6834 { "no-frame", 0, QEMU_OPTION_no_frame },
  6835 + { "alt-grab", 0, QEMU_OPTION_alt_grab },
6832 6836 { "no-quit", 0, QEMU_OPTION_no_quit },
6833 6837 #endif
6834 6838 { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
... ... @@ -7544,6 +7548,9 @@ int main(int argc, char **argv)
7544 7548 case QEMU_OPTION_no_frame:
7545 7549 no_frame = 1;
7546 7550 break;
  7551 + case QEMU_OPTION_alt_grab:
  7552 + alt_grab = 1;
  7553 + break;
7547 7554 case QEMU_OPTION_no_quit:
7548 7555 no_quit = 1;
7549 7556 break;
... ...
... ... @@ -156,6 +156,7 @@ extern int graphic_depth;
156 156 extern const char *keyboard_layout;
157 157 extern int kqemu_allowed;
158 158 extern int win2k_install_hack;
  159 +extern int alt_grab;
159 160 extern int usb_enabled;
160 161 extern int smp_cpus;
161 162 extern int cursor_hide;
... ...