Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
SetWindowMinimumSize Windows implementation
  • Loading branch information
stopiccot committed Nov 18, 2012
1 parent 4b5e221 commit c4df18392ec276ec1bc0e6b5adeedd7be326afc4
Showing with 22 additions and 14 deletions.
  1. +22 −14 src/video/windows/SDL_windowsevents.c
@@ -426,16 +426,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT size;
int x, y;
int w, h;
int min_w, min_h;
int style;
BOOL menu;

/* If we allow resizing, let the resize happen naturally */
if(SDL_IsShapedWindow(data->window))
if (SDL_IsShapedWindow(data->window))
Win32_ResizeWindowShape(data->window);
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
returnCode = 0;
break;
}

/* Get the current position of our window */
GetWindowRect(hwnd, &size);
@@ -444,12 +441,18 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

/* Calculate current size of our window */
SDL_GetWindowSize(data->window, &w, &h);
SDL_GetWindowMinimumSize(data->window, &min_w, &min_h);

/* Store in min_w and min_h difference between current size and minimal
size so we don't need to call AdjustWindowRectEx twice */
min_w -= w;
min_h -= h;

size.top = 0;
size.left = 0;
size.bottom = h;
size.right = w;


style = GetWindowLong(hwnd, GWL_STYLE);
/* DJM - according to the docs for GetMenu(), the
return value is undefined if hwnd is a child window.
@@ -463,14 +466,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

/* Fix our size to the current size */
info = (MINMAXINFO *) lParam;
info->ptMaxSize.x = w;
info->ptMaxSize.y = h;
info->ptMaxPosition.x = x;
info->ptMaxPosition.y = y;
info->ptMinTrackSize.x = w;
info->ptMinTrackSize.y = h;
info->ptMaxTrackSize.x = w;
info->ptMaxTrackSize.y = h;
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
info->ptMinTrackSize.x = w + min_w;
info->ptMinTrackSize.y = h + min_h;
} else {
info->ptMaxSize.x = w;
info->ptMaxSize.y = h;
info->ptMaxPosition.x = x;
info->ptMaxPosition.y = y;
info->ptMinTrackSize.x = w;
info->ptMinTrackSize.y = h;
info->ptMaxTrackSize.x = w;
info->ptMaxTrackSize.y = h;
}
}
returnCode = 0;
break;

0 comments on commit c4df183

Please sign in to comment.