From a4a042e90dad87344d32a3349c93933cec426acd Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 16 Jan 2021 20:04:15 +1100 Subject: [PATCH] [client] mouse: force the cursor to the in view state when capturing When capture mode is set if the cursor is not already in the view area we need to force it to the state it would be if it were in view as capture mode overrides all. --- client/src/main.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index 2ccc4f77..914d6ac0 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -81,6 +81,7 @@ struct AppParams params = { 0 }; static void setGrab(bool enable); static void setGrabQuiet(bool enable); +static void setCursorInView(void); static void lgInit(void) { @@ -908,6 +909,16 @@ static void cursorToInt(double ex, double ey, int *x, int *y) *y = (int)ey; } +static void setCursorInView(void) +{ + g_cursor.inView = true; + g_cursor.draw = true; + g_cursor.redraw = true; + + g_cursor.warpState = WARP_STATE_ON; + g_state.ds->grabPointer(); +} + void app_handleMouseGrabbed(double ex, double ey) { int x, y; @@ -1018,12 +1029,7 @@ void app_handleMouseNormal(double ex, double ey) if (g_state.focused) { /* the cursor moved in, enable grab mode */ - g_cursor.inView = true; - g_cursor.draw = true; - g_cursor.redraw = true; - - g_cursor.warpState = WARP_STATE_ON; - g_state.ds->grabPointer(); + setCursorInView(); } struct DoublePoint guest = @@ -1209,6 +1215,9 @@ static void setGrabQuiet(bool enable) if (enable) { + if (!g_cursor.inView) + setCursorInView(); + if (params.grabKeyboard) g_state.ds->grabKeyboard(); }