[client] ds: separate grab and capture logic

Currently, (un)grabPointer is used both for tracking/confining the mouse
in normal mode, as well as entering/exiting capture mode. This makes it
impossible to use separate cursor logic for capture mode, which is needed
to deal with overlapping windows for the Wayland backend.

This commit creates separate (un)capturePointer for entering/exiting
capture mode. There should be no behaviour changes.
This commit is contained in:
Quantum
2021-05-03 20:16:51 -04:00
committed by Geoffrey McRae
parent 7acbc57bc7
commit 00c2773e6b
9 changed files with 65 additions and 14 deletions

View File

@@ -46,6 +46,16 @@ bool app_isCaptureMode(void)
return g_cursor.grab;
}
bool app_isCaptureOnlyMode(void)
{
return g_params.captureInputOnly;
}
bool app_isFormatValid(void)
{
return g_state.formatValid;
}
void app_updateCursorPos(double x, double y)
{
g_cursor.pos.x = x;

View File

@@ -123,7 +123,7 @@ void core_setGrabQuiet(bool enable)
if (g_params.grabKeyboard)
g_state.ds->grabKeyboard();
g_state.ds->grabPointer();
g_state.ds->capturePointer();
}
else
{
@@ -134,17 +134,7 @@ void core_setGrabQuiet(bool enable)
g_state.ds->ungrabKeyboard();
}
/* 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();
g_state.ds->uncapturePointer();
/* if exiting capture when input on capture only we need to align the local
* cursor to the guest's location before it is shown. */