From 698ab75a597cc67174aff04949478698999082c6 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Wed, 13 Nov 2024 16:24:07 -0600 Subject: [PATCH] server: Don't update cursor pos in set_window_pos() if window wasn't moved. Fixes a regression introduced by commit db9a4bc66a5ff550a0a25899b6646117f66c50df. --- dlls/user32/tests/msg.c | 12 ++++++++++++ server/window.c | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 590f50aa6b7..45e91af517d 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -6187,6 +6187,13 @@ static const struct message WmMove_mouse[] = { { 0 } }; +static const struct message WmMove_mouse2[] = { + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE }, + { WM_GETTEXT, sent|optional }, + { WM_GETMINMAXINFO, sent|defwinproc }, + { 0 } +}; + static void test_setwindowpos(void) { HWND hwnd; @@ -6253,6 +6260,11 @@ static void test_setwindowpos(void) ok(res == TRUE, "SetWindowPos expected TRUE, got %Id.\n", res); flush_events(); ok_sequence(WmMove_mouse, "MouseMove", FALSE); + /* if the window and client rects were not changed WM_MOUSEMOVE is not sent. */ + res = SetWindowPos( hwnd, 0, 205, 205, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE ); + ok(res == TRUE, "SetWindowPos expected TRUE, got %Id.\n", res); + flush_events(); + ok_sequence(WmMove_mouse2, "MouseMove2", FALSE); ignore_mouse_messages = TRUE; DestroyWindow(hwnd); diff --git a/server/window.c b/server/window.c index 46377513719..8a55c66dea6 100644 --- a/server/window.c +++ b/server/window.c @@ -2488,7 +2488,7 @@ DECL_HANDLER(get_window_tree) /* set the position and Z order of a window */ DECL_HANDLER(set_window_pos) { - rectangle_t window_rect, client_rect, visible_rect, surface_rect, valid_rect; + rectangle_t window_rect, client_rect, visible_rect, surface_rect, valid_rect, old_window, old_client; const rectangle_t *extra_rects = get_req_data(); struct window *previous = NULL; struct window *top, *win = get_window( req->handle ); @@ -2558,9 +2558,13 @@ DECL_HANDLER(set_window_pos) win->monitor_dpi = req->monitor_dpi; old_style = win->style; + old_window = win->window_rect; + old_client = win->client_rect; set_window_pos( win, previous, flags, &window_rect, &client_rect, &visible_rect, &surface_rect, &valid_rect ); - if (win->style & old_style & WS_VISIBLE) update_cursor_pos( win->desktop ); + if ((win->style & old_style & WS_VISIBLE) && (memcmp( &old_client, &win->client_rect, sizeof(old_client) ) + || memcmp( &old_window, &win->window_rect, sizeof(old_window) ))) + update_cursor_pos( win->desktop ); if (win->paint_flags & SET_WINPOS_LAYERED_WINDOW) validate_whole_window( win );