[client] mouse: do not grab the pointer if the platform has no warp

Platforms such as Wayland have no abillity to warp the cursor, as such
can not operate in an always relative mode. This property allows
platforms to report the lack of warp support and prevent LG from
grabbing the pointer.
This commit is contained in:
Geoffrey McRae 2021-01-16 21:17:35 +11:00
parent cebc728a67
commit 701dfd5694
2 changed files with 27 additions and 4 deletions

View File

@ -38,7 +38,19 @@ LG_ClipboardData;
typedef enum LG_DSProperty typedef enum LG_DSProperty
{ {
LG_DS_MAX_MULTISAMPLE // data type is `int` /**
* returns the maximum number of samples supported
* if not implemented LG assumes no multisample support
* return data type: int
*/
LG_DS_MAX_MULTISAMPLE,
/**
* returns if the platform is warp capable
* if not implemented LG assumes that the platform is warp capable
* return data type: bool
*/
LG_DS_WARP_SUPPORT,
} }
LG_DSProperty; LG_DSProperty;
@ -64,7 +76,11 @@ struct LG_DisplayServerOps
/* final free */ /* final free */
void (*free)(); void (*free)();
/* return a system specific property, returns false if unsupported or failure */ /*
* return a system specific property, returns false if unsupported or failure
* if the platform does not support/implement the requested property the value
* of `ret` must not be altered.
*/
bool (*getProp)(LG_DSProperty prop, void * ret); bool (*getProp)(LG_DSProperty prop, void * ret);
/* event filter, return true if the event has been handled */ /* event filter, return true if the event has been handled */

View File

@ -915,6 +915,11 @@ static void setCursorInView(bool enable)
if (enable && !g_state.focused) if (enable && !g_state.focused)
return; return;
/* if the display server does not support warp, then we can not operate in
* always relative mode and we should not grab the pointer */
bool warpSupport = true;
app_getProp(LG_DS_WARP_SUPPORT, &warpSupport);
g_cursor.inView = enable; g_cursor.inView = enable;
g_cursor.draw = params.alwaysShowCursor ? true : enable; g_cursor.draw = params.alwaysShowCursor ? true : enable;
g_cursor.redraw = true; g_cursor.redraw = true;
@ -926,14 +931,16 @@ static void setCursorInView(bool enable)
if (params.hideMouse) if (params.hideMouse)
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
g_state.ds->grabPointer(); if (warpSupport)
g_state.ds->grabPointer();
} }
else else
{ {
if (params.hideMouse) if (params.hideMouse)
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
g_state.ds->ungrabPointer(); if (warpSupport)
g_state.ds->ungrabPointer();
} }
} }