[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.
This commit is contained in:
Geoffrey McRae 2021-01-08 20:55:48 +11:00
parent 40c3c38681
commit 3ac178a305

View File

@ -886,7 +886,7 @@ static void handleMouseNormal(double ex, double ey)
ey *= g_cursor.scale.y / g_cursor.dpiScale; 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 the cursor was outside the viewport, check if it moved in */
if (!g_cursor.inView) 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); ex += guest.x - (g_cursor.guest.x + g_cursor.guest.hx);
ey += guest.y - (g_cursor.guest.y + g_cursor.guest.hy); ey += guest.y - (g_cursor.guest.y + g_cursor.guest.hy);
/* stop the below code from looking for an exit */ /* don't test for an exit as we just entered, we can get into a enter/exit
enter = true; * loop otherwise */
testExit = false;
} }
else 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 */ /* translate the guests position to our coordinate space */
struct DoublePoint local = 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 */ /* check if the move would push the cursor outside the guest's viewport */
if (!enter && ( if (testExit && (
local.x + ex < 0.0 || local.x + ex < 0.0 ||
local.y + ey < 0.0 || local.y + ey < 0.0 ||
local.x + ex >= g_state.dstRect.w || local.x + ex >= g_state.dstRect.w ||