Fullscreen focus hijacking on X11

I’m getting a lot of bug reports about IM clients screwing up fullscreen
modes on X11, so I spent a few hours reproducing the issue and writing a
minimal test case for two seperate, but related issues.

Issue #1:
A message window pops up and the SDL window loses focus. Under the hood,
SDL responds to this by reverting to a window, but doesn’t seem to
unlock the mouse cursor; the cursor sits visible in the center of the
newly-windowed SDL surface. This is happening reliably here with both
metacity and icewm window managers in a Gnome environment on XFree86
4.3.0 (gentoo’s 4.3.0-r3, specifically).

At the application level, if I call SDL_ShowCursor(1) in my
SDL_ACTIVEEVENT handler, the mouse moves correctly across the desktop.
So the SDL_ACTIVEEVENT code ends up looking like:

    SDL_ShowCursor(event.active.gain ? 0 : 1);

I’ve attached a program to demonstrate this. Run it, ssh in to your box
and launch an xterm so the SDL window loses focus. See how mouse cursor
becomes visible but doesn’t move. Exit the new xterm so it goes away and
(hopefully) returns focus to your SDL window, and hit ESC to terminate
the program.

Rerun program with --showhide to manually show/hide the cursor in the
SDL_ACTIVEEVENT handler, which “fixes” the issue.

You may also notice that the windowed SDL surface resists being dragged
around by its title bar, but that might just be metacity.

Issue #2:
Create a 2D window and then manually focus a different window on your
desktop, call SDL_PumpEvents() so the X11 driver sets its
this->hidden->switch_waiting, then set a fullscreen OpenGL window (which
makes the X11 driver tear down and create a new window instead of just
resizing the existing one), poll for events, and the newly-created
window will think it needs to pop back to a window. --showhide doesn’t
unlock the cursor with this one.

I just checked in a fix to CVS for this second issue, but if you want to
see it firsthand, run the test program with --splash and SDL-1.2.7 so it
triggers the bug.


-------------- next part --------------
A non-text attachment was scrubbed…
Name: test.c
Type: text/x-c
Size: 1936 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040226/42026e4b/attachment.bin