Workaround for #1335 (glfwCreateWindow crash)

GetDpiForWindow() doesn't exist prior to Win10, so this
falls back on the previous behavior (USER_DEFAULT_SCREEN_DPI)
if GetDpiForWindow isn't available & avoids the crash.

Feel free to edit/replace with a proper fix!
This commit is contained in:
Cort 2018-10-20 22:46:12 -07:00
parent 5afcd0981b
commit 308a8cd5d3

View File

@ -210,10 +210,12 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
{
int xoff, yoff;
const float ratio = (float) window->numer / (float) window->denom;
UINT dpi = _glfwIsWindows10AnniversaryUpdateOrGreaterWin32()
? GetDpiForWindow(window->win32.handle)
: USER_DEFAULT_SCREEN_DPI;
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
0, 0, &xoff, &yoff,
GetDpiForWindow(window->win32.handle));
0, 0, &xoff, &yoff, dpi);
if (edge == WMSZ_LEFT || edge == WMSZ_BOTTOMLEFT ||
edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
@ -1002,13 +1004,15 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
{
int xoff, yoff;
MINMAXINFO* mmi = (MINMAXINFO*) lParam;
UINT dpi = _glfwIsWindows10AnniversaryUpdateOrGreaterWin32()
? GetDpiForWindow(window->win32.handle)
: USER_DEFAULT_SCREEN_DPI;
if (window->monitor)
break;
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
0, 0, &xoff, &yoff,
GetDpiForWindow(window->win32.handle));
0, 0, &xoff, &yoff, dpi);
if (window->minwidth != GLFW_DONT_CARE &&
window->minheight != GLFW_DONT_CARE)
@ -2186,3 +2190,4 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
return window->win32.handle;
}