Skip to contentSkip to conversation

USB tablet auto grab and ungrab

PATCH New Scipio 1 participant 1 message May 1, 2006

lore
Share & tools
lore

Scipio

author
#0 lore raw

PATCH 1/1 USB tablet auto grab and ungrab

With this patch, automatic grab keyboard and mouse when the mouse enters the window, and ungrab when the mouse reachs the window edge.

I created this beacuse I want to close a window with ALT+F4 inside qemu, but I closed qemu window, because qemu is not grabbed.

Scipio

sdl.c +5 -0
diff -u qemu.orig/sdl.c qemu/sdl.c
@@ -330,6 +330,11 @@
 	}
 
 	SDL_GetMouseState(&dx, &dy);
+	if( dx==0 || dx==width-1 || dy==0 || dy==height-1 ) {
+	    if(gui_grab) sdl_grab_end();
+	} else {
+	    if(!gui_grab) sdl_grab_start();
+        }
 	dx = dx * 0x7FFF / width;
 	dy = dy * 0x7FFF / height;
     }