From 9e2cfb910676d17608b6d5af1dadf8bc23eabf6b Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 23 Feb 2021 20:19:35 +1100 Subject: [PATCH] [client] core: fix reversed logic and document the rationale for it During the refactor/rebase period with B3-next the conditional was accidentally reversed. This would cause the cursor to be ungrabbed simply when toggling capture mode instead of waiting for the cursor to exit the window. --- client/src/core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/core.c b/client/src/core.c index 2469f04e..c777684d 100644 --- a/client/src/core.c +++ b/client/src/core.c @@ -134,10 +134,20 @@ void core_setGrabQuiet(bool enable) g_state.ds->ungrabKeyboard(); } - if (warpSupport != LG_DS_WARP_NONE || g_params.captureInputOnly || !g_state.formatValid) + /* we need to ungrab the pointer on the following conditions + * - if the backend does not support warp as exit via window edge + * detection will never work as the cursor can not be warped out of the + * window when we release it. + * - if the format is invalid as we do not know where the guest cursor is + * which also breaks edge detection. + * - if the user has opted to use captureInputOnly mode. + */ + if (warpSupport == LG_DS_WARP_NONE || !g_state.formatValid || + g_params.captureInputOnly) g_state.ds->ungrabPointer(); - // if exiting capture when input on capture only, we want to show the cursor + /* if exiting capture when input on capture only we need to align the local + * cursor to the guest's location before it is shown. */ if (g_params.captureInputOnly || !g_params.hideMouse) core_alignToGuest(); }