[PATCH 0/1] MR11133: win32u: Fix signed coordinate extraction in drag_drop_call.
Xdnd protocol uses 16-bit signed coordinates for mouse position. When the cursor is on a secondary monitor left of the primary, coordinates are negative. LOWORD/HIWORD extract the low 16 bits as unsigned, causing sign loss when assigning to RECT fields. Fix by casting LOWORD/HIWORD result to SHORT before assignment, ensuring proper sign extension on both 32-bit and 64-bit Wine. Test on deepin v25 & UOS V20 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11133
From: chenzhengyong <chenzhengyong@uniontech.com> Xdnd protocol uses 16-bit signed coordinates for mouse position. When the cursor is on a secondary monitor left of the primary, coordinates are negative. LOWORD/HIWORD extract the low 16 bits as unsigned, causing sign loss when assigning to RECT fields. Fix by casting LOWORD/HIWORD result to SHORT before assignment, ensuring proper sign extension on both 32-bit and 64-bit Wine. Signed-off-by: chenzhengyong <chenzhengyong@uniontech.com> --- dlls/win32u/clipboard.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/clipboard.c b/dlls/win32u/clipboard.c index 4667d72e6ef..ec48cd09381 100644 --- a/dlls/win32u/clipboard.c +++ b/dlls/win32u/clipboard.c @@ -37,6 +37,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard); +#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) +#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) + static pthread_mutex_t clipboard_mutex = PTHREAD_MUTEX_INITIALIZER; struct cached_format @@ -755,7 +758,7 @@ LRESULT drag_drop_call( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, void return KeUserModeCallback( NtUserDragDropLeave, 0, 0, &ret_ptr, &ret_len ); case WINE_DRAG_DROP_DRAG: { - RECT rect = {LOWORD(wparam), HIWORD(wparam), LOWORD(wparam), HIWORD(wparam)}; + RECT rect = {GET_X_LPARAM(wparam), GET_Y_LPARAM(wparam), GET_X_LPARAM(wparam), GET_Y_LPARAM(wparam)}; struct drag_drop_drag_params params = { .hwnd = hwnd, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11133
participants (2)
-
chenzhengyong -
zhengyong chen (@chenzhengyong)