qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] sdl fix for mouse grab/hide
@ 2006-05-25 11:01 Herbert Poetzl
  2006-05-25 17:40 ` [Qemu-devel] " Adam D. Moss
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Poetzl @ 2006-05-25 11:01 UTC (permalink / raw)
  To: Qemu mailing list


Hi Folks!

IMHO the idea behind the grab/mouse hide was to
have relative mouse moves inside the window when
the mouse is grabbed ...

now the SDL documentation SDL_MouseMotionEvent(3)
says the following:

If the cursor is hidden (SDL_ShowCursor(0)) and the 
input is grabbed (SDL_WM_GrabInput(SDL_GRAB_ON)),
then the mouse will give relative motion events 
even when the cursor reaches the edge fo the screen.

which is almost met, except for qemu _not_ using
the SDL_ShowCursor() but instead doing a special
SDL_SetCursor(sdl_cursor_hidden), which results in
SDL _not_ transmitting the relative motion events
once the border is reached, which in turn gives
funny behaviour :)

the following patch fixes this:


diff -NurpP qemu-cvs20060522/sdl.c qemu-cvs20060522/sdl.c
--- qemu-cvs20060522/sdl.c	2006-05-23 01:18:33.000000000 +0200
+++ qemu-cvs20060522/sdl.c	2006-05-23 03:03:19.000000000 +0200
@@ -285,13 +285,13 @@ static void sdl_update_caption(void)
 
 static void sdl_hide_cursor(void)
 {
-    SDL_SetCursor(sdl_cursor_hidden);
+    SDL_ShowCursor(0);
 }
 
 static void sdl_show_cursor(void)
 {
     if (!kbd_mouse_is_absolute()) {
-	SDL_SetCursor(sdl_cursor_normal);
+	SDL_ShowCursor(1);
     }
 }
 

best,
Herbert

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

* [Qemu-devel] Re: sdl fix for mouse grab/hide
  2006-05-25 11:01 [Qemu-devel] sdl fix for mouse grab/hide Herbert Poetzl
@ 2006-05-25 17:40 ` Adam D. Moss
  0 siblings, 0 replies; 2+ messages in thread
From: Adam D. Moss @ 2006-05-25 17:40 UTC (permalink / raw)
  To: qemu-devel

Herbert Poetzl wrote:
> which is almost met, except for qemu _not_ using
> the SDL_ShowCursor() but instead doing a special
> SDL_SetCursor(sdl_cursor_hidden), which results in
> SDL _not_ transmitting the relative motion events
> once the border is reached, which in turn gives
> funny behaviour :)

The code you're changing was added to work-around a supposed
SDL bug in the first place.  Below is the text of the original
2006-03-01 posting for the change, by anthony@codemonkey.ws
--adam
------------------------------------------------------
There appears to bug a bug in the latest version of SDL (1.2.9) that 
causes the position of the cursor to be wrongly reported after calling 
SDL_ShowCursor(0).

When the cursor is disabled, relative and absolute mouse events are 
reported as garbage.

This patch works around this by using a invisible cursor instead of 
disabling the cursor.  This has the same functionality of disabling the 
cursor but avoids these problems.

For what it's worth, disabling the cursor in older versions of SDL also 
has strange side effects.  For instance, the cursor gets warped when you 
hit the edge of the bounding box.  If you're using an absolute input 
device (emulating a Wacom or Synaptics touchpad for instance), this 
results in weird mouse behavior (when you exit this window, your mouse 
ends up in the middle of the window!).

Avoiding SDL_ShowCursor(0) is probably a good idea regardless of this 
particular bug.

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

end of thread, other threads:[~2006-05-25 17:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-25 11:01 [Qemu-devel] sdl fix for mouse grab/hide Herbert Poetzl
2006-05-25 17:40 ` [Qemu-devel] " Adam D. Moss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).