src/video/x11/SDL_x11window.c
changeset 6336 6e6163b6ba69
parent 6331 5732e1a80bde
child 6343 e94f912d20b9
--- a/src/video/x11/SDL_x11window.c	Wed Jun 20 11:25:40 2012 -0300
+++ b/src/video/x11/SDL_x11window.c	Thu Jun 21 09:58:22 2012 -0400
@@ -765,13 +765,27 @@
     XFlush(display);
 }
 
+static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win)
+{
+    return ev->type == MapNotify && ev->xmap.window == *((Window*)win);
+}
+static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win)
+{
+    return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win);
+}
+
 void
 X11_ShowWindow(_THIS, SDL_Window * window)
 {
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
+    XEvent event;
 
     XMapRaised(display, data->xwindow);
+    /* Blocking wait for "MapNotify" event.
+     * We use XIfEvent because XWindowEvent takes a mask rather than a type, 
+     * and XCheckTypedWindowEvent doesn't block */
+    XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
     XFlush(display);
 }
 
@@ -780,8 +794,11 @@
 {
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
+    XEvent event;
 
     XUnmapWindow(display, data->xwindow);
+    /* Blocking wait for "UnmapNotify" event */
+    XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);    
     XFlush(display);
 }