Skip to contentSkip to conversation

feature request: Mousepointer not grabbed

Qemu-devel Jens Arm 4 participants 7 messages Dec 17, 2004

lore
Share & tools
lore

Jens Arm

author
#0 lore raw

Hi

Is it possible to implement in qemu that the Mousepointer is not grabbed if enabled? Like in BasiliskII?

Jens

author
#4 lore raw
Quoted 5 lines
Quoted 1 line

Almost all *hunks* are failing in the patch :(

:-)

Very funny typo.

Why typo patch is saying this:

patching file target-i386/translate.c
Hunk #12 succeeded at 4408 (offset 12 lines).
^^^^
Jens

#5 lore raw
Quoted 6 lines

Why typo patch is saying this:

patching file target-i386/translate.c
Hunk #12 succeeded at 4408 (offset 12 lines).
^^^^
Jens

Yes you are right. My mind is playing games with me.
I always red that as "chunk". Don't now why.

teris.

#6 lore raw
In reply to Jens Arm

Hi,

Quoted 9 lines · Jens Arm
Quoted 7 lines
Quoted 2 lines

Is it possible to implement in qemu that the Mousepointer is not grabbed if enabled? Like in BasiliskII?

A patch with such functionality was posted here:

http://lists.gnu.org/archive/html/qemu-devel/2004-07/msg00453.html

Almost all hunks are failing in the patch :(

So I took the patch, and updated manually. You can see the result attached.

Hth,
Dscho

Index: sdl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/sdl.c,v
retrieving revision 1.20

sdl.c +13 -6
diff -u -u -r1.20 sdl.c
@@ -39,6 +39,7 @@
 static int gui_fullscreen_initial_grab;
 static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
 static uint8_t modifiers_state[256];
+static int saved_grab_with_sdl;
 
 static void sdl_update(DisplayState *ds, int x, int y, int w, int h)
 {
@@ -263,8 +264,10 @@
 
 static void sdl_grab_start(void)
 {
-    SDL_ShowCursor(0);
-    SDL_WM_GrabInput(SDL_GRAB_ON);
+    if(grab_with_sdl) {
+        SDL_ShowCursor(0);
+        SDL_WM_GrabInput(SDL_GRAB_ON);
+    }
     /* dummy read to avoid moving the mouse */
     SDL_GetRelativeMouseState(NULL, NULL);
     gui_grab = 1;
@@ -273,8 +276,10 @@
 
 static void sdl_grab_end(void)
 {
-    SDL_WM_GrabInput(SDL_GRAB_OFF);
-    SDL_ShowCursor(1);
+    if(grab_with_sdl) {
+        SDL_WM_GrabInput(SDL_GRAB_OFF);
+        SDL_ShowCursor(1);
+    }
     gui_grab = 0;
     sdl_update_caption();
 }
@@ -307,9 +312,11 @@
     sdl_resize(ds, screen->w, screen->h);
     if (gui_fullscreen) {
         gui_saved_grab = gui_grab;
+	saved_grab_with_sdl = grab_with_sdl;
+	grab_with_sdl = 1;
         sdl_grab_start();
     } else {
-        if (!gui_saved_grab)
+        if (!gui_saved_grab || !saved_grab_with_sdl)
             sdl_grab_end();
     }
     vga_invalidate_display();
@@ -445,7 +452,7 @@
             }
             break;
         case SDL_ACTIVEEVENT:
-            if (gui_grab && (ev->active.gain & SDL_ACTIVEEVENTMASK) == 0 &&
+            if (grab_with_sdl && gui_grab && (ev->active.gain & SDL_ACTIVEEVENTMASK) == 0 &&
                 !gui_fullscreen_initial_grab) {
                 sdl_grab_end();
             }

Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.110

vl.c +6 -0
diff -u -u -r1.110 vl.c
@@ -136,6 +136,7 @@
 int full_screen = 0;
 TextConsole *vga_console;
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
+int grab_with_sdl = 1;
 
 /***********************************************************/
 /* x86 ISA bus support */
@@ -2672,6 +2673,7 @@
     QEMU_OPTION_loadvm,
     QEMU_OPTION_full_screen,
     QEMU_OPTION_pidfile,
+    QEMU_OPTION_no_sdl_grab,
 };
 
 typedef struct QEMUOption {
@@ -2738,6 +2740,7 @@
     /* temporary options */
     { "pci", 0, QEMU_OPTION_pci },
     { "cirrusvga", 0, QEMU_OPTION_cirrusvga },
+    { "no-sdl-grab", 0, QEMU_OPTION_no_sdl_grab },
     { NULL },
 };
 
@@ -3165,6 +3168,9 @@
             case QEMU_OPTION_pidfile:
                 create_pidfile(optarg);
                 break;
+	    case QEMU_OPTION_no_sdl_grab:
+		grab_with_sdl = 0;
+		break;
             }
         }
     }

Index: vl.h
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.h,v
retrieving revision 1.63

vl.h +1 -0
diff -u -u -r1.63 vl.h
@@ -124,6 +124,7 @@
 extern int graphic_height;
 extern int graphic_depth;
 extern const char *keyboard_layout;
+extern int grab_with_sdl;
 
 /* XXX: make it dynamic */
 #if defined (TARGET_PPC)