Next mouse down event lost after SDL_WM_GrabInput(SDL_GRAB_OFF) if window manager mouse cursor also hidden

Andrew Caudwell acaudwell at
Fri May 14 03:16:47 UTC 2010


I've been trying to isolate the cause of a weird mouse click bug i'm
experiencing in my package gource in Squeeze. I also managed to replicate in
another SDL application that also grabs mouse focus in a similar way called
Neverball (neverball).

If you open Gource 0.26 (you will need to point Gource at a git repository
eg 'gource my-project.git/' ), drag the mouse on the background, and
release, the next 'mouse down' click event will get lost by the window
manager (the 'mouse up' event when the button is finally released is still
received). In fact, the next click doesn't even have to be on Gource - eg
you can click on another application and that click will not register.

Likewise, in Neverball once you get into the game it grabs the mouse focus
and hides the mouse pointer to control the Ball with the mouse. If you press
ESC to go back to the menu and try to click a button on the menu, the first
click wont register.

It seems to happen only if the application grabs mouse focus AND hides the
cursor. For instance, the game Abuse (abuse) lets you toggle grabbing the
mouse by pressing F12, but doesn't use the window managers mouse cursor, and
this doesn't lose the mouse click.

Basically programs that use this idiom:




Seem to be affected.

The work around I've found is to use SDL_WarpMouse() to warp the cursor to
the middle of the screen after each mouse motion event to simulate the
behaviour of SDL_WM_GrabInput(SDL_GRAB_ON), and ignore the warp event itself
(eg the game Chromium BSU (chromium-bsu) uses this technique).

It may be this is actually a bug in xorg and not specially SDL as the next
mouse down event doesn't register regardless of where you click after


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Pkg-sdl-maintainers mailing list