From: Etaash Mathamsetty <etaash.mathamsetty@gmail.com> --- dlls/winewayland.drv/wayland_pointer.c | 20 ++++++++++++-------- dlls/winewayland.drv/waylanddrv.h | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/winewayland.drv/wayland_pointer.c b/dlls/winewayland.drv/wayland_pointer.c index 7f3124e4bd8..1cce6c09727 100644 --- a/dlls/winewayland.drv/wayland_pointer.c +++ b/dlls/winewayland.drv/wayland_pointer.c @@ -197,6 +197,8 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, pthread_mutex_lock(&pointer->mutex); pointer->focused_hwnd = hwnd; pointer->enter_serial = serial; + pointer->accum_x = pointer->accum_y = 0; + pointer->accum_raw_x = pointer->accum_raw_y = 0; pthread_mutex_unlock(&pointer->mutex); /* The cursor is undefined at every enter, so we set it again with @@ -360,8 +362,7 @@ static void relative_pointer_v1_relative_motion(void *private, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_unaccel, wl_fixed_t dy_unaccel) { - const POINT raw_pos = { .x = wl_fixed_to_double(dx_unaccel), .y = wl_fixed_to_double(dy_unaccel) }; - struct raw_mouse raw = { .count = 1, .data = { raw_pos } }; + struct raw_mouse raw = { .count = 1 }; INPUT input = { .type = INPUT_MOUSE, .mi.dwFlags = MOUSEEVENTF_MOVE }; HWND hwnd; struct wayland_win_data *data; @@ -379,23 +380,26 @@ static void relative_pointer_v1_relative_motion(void *private, pthread_mutex_lock(&pointer->mutex); + pointer->accum_raw_x += wl_fixed_to_double(dx_unaccel); + pointer->accum_raw_y += wl_fixed_to_double(dy_unaccel); + + pointer->accum_raw_x -= (raw.data[0].x = round(pointer->accum_raw_x)); + pointer->accum_raw_y -= (raw.data[0].y = round(pointer->accum_raw_y)); + if (pointer->relative_mode) { pointer->accum_x += screen_x; pointer->accum_y += screen_y; - input.mi.dx = round(pointer->accum_x); - input.mi.dy = round(pointer->accum_y); - - pointer->accum_x -= input.mi.dx; - pointer->accum_y -= input.mi.dy; + pointer->accum_x -= (input.mi.dx = round(pointer->accum_x)); + pointer->accum_y -= (input.mi.dy = round(pointer->accum_y)); } pthread_mutex_unlock(&pointer->mutex); TRACE("hwnd=%p wayland_dxdy=%.2f,%.2f accum_dxdy=%d,%d wayland_raw=%.2f,%.2f raw_dxdy=%d,%d\n", hwnd, wl_fixed_to_double(dx), wl_fixed_to_double(dy), input.mi.dx, input.mi.dy, - wl_fixed_to_double(dx_unaccel), wl_fixed_to_double(dy_unaccel), raw_pos.x, raw_pos.y); + wl_fixed_to_double(dx_unaccel), wl_fixed_to_double(dy_unaccel), raw.data[0].x, raw.data[0].y); NtUserSendHardwareInput(hwnd, SEND_HWMSG_RAWINPUT, &input, (LPARAM)&raw); } diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index fa590eecd13..c2630fc89c1 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -118,8 +118,8 @@ struct wayland_pointer uint32_t enter_serial; uint32_t button_serial; struct wayland_cursor cursor; - double accum_x; - double accum_y; + double accum_x; double accum_y; + double accum_raw_x; double accum_raw_y; pthread_mutex_t mutex; }; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11357