X11_WaitMapped blocks apps from starting on different virtual desktop

We’re experiencing an issue with the stable branch of SDL regarding opening an
X11 SDL window, when the window manager decides to place it off-screen, or
iconified initially, when the program starts.

It’s caused by the “X11_WaitMapped” change that took place in this email:

http://lists.libsdl.org/htdig.cgi/sdl-libsdl.org/2001-August/019499.html

I believe the fix to be suboptimal, because it means that any SDL application
will block until the window is brought into focus (X11 mapped). It causes
difficulty for our application (a variant of qemu, the virtual machine emulator)
where we’d like the option to be able to open the window on a non-visible
workspace and have it proceed without waiting for focus.

There are two hunks below that I believe will fix the original concern of having
the window title being sometimes lost, and will revert the previous patch to
unblock applications that run without needing to be initially visible.

Looking at the latest code in SVN, I don’t believe that this issue is present in
1.3, though I’ve yet to perform the tests.

It is possible that this patch, or something similar, would be considered for
the 1.2 branch?

Christopher

diff -r 52d550ce7b24 src/video/x11/SDL_x11events.c
— a/src/video/x11/SDL_x11events.c Wed Apr 09 18:55:53 2008 -0700
+++ b/src/video/x11/SDL_x11events.c Wed Apr 09 18:57:33 2008 -0700
@@ -811,6 +811,10 @@ printf(“MapNotify!\n”);
}
X11_CheckMouseModeNoLock(this);

  •           if ( (this->wm_title) || (this->wm_icon) ) {
    
  •                   X11_SetCaption(this, this->wm_title, this->wm_icon);
    
  •           }+
              if ( SDL_VideoSurface ) {
                      X11_RefreshDisplay(this);
              }
    

diff -r 52d550ce7b24 src/video/x11/SDL_x11video.c
— a/src/video/x11/SDL_x11video.c Wed Apr 09 18:55:53 2008 -0700
+++ b/src/video/x11/SDL_x11video.c Wed Apr 09 18:56:21 2008 -0700
@@ -1087,9 +1087,9 @@ static int X11_CreateWindow(_THIS, SDL_S
if ( ! SDL_windowid ) {
XMapWindow(SDL_Display, SDL_Window);
XMapWindow(SDL_Display, WMwindow);

  •           X11_WaitMapped(this, WMwindow);
              if ( flags & SDL_FULLSCREEN ) {
                      screen->flags |= SDL_FULLSCREEN;
    
  •                   X11_WaitMapped(this, WMwindow);
                      X11_EnterFullScreen(this);
              } else {
                      screen->flags &= ~SDL_FULLSCREEN;