From 3ac178a3058c0e3011b1a8fea4df4564c201b7ea Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 8 Jan 2021 20:55:48 +1100 Subject: [PATCH] [client] spice: when in autoCapture limit the exit delta Rapid movements in games can cause large detas that may cause the client to allow the mouse to exit when this is not desired. This change attempts to limit this by ignoring movements large movements when using this mode. --- client/src/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 57f6035f..a48e05a7 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -886,7 +886,7 @@ static void handleMouseNormal(double ex, double ey) ey *= g_cursor.scale.y / g_cursor.dpiScale; } - bool enter = false; + bool testExit = true; /* if the cursor was outside the viewport, check if it moved in */ if (!g_cursor.inView) @@ -927,8 +927,9 @@ static void handleMouseNormal(double ex, double ey) ex += guest.x - (g_cursor.guest.x + g_cursor.guest.hx); ey += guest.y - (g_cursor.guest.y + g_cursor.guest.hy); - /* stop the below code from looking for an exit */ - enter = true; + /* don't test for an exit as we just entered, we can get into a enter/exit + * loop otherwise */ + testExit = false; } else { @@ -937,6 +938,11 @@ static void handleMouseNormal(double ex, double ey) } } + /* if we are in "autoCapture" and the delta was large don't test for exit */ + if (params.autoCapture && + (abs(ex) > 100.0 / g_cursor.scale.x || abs(ey) > 100.0 / g_cursor.scale.y)) + testExit = false; + /* translate the guests position to our coordinate space */ struct DoublePoint local = { @@ -945,7 +951,7 @@ static void handleMouseNormal(double ex, double ey) }; /* check if the move would push the cursor outside the guest's viewport */ - if (!enter && ( + if (testExit && ( local.x + ex < 0.0 || local.y + ey < 0.0 || local.x + ex >= g_state.dstRect.w ||