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

Commit

Permalink
SetWindowMinimumSize Windows implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
stopiccot committed Nov 18, 2012
1 parent 4b5e221 commit c4df183
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/video/windows/SDL_windowsevents.c
Expand Up @@ -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);
Expand All @@ -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.
Expand All @@ -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;
Expand Down

0 comments on commit c4df183

Please sign in to comment.