Fixed issue with tiling window managers (bug 1246)
authorSam Lantinga <slouken@libsdl.org>
Thu, 21 Jun 2012 09:58:22 -0400
changeset 63366e6163b6ba69
parent 6335 fbb84f5b985f
child 6337 3c91a153f398
Fixed issue with tiling window managers (bug 1246)

Patch contributed by Driedfruit - thanks!
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/x11/SDL_x11sym.h	Wed Jun 20 11:25:40 2012 -0300
     1.2 +++ b/src/video/x11/SDL_x11sym.h	Thu Jun 21 09:58:22 2012 -0400
     1.3 @@ -59,6 +59,7 @@
     1.4  SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
     1.5  SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return)
     1.6  SDL_X11_SYM(Status,XGetWMNormalHints,(Display *a,Window b, XSizeHints *c, long *d),(a,b,c,d),return)
     1.7 +SDL_X11_SYM(int,XIfEvent,(Display* a,XEvent *b,Bool (*c)(Display*,XEvent*,XPointer),XPointer d),(a,b,c,d),return)
     1.8  SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return)
     1.9  SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return)
    1.10  SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return)
     2.1 --- a/src/video/x11/SDL_x11window.c	Wed Jun 20 11:25:40 2012 -0300
     2.2 +++ b/src/video/x11/SDL_x11window.c	Thu Jun 21 09:58:22 2012 -0400
     2.3 @@ -765,13 +765,27 @@
     2.4      XFlush(display);
     2.5  }
     2.6  
     2.7 +static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win)
     2.8 +{
     2.9 +    return ev->type == MapNotify && ev->xmap.window == *((Window*)win);
    2.10 +}
    2.11 +static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win)
    2.12 +{
    2.13 +    return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win);
    2.14 +}
    2.15 +
    2.16  void
    2.17  X11_ShowWindow(_THIS, SDL_Window * window)
    2.18  {
    2.19      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    2.20      Display *display = data->videodata->display;
    2.21 +    XEvent event;
    2.22  
    2.23      XMapRaised(display, data->xwindow);
    2.24 +    /* Blocking wait for "MapNotify" event.
    2.25 +     * We use XIfEvent because XWindowEvent takes a mask rather than a type, 
    2.26 +     * and XCheckTypedWindowEvent doesn't block */
    2.27 +    XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
    2.28      XFlush(display);
    2.29  }
    2.30  
    2.31 @@ -780,8 +794,11 @@
    2.32  {
    2.33      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    2.34      Display *display = data->videodata->display;
    2.35 +    XEvent event;
    2.36  
    2.37      XUnmapWindow(display, data->xwindow);
    2.38 +    /* Blocking wait for "UnmapNotify" event */
    2.39 +    XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);    
    2.40      XFlush(display);
    2.41  }
    2.42