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,8 +223,12 @@ static void sdl_update_caption(void)
223 223
224 if (!vm_running) 224 if (!vm_running)
225 status = " [Stopped]"; 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 if (qemu_name) 233 if (qemu_name)
230 snprintf(buf, sizeof(buf), "QEMU (%s)%s", qemu_name, status); 234 snprintf(buf, sizeof(buf), "QEMU (%s)%s", qemu_name, status);
@@ -357,8 +361,13 @@ static void sdl_refresh(DisplayState *ds) @@ -357,8 +361,13 @@ static void sdl_refresh(DisplayState *ds)
357 case SDL_KEYDOWN: 361 case SDL_KEYDOWN:
358 case SDL_KEYUP: 362 case SDL_KEYUP:
359 if (ev->type == SDL_KEYDOWN) { 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 gui_key_modifier_pressed = mod_state; 371 gui_key_modifier_pressed = mod_state;
363 if (gui_key_modifier_pressed) { 372 if (gui_key_modifier_pressed) {
364 int keycode; 373 int keycode;
@@ -419,7 +428,12 @@ static void sdl_refresh(DisplayState *ds) @@ -419,7 +428,12 @@ static void sdl_refresh(DisplayState *ds)
419 } 428 }
420 } 429 }
421 } else if (ev->type == SDL_KEYUP) { 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 if (!mod_state) { 437 if (!mod_state) {
424 if (gui_key_modifier_pressed) { 438 if (gui_key_modifier_pressed) {
425 gui_key_modifier_pressed = 0; 439 gui_key_modifier_pressed = 0;
@@ -196,6 +196,7 @@ int nb_option_roms; @@ -196,6 +196,7 @@ int nb_option_roms;
196 int semihosting_enabled = 0; 196 int semihosting_enabled = 0;
197 int autostart = 1; 197 int autostart = 1;
198 const char *qemu_name; 198 const char *qemu_name;
  199 +int alt_grab = 0;
199 #ifdef TARGET_SPARC 200 #ifdef TARGET_SPARC
200 unsigned int nb_prom_envs = 0; 201 unsigned int nb_prom_envs = 0;
201 const char *prom_envs[MAX_PROM_ENVS]; 202 const char *prom_envs[MAX_PROM_ENVS];
@@ -6553,6 +6554,7 @@ void help(void) @@ -6553,6 +6554,7 @@ void help(void)
6553 "-snapshot write to temporary files instead of disk image files\n" 6554 "-snapshot write to temporary files instead of disk image files\n"
6554 #ifdef CONFIG_SDL 6555 #ifdef CONFIG_SDL
6555 "-no-frame open SDL window without a frame and window decorations\n" 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 "-no-quit disable SDL window close capability\n" 6558 "-no-quit disable SDL window close capability\n"
6557 #endif 6559 #endif
6558 #ifdef TARGET_I386 6560 #ifdef TARGET_I386
@@ -6736,6 +6738,7 @@ enum { @@ -6736,6 +6738,7 @@ enum {
6736 QEMU_OPTION_loadvm, 6738 QEMU_OPTION_loadvm,
6737 QEMU_OPTION_full_screen, 6739 QEMU_OPTION_full_screen,
6738 QEMU_OPTION_no_frame, 6740 QEMU_OPTION_no_frame,
  6741 + QEMU_OPTION_alt_grab,
6739 QEMU_OPTION_no_quit, 6742 QEMU_OPTION_no_quit,
6740 QEMU_OPTION_pidfile, 6743 QEMU_OPTION_pidfile,
6741 QEMU_OPTION_no_kqemu, 6744 QEMU_OPTION_no_kqemu,
@@ -6829,6 +6832,7 @@ const QEMUOption qemu_options[] = { @@ -6829,6 +6832,7 @@ const QEMUOption qemu_options[] = {
6829 { "full-screen", 0, QEMU_OPTION_full_screen }, 6832 { "full-screen", 0, QEMU_OPTION_full_screen },
6830 #ifdef CONFIG_SDL 6833 #ifdef CONFIG_SDL
6831 { "no-frame", 0, QEMU_OPTION_no_frame }, 6834 { "no-frame", 0, QEMU_OPTION_no_frame },
  6835 + { "alt-grab", 0, QEMU_OPTION_alt_grab },
6832 { "no-quit", 0, QEMU_OPTION_no_quit }, 6836 { "no-quit", 0, QEMU_OPTION_no_quit },
6833 #endif 6837 #endif
6834 { "pidfile", HAS_ARG, QEMU_OPTION_pidfile }, 6838 { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
@@ -7544,6 +7548,9 @@ int main(int argc, char **argv) @@ -7544,6 +7548,9 @@ int main(int argc, char **argv)
7544 case QEMU_OPTION_no_frame: 7548 case QEMU_OPTION_no_frame:
7545 no_frame = 1; 7549 no_frame = 1;
7546 break; 7550 break;
  7551 + case QEMU_OPTION_alt_grab:
  7552 + alt_grab = 1;
  7553 + break;
7547 case QEMU_OPTION_no_quit: 7554 case QEMU_OPTION_no_quit:
7548 no_quit = 1; 7555 no_quit = 1;
7549 break; 7556 break;
@@ -156,6 +156,7 @@ extern int graphic_depth; @@ -156,6 +156,7 @@ extern int graphic_depth;
156 extern const char *keyboard_layout; 156 extern const char *keyboard_layout;
157 extern int kqemu_allowed; 157 extern int kqemu_allowed;
158 extern int win2k_install_hack; 158 extern int win2k_install_hack;
  159 +extern int alt_grab;
159 extern int usb_enabled; 160 extern int usb_enabled;
160 extern int smp_cpus; 161 extern int smp_cpus;
161 extern int cursor_hide; 162 extern int cursor_hide;