From fb04dd34fca520cfcac737fc1352a807331ea72d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 3 Jun 2019 21:09:56 +0200 Subject: [PATCH] fixed mouse x/y position (for pointer class global animations) This is required in rare cases where the mouse x/y position calculated from raw values (to apply logical screen size scaling corrections) does not match the final mouse event x/y position -- this may happen because the SDL renderer's viewport position is internally represented as float, but only accessible as integer, which may lead to rounding errors. Setting the mouse x/y position for pointer class global animations from the final mouse event position fixes this problem. --- src/events.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/events.c b/src/events.c index 1e39b67b..085dd9ff 100644 --- a/src/events.c +++ b/src/events.c @@ -103,6 +103,15 @@ static int FilterEvents(const Event *event) cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE && motion->y >= SY && motion->y < SY + SYSIZE); + // set correct mouse x/y position (for pointer class global animations) + // (this is required in rare cases where the mouse x/y position calculated + // from raw values (to apply logical screen size scaling corrections) does + // not match the final mouse event x/y position -- this may happen because + // the SDL renderer's viewport position is internally represented as float, + // but only accessible as integer, which may lead to rounding errors) + gfx.mouse_x = motion->x; + gfx.mouse_y = motion->y; + // do no reset mouse cursor before all pending events have been processed if (gfx.cursor_mode == cursor_mode_last && ((game_status == GAME_MODE_TITLE && -- 2.34.1