mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 19:42:00 +00:00
Win32: Remove unhelpful helper function
This commit is contained in:
parent
c812b9d87c
commit
ab3ea8ac9f
@ -186,53 +186,38 @@ static HICON createIcon(const GLFWimage* image, int xhot, int yhot, GLFWbool ico
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate content area size to full window size according to styles and DPI
|
|
||||||
//
|
|
||||||
static void getFullWindowSize(DWORD style, DWORD exStyle,
|
|
||||||
int contentWidth, int contentHeight,
|
|
||||||
int* fullWidth, int* fullHeight,
|
|
||||||
UINT dpi)
|
|
||||||
{
|
|
||||||
RECT rect = { 0, 0, contentWidth, contentHeight };
|
|
||||||
|
|
||||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
|
||||||
AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
|
|
||||||
else
|
|
||||||
AdjustWindowRectEx(&rect, style, FALSE, exStyle);
|
|
||||||
|
|
||||||
*fullWidth = rect.right - rect.left;
|
|
||||||
*fullHeight = rect.bottom - rect.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enforce the content area aspect ratio based on which edge is being dragged
|
// Enforce the content area aspect ratio based on which edge is being dragged
|
||||||
//
|
//
|
||||||
static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
|
static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
|
||||||
{
|
{
|
||||||
int xoff, yoff;
|
RECT frame = {0};
|
||||||
UINT dpi = USER_DEFAULT_SCREEN_DPI;
|
|
||||||
const float ratio = (float) window->numer / (float) window->denom;
|
const float ratio = (float) window->numer / (float) window->denom;
|
||||||
|
const DWORD style = getWindowStyle(window);
|
||||||
|
const DWORD exStyle = getWindowExStyle(window);
|
||||||
|
|
||||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||||
dpi = GetDpiForWindow(window->win32.handle);
|
{
|
||||||
|
AdjustWindowRectExForDpi(&frame, style, FALSE, exStyle,
|
||||||
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
|
GetDpiForWindow(window->win32.handle));
|
||||||
0, 0, &xoff, &yoff, dpi);
|
}
|
||||||
|
else
|
||||||
|
AdjustWindowRectEx(&frame, style, FALSE, exStyle);
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
area->bottom = area->top + yoff +
|
area->bottom = area->top + (frame.bottom - frame.top) +
|
||||||
(int) ((area->right - area->left - xoff) / ratio);
|
(int) (((area->right - area->left) - (frame.right - frame.left)) / ratio);
|
||||||
}
|
}
|
||||||
else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
|
else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
|
||||||
{
|
{
|
||||||
area->top = area->bottom - yoff -
|
area->top = area->bottom - (frame.bottom - frame.top) -
|
||||||
(int) ((area->right - area->left - xoff) / ratio);
|
(int) (((area->right - area->left) - (frame.right - frame.left)) / ratio);
|
||||||
}
|
}
|
||||||
else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
|
else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
|
||||||
{
|
{
|
||||||
area->right = area->left + xoff +
|
area->right = area->left + (frame.right - frame.left) +
|
||||||
(int) ((area->bottom - area->top - yoff) * ratio);
|
(int) (((area->bottom - area->top) - (frame.bottom - frame.top)) * ratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1082,31 +1067,34 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
|
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
{
|
{
|
||||||
int xoff, yoff;
|
RECT frame = {0};
|
||||||
UINT dpi = USER_DEFAULT_SCREEN_DPI;
|
|
||||||
MINMAXINFO* mmi = (MINMAXINFO*) lParam;
|
MINMAXINFO* mmi = (MINMAXINFO*) lParam;
|
||||||
|
const DWORD style = getWindowStyle(window);
|
||||||
|
const DWORD exStyle = getWindowExStyle(window);
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
if (_glfwIsWindows10Version1607OrGreaterWin32())
|
||||||
dpi = GetDpiForWindow(window->win32.handle);
|
{
|
||||||
|
AdjustWindowRectExForDpi(&frame, style, FALSE, exStyle,
|
||||||
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
|
GetDpiForWindow(window->win32.handle));
|
||||||
0, 0, &xoff, &yoff, dpi);
|
}
|
||||||
|
else
|
||||||
|
AdjustWindowRectEx(&frame, style, FALSE, exStyle);
|
||||||
|
|
||||||
if (window->minwidth != GLFW_DONT_CARE &&
|
if (window->minwidth != GLFW_DONT_CARE &&
|
||||||
window->minheight != GLFW_DONT_CARE)
|
window->minheight != GLFW_DONT_CARE)
|
||||||
{
|
{
|
||||||
mmi->ptMinTrackSize.x = window->minwidth + xoff;
|
mmi->ptMinTrackSize.x = window->minwidth + frame.right - frame.left;
|
||||||
mmi->ptMinTrackSize.y = window->minheight + yoff;
|
mmi->ptMinTrackSize.y = window->minheight + frame.bottom - frame.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->maxwidth != GLFW_DONT_CARE &&
|
if (window->maxwidth != GLFW_DONT_CARE &&
|
||||||
window->maxheight != GLFW_DONT_CARE)
|
window->maxheight != GLFW_DONT_CARE)
|
||||||
{
|
{
|
||||||
mmi->ptMaxTrackSize.x = window->maxwidth + xoff;
|
mmi->ptMaxTrackSize.x = window->maxwidth + frame.right - frame.left;
|
||||||
mmi->ptMaxTrackSize.y = window->maxheight + yoff;
|
mmi->ptMaxTrackSize.y = window->maxheight + frame.bottom - frame.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window->decorated)
|
if (!window->decorated)
|
||||||
@ -1265,7 +1253,7 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
int xpos, ypos, fullWidth, fullHeight;
|
int frameX, frameY, frameWidth, frameHeight;
|
||||||
WCHAR* wideTitle;
|
WCHAR* wideTitle;
|
||||||
DWORD style = getWindowStyle(window);
|
DWORD style = getWindowStyle(window);
|
||||||
DWORD exStyle = getWindowExStyle(window);
|
DWORD exStyle = getWindowExStyle(window);
|
||||||
@ -1311,10 +1299,10 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
// NOTE: This window placement is temporary and approximate, as the
|
// NOTE: This window placement is temporary and approximate, as the
|
||||||
// correct position and size cannot be known until the monitor
|
// correct position and size cannot be known until the monitor
|
||||||
// video mode has been picked in _glfwSetVideoModeWin32
|
// video mode has been picked in _glfwSetVideoModeWin32
|
||||||
xpos = mi.rcMonitor.left;
|
frameX = mi.rcMonitor.left;
|
||||||
ypos = mi.rcMonitor.top;
|
frameY = mi.rcMonitor.top;
|
||||||
fullWidth = mi.rcMonitor.right - mi.rcMonitor.left;
|
frameWidth = mi.rcMonitor.right - mi.rcMonitor.left;
|
||||||
fullHeight = mi.rcMonitor.bottom - mi.rcMonitor.top;
|
frameHeight = mi.rcMonitor.bottom - mi.rcMonitor.top;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1328,17 +1316,17 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
|
if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
|
||||||
{
|
{
|
||||||
xpos = CW_USEDEFAULT;
|
frameX = CW_USEDEFAULT;
|
||||||
ypos = CW_USEDEFAULT;
|
frameY = CW_USEDEFAULT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xpos = wndconfig->xpos + rect.left;
|
frameX = wndconfig->xpos + rect.left;
|
||||||
ypos = wndconfig->ypos + rect.top;
|
frameY = wndconfig->ypos + rect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
fullWidth = rect.right - rect.left;
|
frameWidth = rect.right - rect.left;
|
||||||
fullHeight = rect.bottom - rect.top;
|
frameHeight = rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
|
wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
|
||||||
@ -1349,8 +1337,8 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
MAKEINTATOM(_glfw.win32.mainWindowClass),
|
MAKEINTATOM(_glfw.win32.mainWindowClass),
|
||||||
wideTitle,
|
wideTitle,
|
||||||
style,
|
style,
|
||||||
xpos, ypos,
|
frameX, frameY,
|
||||||
fullWidth, fullHeight,
|
frameWidth, frameHeight,
|
||||||
NULL, // No parent window
|
NULL, // No parent window
|
||||||
NULL, // No window menu
|
NULL, // No window menu
|
||||||
_glfw.win32.instance,
|
_glfw.win32.instance,
|
||||||
|
Loading…
Reference in New Issue
Block a user