From: Giovanni Mascellani gmascellani@codeweavers.com
libOVR brings a message window topmost claiming that this way it receives WM_DEVICECHANGE faster. Currently, in Wine, this causes a WM_KILLFOCUS to be sent to the actual topmost window, which in turn causes "Shantae: Risky's Revenge" to minimize. The effect is that the game automatically minimizes as soon as it is launched, which is incorrect.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/user32/tests/win.c | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 3727efb1b41..c268a837214 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -8899,6 +8899,54 @@ static void test_hwnd_message(void) DestroyWindow(hwnd); }
+static BOOL message_window_topmost_destroying = FALSE; + +static LRESULT WINAPI message_window_topmost_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if (msg == WM_KILLFOCUS && !message_window_topmost_destroying) + todo_wine ok(msg != WM_KILLFOCUS, "WM_KILLFOCUS message was delivered\n"); + + return DefWindowProcW(hwnd, msg, wparam, lparam); +} + +static void test_message_window_topmost(void) +{ + WNDCLASSW cls = { 0 }; + ATOM atom; + HWND hwnd, hwnd_msg; + MSG msg; + + cls.lpfnWndProc = message_window_topmost_proc; + cls.hInstance = GetModuleHandleW(NULL); + cls.lpszClassName = L"test_message_window_topmost"; + atom = RegisterClassW(&cls); + ok(!!atom, "Cannot register window class\n"); + + hwnd = CreateWindowW(L"test_message_window_topmost", L"main window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandleW(NULL), NULL); + ok(!!hwnd, "Cannot create main window\n"); + + hwnd_msg = CreateWindowW(L"test_message_window_topmost", L"message window", 0, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_MESSAGE, NULL, GetModuleHandleW(NULL), NULL); + ok(!!hwnd_msg, "Cannot create message window\n"); + + SetWindowPos(hwnd_msg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + + while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + + message_window_topmost_destroying = TRUE; + + ok(DestroyWindow(hwnd_msg), "Cannot destroy main window\n"); + ok(DestroyWindow(hwnd), "Cannot destroy message window\n"); + + ok(UnregisterClassW(L"test_message_window_topmost", GetModuleHandleW(NULL)), "Cannot unregister class\n"); +} + + static void test_layered_window(void) { HWND hwnd, child; @@ -13089,6 +13137,7 @@ START_TEST(win) test_thick_child_size(hwndMain); test_fullscreen(); test_hwnd_message(); + test_message_window_topmost(); test_nonclient_area(hwndMain); test_params(); test_GetWindowModuleFileName();