[client] spice: allow mouse smoothing in capture but only if not RAW

This commit is contained in:
Geoffrey McRae 2021-01-09 14:55:20 +11:00
parent 1a4ac4c109
commit 318759f54d
2 changed files with 18 additions and 17 deletions

View File

@ -285,7 +285,7 @@ static struct Option options[] =
{ {
.module = "input", .module = "input",
.name = "mouseSmoothing", .name = "mouseSmoothing",
.description = "Apply simple mouse smoothing when not in capture mode (helps reduce aliasing)", .description = "Apply simple mouse smoothing when rawMouse is not in use (helps reduce aliasing)",
.type = OPTION_TYPE_BOOL, .type = OPTION_TYPE_BOOL,
.value.x_bool = true, .value.x_bool = true,
}, },

View File

@ -866,6 +866,14 @@ static bool isValidCursorLocation(int x, int y)
static void cursorToInt(double ex, double ey, int *x, int *y) static void cursorToInt(double ex, double ey, int *x, int *y)
{ {
/* only smooth if enabled and not using raw mode */
if (params.mouseSmoothing && !(g_cursor.grab && params.rawMouse))
{
static struct DoublePoint last = { 0 };
ex = last.x = (last.x + ex) / 2.0;
ey = last.y = (last.y + ey) / 2.0;
}
/* convert to int accumulating the fractional error */ /* convert to int accumulating the fractional error */
g_cursor.acc.x += ex; g_cursor.acc.x += ex;
g_cursor.acc.y += ey; g_cursor.acc.y += ey;
@ -879,17 +887,18 @@ static void handleMouseGrabbed(double ex, double ey)
{ {
int x, y; int x, y;
/* apply sensitivity */ if (params.rawMouse && !g_cursor.useScale)
if (g_cursor.sens != 0)
{ {
ex = (ex / 10.0) * (g_cursor.sens + 10); /* raw unscaled input are always round numbers */
ey = (ey / 10.0) * (g_cursor.sens + 10); x = floor(ex);
cursorToInt(ex, ey, &x, &y); y = floor(ey);
} }
else else
{ {
x = floor(ex); /* apply sensitivity */
y = floor(ey); ex = (ex / 10.0) * (g_cursor.sens + 10);
ey = (ey / 10.0) * (g_cursor.sens + 10);
cursorToInt(ex, ey, &x, &y);
} }
if (x == 0 && y == 0) if (x == 0 && y == 0)
@ -1029,15 +1038,7 @@ static void handleMouseNormal(double ex, double ey)
} }
int x, y; int x, y;
if (params.mouseSmoothing) cursorToInt(ex, ey, &x, &y);
{
static struct DoublePoint last = { 0 };
last.x = (last.x + ex) / 2.0;
last.y = (last.y + ey) / 2.0;
cursorToInt(last.x, last.y, &x, &y);
}
else
cursorToInt(ex, ey, &x, &y);
if (x == 0 && y == 0) if (x == 0 && y == 0)
return; return;