From c5befbba0e705e40d9b33ea37aeb35a6ced895f0 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 4 Dec 2020 00:50:27 +1100 Subject: [PATCH] [client] spice: don't scale mouse if it's 1:1 --- client/src/main.c | 15 ++++++++++++--- client/src/main.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 873e3d05..1b75f9d2 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -82,6 +82,7 @@ static void alignMouseWithHost(); static void lgInit() { state.state = APP_STATE_RUNNING; + state.scale = false; state.scaleX = 1.0f; state.scaleY = 1.0f; state.resizeDone = true; @@ -151,6 +152,10 @@ static void updatePositionInfo() } state.dstRect.valid = true; + state.scale = ( + state.srcSize.y != state.dstRect.h || + state.srcSize.x != state.dstRect.w); + state.scaleX = (float)state.srcSize.y / (float)state.dstRect.h; state.scaleY = (float)state.srcSize.x / (float)state.dstRect.w; } @@ -856,7 +861,7 @@ static void handleMouseMoveEvent(int ex, int ey) state.drawCursor = true; } - if (params.scaleMouseInput && !state.grabMouse) + if (state.scale && params.scaleMouseInput && !state.grabMouse) { state.accX += (float)delta.x * state.scaleX; state.accY += (float)delta.y * state.scaleY; @@ -931,8 +936,12 @@ static void alignMouseWithHost() if (!state.haveCursorPos) return; - const int dx = round((state.curLocalX - state.dstRect.x) * state.scaleX) - state.cursor.x; - const int dy = round((state.curLocalY - state.dstRect.y) * state.scaleY) - state.cursor.y; + const int dx = round((state.curLocalX - state.dstRect.x) * state.scaleX) - + state.cursor.x; + + const int dy = round((state.curLocalY - state.dstRect.y) * state.scaleY) - + state.cursor.y; + spice_mouse_motion(dx, dy); } diff --git a/client/src/main.h b/client/src/main.h index c296aed1..29f01786 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -74,6 +74,7 @@ struct AppState bool cursorInView; bool updateCursor; bool initialCursorSync; + bool scale; float scaleX, scaleY; float accX, accY; int curLastX;