]> Git Repo - qemu.git/commitdiff
offer right-ctrl as a grab option
authorDustin Kirkland <[email protected]>
Thu, 17 Sep 2009 20:48:04 +0000 (15:48 -0500)
committerAnthony Liguori <[email protected]>
Tue, 6 Oct 2009 19:36:09 +0000 (14:36 -0500)
Add support for -ctrl-grab to use the right-ctrl button to grab/release
the mouse in SDL.

The multi-button ctrl-alt and ctrl-alt-shift grab buttons present an
accessibility problem to users who cannot press more than one button
at a time.

https://bugs.edge.launchpad.net/ubuntu/+source/qemu-kvm/+bug/237635

Signed-off-by: Dustin Kirkland <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
qemu-options.hx
sdl.c
sysemu.h
vl.c

index f21e9f9da22060b5ae917d639e05dc6d41e2a53d..3dd76b34bf4b532a5aab7275a09da47fdcd102df 100644 (file)
@@ -477,6 +477,16 @@ STEXI
 Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt).
 ETEXI
 
+#ifdef CONFIG_SDL
+DEF("ctrl-grab", 0, QEMU_OPTION_ctrl_grab,
+    "-ctrl-grab       use Right-Ctrl to grab mouse (instead of Ctrl-Alt)\n")
+#endif
+STEXI
+@item -ctrl-grab
+
+Use Right-Ctrl to grab mouse (instead of Ctrl-Alt).
+ETEXI
+
 #ifdef CONFIG_SDL
 DEF("no-quit", 0, QEMU_OPTION_no_quit,
     "-no-quit        disable SDL window close capability\n")
diff --git a/sdl.c b/sdl.c
index 42b6f37e6f45a08f35efb976c692697c4ac057fb..034440f72157c927df0f177d988e5d581cd4658f 100644 (file)
--- a/sdl.c
+++ b/sdl.c
@@ -414,10 +414,12 @@ static void sdl_update_caption(void)
     if (!vm_running)
         status = " [Stopped]";
     else if (gui_grab) {
-        if (!alt_grab)
-            status = " - Press Ctrl-Alt to exit grab";
-        else
+        if (alt_grab)
             status = " - Press Ctrl-Alt-Shift to exit grab";
+        else if (ctrl_grab)
+            status = " - Press Right-Ctrl to exit grab";
+        else
+            status = " - Press Ctrl-Alt to exit grab";
     }
 
     if (qemu_name) {
@@ -557,12 +559,14 @@ static void sdl_refresh(DisplayState *ds)
         case SDL_KEYDOWN:
         case SDL_KEYUP:
             if (ev->type == SDL_KEYDOWN) {
-                if (!alt_grab) {
-                    mod_state = (SDL_GetModState() & gui_grab_code) ==
-                                gui_grab_code;
-                } else {
+                if (alt_grab) {
                     mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
                                 (gui_grab_code | KMOD_LSHIFT);
+                } else if (ctrl_grab) {
+                    mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
+                } else {
+                    mod_state = (SDL_GetModState() & gui_grab_code) ==
+                                gui_grab_code;
                 }
                 gui_key_modifier_pressed = mod_state;
                 if (gui_key_modifier_pressed) {
index 9131e62cddcfa97319aba2b8e7b6f6dc2f66fc4d..763861ded56c1095325e9dbee19939530b064dfd 100644 (file)
--- a/sysemu.h
+++ b/sysemu.h
@@ -126,6 +126,7 @@ extern const char *keyboard_layout;
 extern int win2k_install_hack;
 extern int rtc_td_hack;
 extern int alt_grab;
+extern int ctrl_grab;
 extern int usb_enabled;
 extern int smp_cpus;
 extern int max_cpus;
diff --git a/vl.c b/vl.c
index 6d79912172f5a5b5e6d184e256af59d9dd1ec699..3d2314025ce116140eacc77d0fdcdb092f48b0fd 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -247,6 +247,7 @@ int old_param = 0;
 #endif
 const char *qemu_name;
 int alt_grab = 0;
+int ctrl_grab = 0;
 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
 unsigned int nb_prom_envs = 0;
 const char *prom_envs[MAX_PROM_ENVS];
@@ -5310,6 +5311,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_alt_grab:
                 alt_grab = 1;
                 break;
+            case QEMU_OPTION_ctrl_grab:
+                ctrl_grab = 1;
+                break;
             case QEMU_OPTION_no_quit:
                 no_quit = 1;
                 break;
This page took 0.051092 seconds and 4 git commands to generate.