Skip to content

Commit

Permalink
win32u: Only send mouse input in ReleaseCapture() when a window is ca…
Browse files Browse the repository at this point in the history
…ptured.

Fix a regression from "bb496ea8 - server: Always queue mouse messages delivered to another window."

Fix ETHER VAPOR Remaster (214570) launches to black screen when the cursor is in the game window.

The game calls ReleaseCapture() when handling WM_MOUSEMOVE. After bb496ea, WM_MOUSEMOVE is always
queued because the message window is NULL. So ReleaseCapture() ends up queuing another WM_MOUSEMOVE.
So the game ends up handling infinite WM_MOUSEMOVE messages at startup and is not able to do anything.

(cherry picked from commit 818d9a1)
CW-Bug-Id: #23531
  • Loading branch information
zzhiyi authored and ivyl committed May 3, 2024
1 parent 1e2448a commit e8172fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions dlls/user32/tests/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -13112,7 +13112,6 @@ static void test_ReleaseCapture(void)
ok(ret, "ReleaseCapture failed, error %#lx.\n", GetLastError());
flush_events(TRUE);
do_release_capture = FALSE;
todo_wine
ok(wm_mousemove_count < 10, "Got too many WM_MOUSEMOVE.\n");

/* Test that ReleaseCapture() should send a WM_MOUSEMOVE if a window is captured */
Expand All @@ -13128,7 +13127,6 @@ static void test_ReleaseCapture(void)
ret = ReleaseCapture();
ok(ret, "ReleaseCapture failed, error %#lx.\n", GetLastError());
flush_events(TRUE);
todo_wine
ok(wm_mousemove_count == 0, "Got WM_MOUSEMOVE.\n");

ret = SetCursorPos(pt.x, pt.y);
Expand Down
7 changes: 5 additions & 2 deletions dlls/win32u/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -1803,10 +1803,13 @@ HWND WINAPI NtUserSetCapture( HWND hwnd )
*/
BOOL release_capture(void)
{
BOOL ret = set_capture_window( 0, 0, NULL );
HWND previous = NULL;
BOOL ret;

ret = set_capture_window( 0, 0, &previous );

/* Somebody may have missed some mouse movements */
if (ret)
if (ret && previous)
{
INPUT input = { .type = INPUT_MOUSE };
input.mi.dwFlags = MOUSEEVENTF_MOVE;
Expand Down

0 comments on commit e8172fc

Please sign in to comment.