SetWindowMinimumSize Windows implementation

This commit is contained in:
stopiccot 2012-11-19 00:39:19 +03:00
parent de7aeffa50
commit ea4e328e39

View file

@ -426,16 +426,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT size; RECT size;
int x, y; int x, y;
int w, h; int w, h;
int min_w, min_h;
int style; int style;
BOOL menu; BOOL menu;
/* If we allow resizing, let the resize happen naturally */ /* If we allow resizing, let the resize happen naturally */
if(SDL_IsShapedWindow(data->window)) if (SDL_IsShapedWindow(data->window))
Win32_ResizeWindowShape(data->window); Win32_ResizeWindowShape(data->window);
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
returnCode = 0;
break;
}
/* Get the current position of our window */ /* Get the current position of our window */
GetWindowRect(hwnd, &size); GetWindowRect(hwnd, &size);
@ -444,12 +441,18 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Calculate current size of our window */ /* Calculate current size of our window */
SDL_GetWindowSize(data->window, &w, &h); 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.top = 0;
size.left = 0; size.left = 0;
size.bottom = h; size.bottom = h;
size.right = w; size.right = w;
style = GetWindowLong(hwnd, GWL_STYLE); style = GetWindowLong(hwnd, GWL_STYLE);
/* DJM - according to the docs for GetMenu(), the /* DJM - according to the docs for GetMenu(), the
return value is undefined if hwnd is a child window. return value is undefined if hwnd is a child window.
@ -463,6 +466,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Fix our size to the current size */ /* Fix our size to the current size */
info = (MINMAXINFO *) lParam; info = (MINMAXINFO *) lParam;
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.x = w;
info->ptMaxSize.y = h; info->ptMaxSize.y = h;
info->ptMaxPosition.x = x; info->ptMaxPosition.x = x;
@ -472,6 +479,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
info->ptMaxTrackSize.x = w; info->ptMaxTrackSize.x = w;
info->ptMaxTrackSize.y = h; info->ptMaxTrackSize.y = h;
} }
}
returnCode = 0; returnCode = 0;
break; break;
#endif /* WM_GETMINMAXINFO */ #endif /* WM_GETMINMAXINFO */