mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[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:
parent
7acbc57bc7
commit
00c2773e6b
@ -535,6 +535,8 @@ struct LG_DisplayServerOps LGDS_SDL =
|
|||||||
.showPointer = sdlShowPointer,
|
.showPointer = sdlShowPointer,
|
||||||
.grabPointer = sdlGrabPointer,
|
.grabPointer = sdlGrabPointer,
|
||||||
.ungrabPointer = sdlUngrabPointer,
|
.ungrabPointer = sdlUngrabPointer,
|
||||||
|
.capturePointer = sdlGrabPointer,
|
||||||
|
.uncapturePointer = sdlUngrabPointer,
|
||||||
.grabKeyboard = sdlGrabKeyboard,
|
.grabKeyboard = sdlGrabKeyboard,
|
||||||
.ungrabKeyboard = sdlUngrabKeyboard,
|
.ungrabKeyboard = sdlUngrabKeyboard,
|
||||||
.warpPointer = sdlWarpPointer,
|
.warpPointer = sdlWarpPointer,
|
||||||
|
@ -357,6 +357,24 @@ void waylandUngrabPointer(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void waylandCapturePointer(void)
|
||||||
|
{
|
||||||
|
waylandGrabPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void waylandUncapturePointer(void)
|
||||||
|
{
|
||||||
|
/* we need to ungrab the pointer on the following conditions when exiting capture mode:
|
||||||
|
* - if warp is not supported, 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 (!wlWm.warpSupport || !app_isFormatValid() || app_isCaptureOnlyMode())
|
||||||
|
waylandUngrabPointer();
|
||||||
|
}
|
||||||
|
|
||||||
void waylandGrabKeyboard(void)
|
void waylandGrabKeyboard(void)
|
||||||
{
|
{
|
||||||
if (wlWm.keyboardInhibitManager && !wlWm.keyboardInhibitor)
|
if (wlWm.keyboardInhibitManager && !wlWm.keyboardInhibitor)
|
||||||
|
@ -164,6 +164,8 @@ struct LG_DisplayServerOps LGDS_Wayland =
|
|||||||
.showPointer = waylandShowPointer,
|
.showPointer = waylandShowPointer,
|
||||||
.grabPointer = waylandGrabPointer,
|
.grabPointer = waylandGrabPointer,
|
||||||
.ungrabPointer = waylandUngrabPointer,
|
.ungrabPointer = waylandUngrabPointer,
|
||||||
|
.capturePointer = waylandCapturePointer,
|
||||||
|
.uncapturePointer = waylandUncapturePointer,
|
||||||
.grabKeyboard = waylandGrabKeyboard,
|
.grabKeyboard = waylandGrabKeyboard,
|
||||||
.ungrabKeyboard = waylandUngrabKeyboard,
|
.ungrabKeyboard = waylandUngrabKeyboard,
|
||||||
.warpPointer = waylandWarpPointer,
|
.warpPointer = waylandWarpPointer,
|
||||||
|
@ -225,6 +225,8 @@ void waylandGrabKeyboard(void);
|
|||||||
void waylandGrabPointer(void);
|
void waylandGrabPointer(void);
|
||||||
void waylandUngrabKeyboard(void);
|
void waylandUngrabKeyboard(void);
|
||||||
void waylandUngrabPointer(void);
|
void waylandUngrabPointer(void);
|
||||||
|
void waylandCapturePointer(void);
|
||||||
|
void waylandUncapturePointer(void);
|
||||||
void waylandRealignPointer(void);
|
void waylandRealignPointer(void);
|
||||||
void waylandWarpPointer(int x, int y, bool exiting);
|
void waylandWarpPointer(int x, int y, bool exiting);
|
||||||
void waylandGuestPointerUpdated(double x, double y, int localX, int localY);
|
void waylandGuestPointerUpdated(double x, double y, int localX, int localY);
|
||||||
|
@ -1063,6 +1063,23 @@ static void x11UngrabPointer(void)
|
|||||||
x11.pointerGrabbed = false;
|
x11.pointerGrabbed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void x11CapturePointer(void)
|
||||||
|
{
|
||||||
|
x11GrabPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void x11UncapturePointer(void)
|
||||||
|
{
|
||||||
|
/* we need to ungrab the pointer on the following conditions when exiting capture mode:
|
||||||
|
* - if the format is invalid as we do not know where the guest cursor is,
|
||||||
|
* which breaks edge detection as the cursor can not be warped out of the
|
||||||
|
* window when we release it.
|
||||||
|
* - if the user has opted to use captureInputOnly mode.
|
||||||
|
*/
|
||||||
|
if (!app_isFormatValid() || app_isCaptureOnlyMode())
|
||||||
|
x11UngrabPointer();
|
||||||
|
}
|
||||||
|
|
||||||
static void x11GrabKeyboard(void)
|
static void x11GrabKeyboard(void)
|
||||||
{
|
{
|
||||||
if (x11.keyboardGrabbed)
|
if (x11.keyboardGrabbed)
|
||||||
@ -1224,6 +1241,8 @@ struct LG_DisplayServerOps LGDS_X11 =
|
|||||||
.showPointer = x11ShowPointer,
|
.showPointer = x11ShowPointer,
|
||||||
.grabPointer = x11GrabPointer,
|
.grabPointer = x11GrabPointer,
|
||||||
.ungrabPointer = x11UngrabPointer,
|
.ungrabPointer = x11UngrabPointer,
|
||||||
|
.capturePointer = x11CapturePointer,
|
||||||
|
.uncapturePointer = x11UncapturePointer,
|
||||||
.grabKeyboard = x11GrabKeyboard,
|
.grabKeyboard = x11GrabKeyboard,
|
||||||
.ungrabKeyboard = x11UngrabKeyboard,
|
.ungrabKeyboard = x11UngrabKeyboard,
|
||||||
.warpPointer = x11WarpPointer,
|
.warpPointer = x11WarpPointer,
|
||||||
|
@ -38,6 +38,8 @@ LG_MsgAlert;
|
|||||||
bool app_isRunning(void);
|
bool app_isRunning(void);
|
||||||
bool app_inputEnabled(void);
|
bool app_inputEnabled(void);
|
||||||
bool app_isCaptureMode(void);
|
bool app_isCaptureMode(void);
|
||||||
|
bool app_isCaptureOnlyMode(void);
|
||||||
|
bool app_isFormatValid(void);
|
||||||
void app_updateCursorPos(double x, double y);
|
void app_updateCursorPos(double x, double y);
|
||||||
void app_updateWindowPos(int x, int y);
|
void app_updateWindowPos(int x, int y);
|
||||||
void app_handleResizeEvent(int w, int h, double scale, const struct Border border);
|
void app_handleResizeEvent(int w, int h, double scale, const struct Border border);
|
||||||
|
@ -131,10 +131,14 @@ struct LG_DisplayServerOps
|
|||||||
/* dm specific cursor implementations */
|
/* dm specific cursor implementations */
|
||||||
void (*guestPointerUpdated)(double x, double y, int localX, int localY);
|
void (*guestPointerUpdated)(double x, double y, int localX, int localY);
|
||||||
void (*showPointer)(bool show);
|
void (*showPointer)(bool show);
|
||||||
void (*grabPointer)();
|
|
||||||
void (*ungrabPointer)();
|
|
||||||
void (*grabKeyboard)();
|
void (*grabKeyboard)();
|
||||||
void (*ungrabKeyboard)();
|
void (*ungrabKeyboard)();
|
||||||
|
/* (un)grabPointer is used to toggle cursor tracking/confine in normal mode */
|
||||||
|
void (*grabPointer)();
|
||||||
|
void (*ungrabPointer)();
|
||||||
|
/* (un)capturePointer is used do toggle special cursor tracking in capture mode */
|
||||||
|
void (*capturePointer)();
|
||||||
|
void (*uncapturePointer)();
|
||||||
|
|
||||||
/* exiting = true if the warp is to leave the window */
|
/* exiting = true if the warp is to leave the window */
|
||||||
void (*warpPointer)(int x, int y, bool exiting);
|
void (*warpPointer)(int x, int y, bool exiting);
|
||||||
@ -199,6 +203,8 @@ struct LG_DisplayServerOps
|
|||||||
assert((x)->showPointer ); \
|
assert((x)->showPointer ); \
|
||||||
assert((x)->grabPointer ); \
|
assert((x)->grabPointer ); \
|
||||||
assert((x)->ungrabPointer ); \
|
assert((x)->ungrabPointer ); \
|
||||||
|
assert((x)->capturePointer ); \
|
||||||
|
assert((x)->uncapturePointer ); \
|
||||||
assert((x)->warpPointer ); \
|
assert((x)->warpPointer ); \
|
||||||
assert((x)->realignPointer ); \
|
assert((x)->realignPointer ); \
|
||||||
assert((x)->isValidPointerPos ); \
|
assert((x)->isValidPointerPos ); \
|
||||||
|
@ -46,6 +46,16 @@ bool app_isCaptureMode(void)
|
|||||||
return g_cursor.grab;
|
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)
|
void app_updateCursorPos(double x, double y)
|
||||||
{
|
{
|
||||||
g_cursor.pos.x = x;
|
g_cursor.pos.x = x;
|
||||||
|
@ -123,7 +123,7 @@ void core_setGrabQuiet(bool enable)
|
|||||||
if (g_params.grabKeyboard)
|
if (g_params.grabKeyboard)
|
||||||
g_state.ds->grabKeyboard();
|
g_state.ds->grabKeyboard();
|
||||||
|
|
||||||
g_state.ds->grabPointer();
|
g_state.ds->capturePointer();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -134,17 +134,7 @@ void core_setGrabQuiet(bool enable)
|
|||||||
g_state.ds->ungrabKeyboard();
|
g_state.ds->ungrabKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we need to ungrab the pointer on the following conditions
|
g_state.ds->uncapturePointer();
|
||||||
* - 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 need to align the local
|
/* if exiting capture when input on capture only we need to align the local
|
||||||
* cursor to the guest's location before it is shown. */
|
* cursor to the guest's location before it is shown. */
|
||||||
|
Loading…
Reference in New Issue
Block a user