Win32: Fix message pump filtering during init

Fixes #886.
This commit is contained in:
Camilla Löwy 2019-03-21 02:05:49 +01:00
parent 8d4fd40b64
commit 5292914ce1

View File

@ -329,10 +329,12 @@ static void createKeyTables(void)
// Creates a dummy window for behind-the-scenes work
//
static HWND createHelperWindow(void)
static GLFWbool createHelperWindow(void)
{
MSG msg;
HWND window = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
_glfw.win32.helperWindowHandle =
CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
_GLFW_WNDCLASSNAME,
L"GLFW message window",
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
@ -340,16 +342,17 @@ static HWND createHelperWindow(void)
NULL, NULL,
GetModuleHandleW(NULL),
NULL);
if (!window)
if (!_glfw.win32.helperWindowHandle)
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"Win32: Failed to create helper window");
return NULL;
return GLFW_FALSE;
}
// HACK: The command to the first ShowWindow call is ignored if the parent
// process passed along a STARTUPINFO, so clear that with a no-op call
ShowWindow(window, SW_HIDE);
ShowWindow(_glfw.win32.helperWindowHandle, SW_HIDE);
// Register for HID device notifications
{
@ -360,7 +363,7 @@ static HWND createHelperWindow(void)
dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
_glfw.win32.deviceNotificationHandle =
RegisterDeviceNotificationW(window,
RegisterDeviceNotificationW(_glfw.win32.helperWindowHandle,
(DEV_BROADCAST_HDR*) &dbi,
DEVICE_NOTIFY_WINDOW_HANDLE);
}
@ -371,7 +374,7 @@ static HWND createHelperWindow(void)
DispatchMessageW(&msg);
}
return window;
return GLFW_TRUE;
}
@ -571,8 +574,7 @@ int _glfwPlatformInit(void)
if (!_glfwRegisterWindowClassWin32())
return GLFW_FALSE;
_glfw.win32.helperWindowHandle = createHelperWindow();
if (!_glfw.win32.helperWindowHandle)
if (!createHelperWindow())
return GLFW_FALSE;
_glfwInitTimerWin32();