Clarify Win32 getWindowFullSize

This commit is contained in:
Camilla Berglund 2015-10-18 17:01:14 +02:00
parent d84772d620
commit 9dd3b8101a

View File

@ -69,15 +69,14 @@ static DWORD getWindowExStyle(const _GLFWwindow* window)
return style; return style;
} }
// Translate client window size to full window size (including window borders) // Translate client window size to full window size according to styles
// //
static void getFullWindowSize(_GLFWwindow* window, static void getFullWindowSize(DWORD style, DWORD exStyle,
int clientWidth, int clientHeight, int clientWidth, int clientHeight,
int* fullWidth, int* fullHeight) int* fullWidth, int* fullHeight)
{ {
RECT rect = { 0, 0, clientWidth, clientHeight }; RECT rect = { 0, 0, clientWidth, clientHeight };
AdjustWindowRectEx(&rect, getWindowStyle(window), AdjustWindowRectEx(&rect, style, FALSE, exStyle);
FALSE, getWindowExStyle(window));
*fullWidth = rect.right - rect.left; *fullWidth = rect.right - rect.left;
*fullHeight = rect.bottom - rect.top; *fullHeight = rect.bottom - rect.top;
} }
@ -90,7 +89,8 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
const float ratio = (float) window->win32.numer / const float ratio = (float) window->win32.numer /
(float) window->win32.denom; (float) window->win32.denom;
getFullWindowSize(window, 0, 0, &xoff, &yoff); getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
0, 0, &xoff, &yoff);
if (edge == WMSZ_LEFT || edge == WMSZ_BOTTOMLEFT || if (edge == WMSZ_LEFT || edge == WMSZ_BOTTOMLEFT ||
edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT) edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
@ -560,7 +560,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
{ {
int xoff, yoff; int xoff, yoff;
MINMAXINFO* mmi = (MINMAXINFO*) lParam; MINMAXINFO* mmi = (MINMAXINFO*) lParam;
getFullWindowSize(window, 0, 0, &xoff, &yoff); getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
0, 0, &xoff, &yoff);
if (window->win32.minwidth != GLFW_DONT_CARE && if (window->win32.minwidth != GLFW_DONT_CARE &&
window->win32.minheight != GLFW_DONT_CARE) window->win32.minheight != GLFW_DONT_CARE)
@ -685,7 +686,7 @@ static GLFWbool createWindow(_GLFWwindow* window,
xpos = CW_USEDEFAULT; xpos = CW_USEDEFAULT;
ypos = CW_USEDEFAULT; ypos = CW_USEDEFAULT;
getFullWindowSize(window, getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
wndconfig->width, wndconfig->height, wndconfig->width, wndconfig->height,
&fullWidth, &fullHeight); &fullWidth, &fullHeight);
} }
@ -934,7 +935,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
else else
{ {
int fullWidth, fullHeight; int fullWidth, fullHeight;
getFullWindowSize(window, width, height, &fullWidth, &fullHeight); getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
width, height, &fullWidth, &fullHeight);
SetWindowPos(window->win32.handle, HWND_TOP, SetWindowPos(window->win32.handle, HWND_TOP,
0, 0, fullWidth, fullHeight, 0, 0, fullWidth, fullHeight,