user32: DragDetect() should enter its message loop only if the left mouse button is pressed.

There's an application that calls DragDetect() on every WM_MOUSEMOVE
message, and this breaks handling of mouse events. A simple test app
shows that on Windows DragDetect() starts its message loop when left
mouse button is pressed.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2021-10-25 12:41:59 +03:00 committed by Alexandre Julliard
parent 35532015cb
commit ababea0fd7
2 changed files with 25 additions and 2 deletions

View file

@ -12293,6 +12293,22 @@ static void test_cancel_mode(void)
DestroyWindow(hwnd2);
}
static void test_DragDetect(void)
{
POINT pt;
BOOL ret;
ok(!GetCapture(), "got capture window %p\n", GetCapture());
ok(!(GetKeyState( VK_LBUTTON ) & 0x8000), "got VK_LBUTTON\n");
GetCursorPos(&pt);
ret = DragDetect(hwndMain, pt);
ok(!ret, "got %d\n", ret);
ok(!GetCapture(), "got capture window %p\n", GetCapture());
ok(!(GetKeyState( VK_LBUTTON ) & 0x8000), "got VK_LBUTTON\n");
}
START_TEST(win)
{
char **argv;
@ -12461,6 +12477,7 @@ START_TEST(win)
test_other_process_window(argv[0]);
test_SC_SIZE();
test_cancel_mode();
test_DragDetect();
/* add the tests above this line */
if (hhook) UnhookWindowsHookEx(hhook);

View file

@ -3893,9 +3893,15 @@ BOOL WINAPI DragDetect( HWND hWnd, POINT pt )
{
MSG msg;
RECT rect;
WORD wDragWidth = GetSystemMetrics(SM_CXDRAG);
WORD wDragHeight= GetSystemMetrics(SM_CYDRAG);
WORD wDragWidth, wDragHeight;
TRACE( "%p,%s\n", hWnd, wine_dbgstr_point( &pt ) );
if (!(GetKeyState( VK_LBUTTON ) & 0x8000))
return FALSE;
wDragWidth = GetSystemMetrics(SM_CXDRAG);
wDragHeight= GetSystemMetrics(SM_CYDRAG);
SetRect(&rect, pt.x - wDragWidth, pt.y - wDragHeight, pt.x + wDragWidth, pt.y + wDragHeight);
SetCapture(hWnd);