Fixed bug 2007 - SDL_SetWindowMinimumSize() not implemented on X11 (thanks Rainer!)
authorSam Lantinga
Fri, 09 Aug 2013 23:13:52 -0700
changeset 7617918703f5cff8
parent 7616 1eaa3b3c55c5
child 7618 d381f183aa07
Fixed bug 2007 - SDL_SetWindowMinimumSize() not implemented on X11 (thanks Rainer!)
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11window.c
src/video/x11/SDL_x11window.h
     1.1 --- a/src/video/x11/SDL_x11video.c	Fri Aug 09 21:09:49 2013 -0700
     1.2 +++ b/src/video/x11/SDL_x11video.c	Fri Aug 09 23:13:52 2013 -0700
     1.3 @@ -362,6 +362,8 @@
     1.4      device->SetWindowIcon = X11_SetWindowIcon;
     1.5      device->SetWindowPosition = X11_SetWindowPosition;
     1.6      device->SetWindowSize = X11_SetWindowSize;
     1.7 +    device->SetWindowMinimumSize = X11_SetWindowMinimumSize;
     1.8 +    device->SetWindowMaximumSize = X11_SetWindowMaximumSize;
     1.9      device->ShowWindow = X11_ShowWindow;
    1.10      device->HideWindow = X11_HideWindow;
    1.11      device->RaiseWindow = X11_RaiseWindow;
     2.1 --- a/src/video/x11/SDL_x11window.c	Fri Aug 09 21:09:49 2013 -0700
     2.2 +++ b/src/video/x11/SDL_x11window.c	Fri Aug 09 23:13:52 2013 -0700
     2.3 @@ -742,6 +742,64 @@
     2.4  }
     2.5  
     2.6  void
     2.7 +X11_SetWindowMinimumSize(_THIS, SDL_Window * window)
     2.8 +{
     2.9 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    2.10 +    Display *display = data->videodata->display;
    2.11 +
    2.12 +    if (window->flags & SDL_WINDOW_RESIZABLE) {
    2.13 +         XSizeHints *sizehints = XAllocSizeHints();
    2.14 +         long userhints;
    2.15 +
    2.16 +         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
    2.17 +
    2.18 +         sizehints->min_width = window->min_w;
    2.19 +         sizehints->min_height = window->min_h;
    2.20 +         sizehints->flags |= PMinSize;
    2.21 +
    2.22 +         XSetWMNormalHints(display, data->xwindow, sizehints);
    2.23 +
    2.24 +         XFree(sizehints);
    2.25 +
    2.26 +        /* See comment in X11_SetWindowSize. */
    2.27 +        XResizeWindow(display, data->xwindow, window->w, window->h);
    2.28 +        XMoveWindow(display, data->xwindow, window->x, window->y);
    2.29 +        XRaiseWindow(display, data->xwindow);
    2.30 +    }
    2.31 +
    2.32 +    XFlush(display);
    2.33 +}
    2.34 +
    2.35 +void
    2.36 +X11_SetWindowMaximumSize(_THIS, SDL_Window * window)
    2.37 +{
    2.38 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    2.39 +    Display *display = data->videodata->display;
    2.40 +
    2.41 +    if (window->flags & SDL_WINDOW_RESIZABLE) {
    2.42 +         XSizeHints *sizehints = XAllocSizeHints();
    2.43 +         long userhints;
    2.44 +
    2.45 +         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
    2.46 +
    2.47 +         sizehints->max_width = window->max_w;
    2.48 +         sizehints->max_height = window->max_h;
    2.49 +         sizehints->flags |= PMaxSize;
    2.50 +
    2.51 +         XSetWMNormalHints(display, data->xwindow, sizehints);
    2.52 +
    2.53 +         XFree(sizehints);
    2.54 +
    2.55 +        /* See comment in X11_SetWindowSize. */
    2.56 +        XResizeWindow(display, data->xwindow, window->w, window->h);
    2.57 +        XMoveWindow(display, data->xwindow, window->x, window->y);
    2.58 +        XRaiseWindow(display, data->xwindow);
    2.59 +    }
    2.60 +
    2.61 +    XFlush(display);
    2.62 +}
    2.63 +
    2.64 +void
    2.65  X11_SetWindowSize(_THIS, SDL_Window * window)
    2.66  {
    2.67      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    2.68 @@ -760,6 +818,7 @@
    2.69  
    2.70           sizehints->min_width = sizehints->max_width = window->w;
    2.71           sizehints->min_height = sizehints->max_height = window->h;
    2.72 +         sizehints->flags |= PMinSize | PMaxSize;
    2.73  
    2.74           XSetWMNormalHints(display, data->xwindow, sizehints);
    2.75  
     3.1 --- a/src/video/x11/SDL_x11window.h	Fri Aug 09 21:09:49 2013 -0700
     3.2 +++ b/src/video/x11/SDL_x11window.h	Fri Aug 09 23:13:52 2013 -0700
     3.3 @@ -70,6 +70,8 @@
     3.4  extern void X11_SetWindowTitle(_THIS, SDL_Window * window);
     3.5  extern void X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
     3.6  extern void X11_SetWindowPosition(_THIS, SDL_Window * window);
     3.7 +extern void X11_SetWindowMinimumSize(_THIS, SDL_Window * window);
     3.8 +extern void X11_SetWindowMaximumSize(_THIS, SDL_Window * window);
     3.9  extern void X11_SetWindowSize(_THIS, SDL_Window * window);
    3.10  extern void X11_ShowWindow(_THIS, SDL_Window * window);
    3.11  extern void X11_HideWindow(_THIS, SDL_Window * window);