From 2bfcfa36df4d21b1e24349316d1b43439ded4fa1 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 20 Jan 2021 00:23:24 +1100 Subject: [PATCH] [client] all: fix regression with input disable toggle --- client/displayservers/X11/x11.c | 3 --- client/src/main.c | 31 ++++++++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index b32cf2e8..04fee7c1 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -312,9 +312,6 @@ static bool x11EventFilter(SDL_Event * event) if (cookie->extension != x11.xinputOp) return false; - if (!app_inputEnabled()) - return true; - switch(cookie->evtype) { case XI_RawKeyPress: diff --git a/client/src/main.c b/client/src/main.c index 8a110136..9991bf79 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1005,8 +1005,7 @@ static void setCursorInView(bool enable) if (warpSupport) g_state.ds->ungrabPointer(); - if (!g_cursor.grab) - g_cursor.realign = true; + setGrabQuiet(false); } g_cursor.warpState = WARP_STATE_ON; @@ -1014,12 +1013,14 @@ static void setCursorInView(bool enable) void app_handleMouseGrabbed(double ex, double ey) { - int x, y; - /* do not pass mouse events to the guest if we do not have focus */ if (!g_state.focused) return; + if (!app_inputEnabled()) + return; + + int x, y; if (params.rawMouse && !g_cursor.useScale) { /* raw unscaled input are always round numbers */ @@ -1254,6 +1255,9 @@ void app_handleMouseNormal(double ex, double ey) if (!g_cursor.guest.valid) return; + if (!app_inputEnabled()) + return; + /* scale the movement to the guest */ if (g_cursor.useScale && params.scaleMouseInput) { @@ -1397,6 +1401,9 @@ void app_handleMouseBasic() if (!g_state.focused) return; + if (!app_inputEnabled()) + return; + const bool inView = g_cursor.pos.x >= g_state.dstRect.x && g_cursor.pos.x < g_state.dstRect.x + g_state.dstRect.w && @@ -1530,6 +1537,7 @@ static void setGrabQuiet(bool enable) if (enable) { setCursorInView(true); + g_state.ignoreInput = false; if (params.grabKeyboard) g_state.ds->grabKeyboard(); @@ -1548,14 +1556,11 @@ static void setGrabQuiet(bool enable) if (!warpSupport) g_state.ds->ungrabPointer(); + + // if exiting capture when input on capture only, we want to show the cursor + if (params.captureInputOnly || !params.hideMouse) + alignToGuest(); } - - // if exiting capture when input on capture only, we want to show the cursor - if (!enable && (params.captureInputOnly || !params.hideMouse)) - alignToGuest(); - - if (g_cursor.grab) - setCursorInView(true); } int eventFilter(void * userdata, SDL_Event * event) @@ -1668,6 +1673,10 @@ static void toggle_rotate(uint32_t scancode, void * opaque) static void toggle_input(uint32_t scancode, void * opaque) { g_state.ignoreInput = !g_state.ignoreInput; + + if (g_state.ignoreInput) + setCursorInView(false); + app_alert( LG_ALERT_INFO, g_state.ignoreInput ? "Input Disabled" : "Input Enabled"