From edb473cf468c781841bfbbfbd1dea337f32ba917 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Fri, 15 Apr 2022 15:03:28 -0400 Subject: [PATCH] video: Wayland: Always round scaled pointer coordinates down Rounding up can cause the pointer coordinates to exceed the window boundaries at the right and bottom edges. --- src/video/wayland/SDL_waylandevents.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index b81c9db4a..ba85c1d68 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -391,8 +391,8 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, if (input->pointer_focus) { const float sx_f = (float)wl_fixed_to_double(sx_w); const float sy_f = (float)wl_fixed_to_double(sy_w); - const int sx = (int)SDL_lroundf(sx_f * window->pointer_scale_x); - const int sy = (int)SDL_lroundf(sy_f * window->pointer_scale_y); + const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x); + const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y); SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy); } } @@ -1826,8 +1826,8 @@ tablet_tool_handle_motion(void* data, struct zwp_tablet_tool_v2* tool, wl_fixed_ if (input->tool_focus) { const float sx_f = (float)wl_fixed_to_double(sx_w); const float sy_f = (float)wl_fixed_to_double(sy_w); - const int sx = (int)SDL_lroundf(sx_f * window->pointer_scale_x); - const int sy = (int)SDL_lroundf(sy_f * window->pointer_scale_y); + const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x); + const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y); SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy); } }