All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1 of 2] sdl nograb
@ 2008-11-04 18:36 Stefano Stabellini
  2008-11-04 19:08 ` Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Stabellini @ 2008-11-04 18:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ian Jackson

Add a -nograb command line option to prevent sdl from grabbing mouse
and keyboard.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

diff -r 5c78dd111aae sdl.c
--- a/sdl.c	Tue Nov 04 09:04:41 2008 +0000
+++ b/sdl.c	Tue Nov 04 18:31:02 2008 +0000
@@ -451,7 +451,7 @@
                         gui_key_modifier_pressed = 0;
                         if (gui_keysym == 0) {
                             /* exit/enter grab if pressing Ctrl-Alt */
-                            if (!gui_grab) {
+                            if (!gui_grab && !grab_disabled) {
                                 /* if the application is not active,
                                    do not try to enter grab state. It
                                    prevents
@@ -481,7 +481,7 @@
             break;
         case SDL_MOUSEMOTION:
             if (gui_grab || kbd_mouse_is_absolute() ||
-                absolute_enabled) {
+                absolute_enabled || grab_disabled) {
                 sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel, 0,
                        ev->motion.x, ev->motion.y, ev->motion.state);
             }
@@ -490,7 +490,7 @@
         case SDL_MOUSEBUTTONUP:
             {
                 SDL_MouseButtonEvent *bev = &ev->button;
-                if (!gui_grab && !kbd_mouse_is_absolute()) {
+                if (!gui_grab && !kbd_mouse_is_absolute() && !grab_disabled) {
                     if (ev->type == SDL_MOUSEBUTTONDOWN &&
                         (bev->button == SDL_BUTTON_LEFT)) {
                         /* start grabbing all events */
@@ -655,7 +655,10 @@
     atexit(sdl_cleanup);
     if (full_screen) {
         gui_fullscreen = 1;
-        gui_fullscreen_initial_grab = 1;
-        sdl_grab_start();
+        if (!grab_disabled)
+        {
+            gui_fullscreen_initial_grab = 1;
+            sdl_grab_start();
+        }
     }
 }
diff -r 5c78dd111aae sysemu.h
--- a/sysemu.h	Tue Nov 04 09:04:41 2008 +0000
+++ b/sysemu.h	Tue Nov 04 18:31:02 2008 +0000
@@ -90,6 +90,7 @@
 extern const char *keyboard_layout;
 extern int win2k_install_hack;
 extern int alt_grab;
+extern int grab_disabled;
 extern int usb_enabled;
 extern int smp_cpus;
 extern int cursor_hide;
diff -r 5c78dd111aae vl.c
--- a/vl.c	Tue Nov 04 09:04:41 2008 +0000
+++ b/vl.c	Tue Nov 04 18:31:02 2008 +0000
@@ -227,6 +227,7 @@
 #endif
 const char *qemu_name;
 int alt_grab = 0;
+int grab_disabled = 0;
 #ifdef TARGET_SPARC
 unsigned int nb_prom_envs = 0;
 const char *prom_envs[MAX_PROM_ENVS];
@@ -4685,6 +4686,7 @@
            "-no-frame       open SDL window without a frame and window decorations\n"
            "-alt-grab       use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n"
            "-no-quit        disable SDL window close capability\n"
+           "-nograb         never grab mouse and keyboard\n"
 #endif
 #ifdef TARGET_I386
            "-no-fd-bootchk  disable boot signature checking for floppy disks\n"
@@ -4883,6 +4885,7 @@
     QEMU_OPTION_full_screen,
     QEMU_OPTION_no_frame,
     QEMU_OPTION_alt_grab,
+    QEMU_OPTION_nograb,
     QEMU_OPTION_no_quit,
     QEMU_OPTION_pidfile,
     QEMU_OPTION_no_kqemu,
@@ -4988,6 +4991,7 @@
     { "no-frame", 0, QEMU_OPTION_no_frame },
     { "alt-grab", 0, QEMU_OPTION_alt_grab },
     { "no-quit", 0, QEMU_OPTION_no_quit },
+    { "nograb", 0, QEMU_OPTION_nograb },
 #endif
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
     { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
@@ -5776,6 +5780,9 @@
                 break;
             case QEMU_OPTION_no_quit:
                 no_quit = 1;
+                break;
+            case QEMU_OPTION_nograb:
+                grab_disabled = 1;
                 break;
 #endif
             case QEMU_OPTION_pidfile:

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH 1 of 2] sdl nograb
  2008-11-04 18:36 [Qemu-devel] [PATCH 1 of 2] sdl nograb Stefano Stabellini
@ 2008-11-04 19:08 ` Anthony Liguori
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2008-11-04 19:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ian Jackson

Stefano Stabellini wrote:
> Add a -nograb command line option to prevent sdl from grabbing mouse
> and keyboard.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>
> diff -r 5c78dd111aae sdl.c
> --- a/sdl.c	Tue Nov 04 09:04:41 2008 +0000
> +++ b/sdl.c	Tue Nov 04 18:31:02 2008 +0000
> @@ -451,7 +451,7 @@
>                          gui_key_modifier_pressed = 0;
>                          if (gui_keysym == 0) {
>                              /* exit/enter grab if pressing Ctrl-Alt */
> -                            if (!gui_grab) {
> +                            if (!gui_grab && !grab_disabled) {
>                                  /* if the application is not active,
>                                     do not try to enter grab state. It
>                                     prevents
> @@ -481,7 +481,7 @@
>              break;
>          case SDL_MOUSEMOTION:
>              if (gui_grab || kbd_mouse_is_absolute() ||
> -                absolute_enabled) {
> +                absolute_enabled || grab_disabled) {
>                  sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel, 0,
>                         ev->motion.x, ev->motion.y, ev->motion.state);
>              }
> @@ -490,7 +490,7 @@
>          case SDL_MOUSEBUTTONUP:
>              {
>                  SDL_MouseButtonEvent *bev = &ev->button;
> -                if (!gui_grab && !kbd_mouse_is_absolute()) {
> +                if (!gui_grab && !kbd_mouse_is_absolute() && !grab_disabled) {
>                      if (ev->type == SDL_MOUSEBUTTONDOWN &&
>                          (bev->button == SDL_BUTTON_LEFT)) {
>                          /* start grabbing all events */
> @@ -655,7 +655,10 @@
>      atexit(sdl_cleanup);
>      if (full_screen) {
>          gui_fullscreen = 1;
> -        gui_fullscreen_initial_grab = 1;
> -        sdl_grab_start();
> +        if (!grab_disabled)
> +        {
> +            gui_fullscreen_initial_grab = 1;
> +            sdl_grab_start();
> +        }
>   

Code formatting is off here (should be if () {).

In principle, I think this patch is good.  I wonder if we should 
introduce some sort of way to pass sdl options and fold -no-quit and 
-no-grab into the same command.  Like -sdlopts no-quit,no-grab.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-04 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-04 18:36 [Qemu-devel] [PATCH 1 of 2] sdl nograb Stefano Stabellini
2008-11-04 19:08 ` Anthony Liguori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.