Only map/unmap if the window isn't already in the correct state.
authorSam Lantinga <slouken@libsdl.org>
Fri, 28 Sep 2012 00:57:47 -0700
changeset 6483 4b51ff3dcf74
parent 6482 94e3643928ed
child 6484 b904bb684095
Only map/unmap if the window isn't already in the correct state.
src/video/x11/SDL_x11window.c
--- a/src/video/x11/SDL_x11window.c	Fri Sep 28 00:40:47 2012 -0700
+++ b/src/video/x11/SDL_x11window.c	Fri Sep 28 00:57:47 2012 -0700
@@ -809,12 +809,14 @@
     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);
+    if (!X11_IsWindowMapped(_this, window)) {
+        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);
+    }
 }
 
 void
@@ -824,10 +826,12 @@
     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);
+    if (X11_IsWindowMapped(_this, window)) {
+        XUnmapWindow(display, data->xwindow);
+        /* Blocking wait for "UnmapNotify" event */
+        XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);    
+        XFlush(display);
+    }
 }
 
 void