Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.
authorSam Lantinga <slouken@libsdl.org>
Tue, 05 Apr 2011 09:47:34 -0700
changeset 5531477f550f6efd
parent 5530 4e46a7b6773d
child 5532 8a04b596b472
Fixed setting programmatically setting the size of a window on X11 for non-resizable windows.

Patch by Matthew Smaling
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/x11/SDL_x11window.c	Tue Apr 05 09:35:56 2011 -0700
     1.2 +++ b/src/video/x11/SDL_x11window.c	Tue Apr 05 09:47:34 2011 -0700
     1.3 @@ -772,7 +772,22 @@
     1.4  
     1.5      if (SDL_IsShapedWindow(window))
     1.6          X11_ResizeWindowShape(window);
     1.7 -    XResizeWindow(display, data->xwindow, window->w, window->h);
     1.8 +    if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
     1.9 +         /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus
    1.10 +            we must set the size hints to adjust the window size.*/
    1.11 +         XSizeHints *sizehints = XAllocSizeHints();
    1.12 +         long userhints;
    1.13 +
    1.14 +         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
    1.15 +
    1.16 +         sizehints->min_width = sizehints->max_height = window->w;
    1.17 +         sizehints->min_height = sizehints->max_height = window->h;
    1.18 +
    1.19 +         XSetWMNormalHints(display, data->xwindow, sizehints);
    1.20 +
    1.21 +         XFree(sizehints);
    1.22 +    } else
    1.23 +        XResizeWindow(display, data->xwindow, window->w, window->h);
    1.24      XFlush(display);
    1.25  }
    1.26