diff --git a/client/src/main.c b/client/src/main.c index 15ddd7f0..4b921a0d 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -153,13 +153,13 @@ static void updatePositionInfo() g_state.dstRect.valid = true; g_cursor.scale = ( - g_state.srcSize.y != g_state.dstRect.h || - g_state.srcSize.x != g_state.dstRect.w || - g_state.mouseScalePercent != 100); + g_state.srcSize.y != g_state.dstRect.h || + g_state.srcSize.x != g_state.dstRect.w || + g_cursor.guest.dpiScale != 100); - g_cursor.scaleX = (float)g_state.srcSize.y / (float)g_state.dstRect.h; - g_cursor.scaleY = (float)g_state.srcSize.x / (float)g_state.dstRect.w; - g_state.mouseScale = g_state.mouseScalePercent / 100.0f; + g_cursor.scaleX = (float)g_state.srcSize.y / (float)g_state.dstRect.h; + g_cursor.scaleY = (float)g_state.srcSize.x / (float)g_state.dstRect.w; + g_cursor.dpiScale = g_cursor.guest.dpiScale / 100.0f; } atomic_fetch_add(&g_state.lgrResize, 1); @@ -512,7 +512,7 @@ static int frameThread(void * unused) if (params.autoResize) SDL_SetWindowSize(g_state.window, lgrFormat.width, lgrFormat.height); - g_state.mouseScalePercent = frame->mouseScalePercent; + g_cursor.guest.dpiScale = frame->mouseScalePercent; updatePositionInfo(); } @@ -936,8 +936,8 @@ static void handleMouseMoveEvent(int ex, int ey) if (g_cursor.scale && params.scaleMouseInput && !g_cursor.grab) { - g_cursor.accX += (float)delta.x * g_cursor.scaleX / g_state.mouseScale; - g_cursor.accY += (float)delta.y * g_cursor.scaleY / g_state.mouseScale; + g_cursor.accX += (float)delta.x * g_cursor.scaleX / g_cursor.dpiScale; + g_cursor.accY += (float)delta.y * g_cursor.scaleY / g_cursor.dpiScale; delta.x = floor(g_cursor.accX); delta.y = floor(g_cursor.accY); g_cursor.accX -= delta.x; diff --git a/client/src/main.h b/client/src/main.h index abd61c21..d420472c 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -53,8 +53,6 @@ struct AppState SDL_Rect border; SDL_Point srcSize; LG_RendererRect dstRect; - float mouseScale; - uint32_t mouseScalePercent; const LG_Renderer * lgr; void * lgrData; @@ -176,6 +174,9 @@ struct CursorInfo /* true if the details in this struct are valid */ bool valid; + + /* the DPI scaling of the guest */ + uint32_t dpiScale; }; struct CursorState @@ -201,6 +202,9 @@ struct CursorState /* the amount to scale the X & Y movements by */ float scaleX, scaleY; + /* the dpi scale factor from the guest as a fraction */ + float dpiScale; + /* the error accumulators */ float accX, accY; @@ -213,6 +217,7 @@ struct CursorState /* the mouse warp state and target */ enum WarpState warpState; + bool warpExit; unsigned long warpSerial; SDL_Point warpTo;