From 38e1904b71afd56b4cae12792f5e2b462811ccdc Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 13 Aug 2023 17:59:19 +0200 Subject: [PATCH] When checking for mouse movement, use ceiling, not floor, if the coordinates are negative. --- src/device/mouse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/device/mouse.c b/src/device/mouse.c index 566fb7a3b..e3908c548 100644 --- a/src/device/mouse.c +++ b/src/device/mouse.c @@ -348,9 +348,15 @@ mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y, int mouse_moved(void) { + double scaled_x = mouse_scale_coord_x(atomic_load(&mouse_x), 1); + double scaled_y = mouse_scale_coord_y(atomic_load(&mouse_y), 1); + + scaled_x = (scaled_x >= 0.0) ? floor(scaled_x) : ceil(scaled_x); + scaled_y = (scaled_y >= 0.0) ? floor(scaled_y) : ceil(scaled_y); + /* Convert them to integer so we treat < 1.0 and > -1.0 as 0. */ - int ret = (((int) floor(mouse_scale_coord_x(atomic_load(&mouse_x), 1)) != 0) || - ((int) floor(mouse_scale_coord_x(atomic_load(&mouse_y), 1)) != 0)); + int ret = ((((int) scaled_x) != 0) || + (((int) scaled_y) != 0)); return ret; }