Fix SDL_SetWindowSize on certain WMs.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Mon, 18 Feb 2013 18:28:02 -0800
changeset 6899f75b1bd8eabc
parent 6898 d0159180a95f
child 6900 767690d1c013
Fix SDL_SetWindowSize on certain WMs.

Makes SDL_SetWindowSize work on some WMs (like Fluxbox, ion3, Awesome,
WindowMaker), and when running without a WM.

Fixes bug 1513.
CR: saml
Xcode/TemplatesForXcodeTiger/SDL Application/English.lproj/InfoPlist.strings
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/InfoPlist.strings
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/English.lproj/InfoPlist.strings
src/video/x11/SDL_x11window.c
     1.1 Binary file Xcode/TemplatesForXcodeTiger/SDL Application/English.lproj/InfoPlist.strings has changed
     2.1 Binary file Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/InfoPlist.strings has changed
     3.1 Binary file Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/English.lproj/InfoPlist.strings has changed
     4.1 --- a/src/video/x11/SDL_x11window.c	Mon Feb 18 16:24:33 2013 -0800
     4.2 +++ b/src/video/x11/SDL_x11window.c	Mon Feb 18 18:28:02 2013 -0800
     4.3 @@ -768,37 +768,28 @@
     4.4           XFree(sizehints);
     4.5  
     4.6          /* From Pierre-Loup:
     4.7 -           For the windowed resize problem; WMs each have their little quirks with
     4.8 -           that.  When you change the size hints, they get a ConfigureNotify event
     4.9 -           with the WM_NORMAL_SIZE_HINTS Atom.  They all save the hints then, but
    4.10 -           they don't all resize the window right away to enforce the new hints.
    4.11 -           Those who do properly do it are:
    4.12 -          
    4.13 -             - XFWM
    4.14 -             - metacity
    4.15 -             - KWin
    4.16 +           WMs each have their little quirks with that.  When you change the
    4.17 +           size hints, they get a ConfigureNotify event with the
    4.18 +           WM_NORMAL_SIZE_HINTS Atom.  They all save the hints then, but they
    4.19 +           don't all resize the window right away to enforce the new hints.
    4.20  
    4.21 -           These are great.  Now, others are more problematic as you could observe
    4.22 -           first hand.  Compiz/Unity only falls into the code that does it on select
    4.23 -           actions, such as window move, raise, map, etc.
    4.24 +           Some of them resize only after:
    4.25 +            - A user-initiated move or resize
    4.26 +            - A code-initiated move or resize
    4.27 +            - Hiding & showing window (Unmap & map)
    4.28  
    4.29 -           WindowMaker is even more difficult and will _only_ do it on map.
    4.30 -
    4.31 -           Awesome only does it on user-initiated moves as far as I can tell.
    4.32 -          
    4.33 -           Your raise workaround only fixes compiz/Unity.  With that all "modern"
    4.34 -           window managers are covered.  Trying to Hide/Show on windowed resize
    4.35 -           (UnMap/Map) fixes both Unity and WindowMaker, but introduces subtle
    4.36 -           problems with transitioning from Windowed to Fullscreen on Unity.  Since
    4.37 -           some window moves happen after the transitions to fullscreen, that forces
    4.38 -           SDL to fall from windowed to fullscreen repeatedly and it sometimes leaves
    4.39 -           itself in a state where the fullscreen window is slightly offset by what
    4.40 -           used to be the window decoration titlebar.
    4.41 -        */
    4.42 +           The following move & resize seems to help a lot of WMs that didn't
    4.43 +           properly update after the hints were changed. We don't do a
    4.44 +           hide/show, because there are supposedly subtle problems with doing so
    4.45 +           and transitioning from windowed to fullscreen in Unity.
    4.46 +         */
    4.47 +        XResizeWindow(display, data->xwindow, window->w, window->h);
    4.48 +        XMoveWindow(display, data->xwindow, window->x, window->y);
    4.49          XRaiseWindow(display, data->xwindow);
    4.50      } else {
    4.51          XResizeWindow(display, data->xwindow, window->w, window->h);
    4.52      }
    4.53 +
    4.54      XFlush(display);
    4.55  }
    4.56