From 2bc767430c460eb69b04e568cc95a17745ce6283 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 4 Jan 2021 12:59:14 +1100 Subject: [PATCH] [client] spice: be more aggressive with window warp for high DPI mice --- client/src/main.c | 18 ++++++++++-------- client/src/main.h | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 6d557e02..dc7d3592 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -837,9 +837,9 @@ static void handleMouseMoveEvent(int ex, int ey) { g_cursor.inView = true; spice_mouse_motion(delta.x, delta.y); - if (ex < 50 || ex > g_state.windowW - 50 || - ey < 50 || ey > g_state.windowH - 50) - warpMouse(g_state.windowW / 2, g_state.windowH / 2); + if (ex < g_state.windowCX - 25 || ex > g_state.windowCX + 25 || + ey < g_state.windowCY - 25 || ey > g_state.windowCY + 25) + warpMouse(g_state.windowCX, g_state.windowCY); } return; @@ -887,9 +887,9 @@ static void handleMouseMoveEvent(int ex, int ey) } else if (inView) { - if (ex < g_state.dstRect.x + 50 || ex > g_state.dstRect.w - 50 || - ey < g_state.dstRect.y + 50 || ey > g_state.dstRect.h - 50) - warpMouse(g_state.windowW / 2, g_state.windowH / 2); + if (ex < g_state.windowCX - 25 || ex > g_state.windowCX + 25 || + ey < g_state.windowCY - 25 || ey > g_state.windowCY + 25) + warpMouse(g_state.windowCX, g_state.windowCY); } if (!inView) @@ -970,8 +970,10 @@ static void handleResizeEvent(unsigned int w, unsigned int h) &g_state.border.w ); - g_state.windowW = w; - g_state.windowH = h; + g_state.windowW = w; + g_state.windowH = h; + g_state.windowCX = w / 2; + g_state.windowCY = h / 2; updatePositionInfo(); } diff --git a/client/src/main.h b/client/src/main.h index 1e36aa47..2e9bfaad 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -49,6 +49,7 @@ struct AppState bool haveSrcSize; SDL_Point windowPos; int windowW, windowH; + int windowCX, windowCY; SDL_Rect border; SDL_Point srcSize; LG_RendererRect dstRect;