Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 2007 - SDL_SetWindowMinimumSize() not implemented on X11 (t…
Browse files Browse the repository at this point in the history
…hanks Rainer!)
  • Loading branch information
slouken committed Aug 10, 2013
1 parent 499d270 commit 0c80bad
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -362,6 +362,8 @@ X11_CreateDevice(int devindex)
device->SetWindowIcon = X11_SetWindowIcon;
device->SetWindowPosition = X11_SetWindowPosition;
device->SetWindowSize = X11_SetWindowSize;
device->SetWindowMinimumSize = X11_SetWindowMinimumSize;
device->SetWindowMaximumSize = X11_SetWindowMaximumSize;
device->ShowWindow = X11_ShowWindow;
device->HideWindow = X11_HideWindow;
device->RaiseWindow = X11_RaiseWindow;
Expand Down
59 changes: 59 additions & 0 deletions src/video/x11/SDL_x11window.c
Expand Up @@ -741,6 +741,64 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)
XFlush(display);
}

void
X11_SetWindowMinimumSize(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;

if (window->flags & SDL_WINDOW_RESIZABLE) {
XSizeHints *sizehints = XAllocSizeHints();
long userhints;

XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);

sizehints->min_width = window->min_w;
sizehints->min_height = window->min_h;
sizehints->flags |= PMinSize;

XSetWMNormalHints(display, data->xwindow, sizehints);

XFree(sizehints);

/* See comment in X11_SetWindowSize. */
XResizeWindow(display, data->xwindow, window->w, window->h);
XMoveWindow(display, data->xwindow, window->x, window->y);
XRaiseWindow(display, data->xwindow);
}

XFlush(display);
}

void
X11_SetWindowMaximumSize(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;

if (window->flags & SDL_WINDOW_RESIZABLE) {
XSizeHints *sizehints = XAllocSizeHints();
long userhints;

XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);

sizehints->max_width = window->max_w;
sizehints->max_height = window->max_h;
sizehints->flags |= PMaxSize;

XSetWMNormalHints(display, data->xwindow, sizehints);

XFree(sizehints);

/* See comment in X11_SetWindowSize. */
XResizeWindow(display, data->xwindow, window->w, window->h);
XMoveWindow(display, data->xwindow, window->x, window->y);
XRaiseWindow(display, data->xwindow);
}

XFlush(display);
}

void
X11_SetWindowSize(_THIS, SDL_Window * window)
{
Expand All @@ -760,6 +818,7 @@ X11_SetWindowSize(_THIS, SDL_Window * window)

sizehints->min_width = sizehints->max_width = window->w;
sizehints->min_height = sizehints->max_height = window->h;
sizehints->flags |= PMinSize | PMaxSize;

XSetWMNormalHints(display, data->xwindow, sizehints);

Expand Down
2 changes: 2 additions & 0 deletions src/video/x11/SDL_x11window.h
Expand Up @@ -70,6 +70,8 @@ extern char *X11_GetWindowTitle(_THIS, Window xwindow);
extern void X11_SetWindowTitle(_THIS, SDL_Window * window);
extern void X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
extern void X11_SetWindowPosition(_THIS, SDL_Window * window);
extern void X11_SetWindowMinimumSize(_THIS, SDL_Window * window);
extern void X11_SetWindowMaximumSize(_THIS, SDL_Window * window);
extern void X11_SetWindowSize(_THIS, SDL_Window * window);
extern void X11_ShowWindow(_THIS, SDL_Window * window);
extern void X11_HideWindow(_THIS, SDL_Window * window);
Expand Down

0 comments on commit 0c80bad

Please sign in to comment.