From 80d911f040b68fdd33afb5ec149f8016b4698cc6 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 4 Dec 2020 20:04:06 +1100 Subject: [PATCH] [client] spice: fix mouse exiting when the window is letterboxed/padded --- client/src/main.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 2d98b88e..790a41ca 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -899,15 +899,9 @@ static void handleMouseMoveEvent(int ex, int ey) .y = (float)(state.cursor.y + delta.y) / state.scaleY }; - const SDL_Point pos = { - .x = state.windowPos.x + state.border.x + newPos.x, - .y = state.windowPos.y + state.border.y + newPos.y - }; - /* check if the movement would exit the window */ - if ((newPos.x < 0 || newPos.x >= state.dstRect.w || - newPos.y < 0 || newPos.y >= state.dstRect.h) && - isValidCursorLocation(pos.x, pos.y)) + if (newPos.x < 0 || newPos.x >= state.dstRect.w || + newPos.y < 0 || newPos.y >= state.dstRect.h) { /* determine where to move the cursor to taking into account any borders * if the aspect ratio is not being forced */ @@ -934,10 +928,15 @@ static void handleMouseMoveEvent(int ex, int ey) ny = newPos.y + state.dstRect.y * 2; } - /* put the mouse where it should be and disable warp */ - state.warpState = WARP_STATE_WIN_EXIT; - warpMouse(nx, ny); - return; + if (isValidCursorLocation( + state.windowPos.x + state.border.x + nx, + state.windowPos.y + state.border.y + ny)) + { + /* put the mouse where it should be and disable warp */ + state.warpState = WARP_STATE_WIN_EXIT; + warpMouse(nx, ny); + return; + } } }