[SDL] problem with X11 mouse events
Kyle Hubert
khubert at gmail.com
Fri Dec 8 12:09:25 PST 2006
I'm bouncing this message, who is in charge of old releases? Or,
rather, independent patches. I want to make a release, but be able to
say, "See the original SDL source." Rather than, "Here is the modified
SDL source, and a modified library that I need at runtime."
I'm perfectly willing to accept this patch is completely wrong. Who is
in charge of the SDL_x11 video implementation?
What is your schedule for SDL 1.2.12? Is it a dead branch?
-Kyle
On 12/7/06, Kyle Hubert <khubert at gmail.com> wrote:
> I'm writing a windowed SDL application with the mouse switching in and
> out of the grabbed state. I'm using SDL 1.2.11 on Linux. I noticed
> that when the mouse was outside of the window and the keyboard input
> was still on, calling grab mouse didn't switch the app state to
> SDL_APPMOUSEFOCUS.
>
> I'm not in tune with the underlying X11 implementation, so I decided
> to workaround it by warping the mouse to the center of the window
> before grabbing input. Unfortunately, this still didn't work. I choose
> to make this workaround do the right thing by using the following
> code. (Forgive the emacs tabbing/spacing issues)
>
> I believe the true issue is that the X11 EnterNotify event is never
> triggered if you leave a window and grab the input. I didn't spend too
> long digging through it.
>
> --- SDL-1.2.11/src/video/x11/SDL_x11mouse.c 2006-05-01
> 01:02:48.000000000 -0700
> +++ SDL-1.2.11.orig/src/video/x11/SDL_x11mouse.c 2006-12-07
> 21:43:20.000000000 -0800
> @@ -171,16 +171,25 @@
> {
> if ( using_dga & DGA_MOUSE ) {
> SDL_PrivateMouseMotion(0, 0, x, y);
> - } else if ( mouse_relative) {
> + } else {
> + if ( ! (SDL_GetAppState & SDL_APPMOUSEFOCUS) ) {
> + Uint16 screen_w = SDL_VideoSurface->w;
> + Uint16 screen_h = SDL_VideoSurface->h;
> + if( x < w && y < h ) {
> + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
> + }
> + }
> + if ( mouse_relative) {
> /* RJR: March 28, 2000
> leave physical cursor at center of screen if
> mouse hidden and grabbed */
> SDL_PrivateMouseMotion(0, 0, x, y);
> - } else {
> - SDL_Lock_EventThread();
> - XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
> - XSync(SDL_Display, False);
> - SDL_Unlock_EventThread();
> + } else {
> + SDL_Lock_EventThread();
> + XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
> + XSync(SDL_Display, False);
> + SDL_Unlock_EventThread();
> + }
> }
> }
>
>
> Thanks,
>
> -Kyle
>
More information about the SDL
mailing list