[client] wayland: add option to enable cursor warp

This is enabled on default. Specify wayland:warpSupport=no to disable it,
which may be useful on certain compositors that do not warp when the
pointer is confined.
This commit is contained in:
Quantum 2021-02-15 20:54:02 -05:00 committed by Geoffrey McRae
parent 9b688909b0
commit 1ba1108099
6 changed files with 44 additions and 0 deletions

View File

@ -196,4 +196,10 @@ Command line arguments will override any options loaded from the config files.
| opengl:preventBuffer | | yes | Prevent the driver from buffering frames |
| opengl:amdPinnedMem | | yes | Use GL_AMD_pinned_memory if it is available |
|------------------------------------------------------------------------------------|
|-------------------------------------------------------------|
| Long | Short | Value | Description |
|-------------------------------------------------------------|
| wayland:warpSupport | | yes | Enable cursor warping |
|-------------------------------------------------------------|
```

View File

@ -53,6 +53,10 @@ static struct SDLDSState sdl;
/* forwards */
static int sdlEventFilter(void * userdata, SDL_Event * event);
static void sdlSetup(void)
{
}
static bool sdlProbe(void)
{
return true;
@ -504,6 +508,7 @@ static bool sdlGetFullscreen(void)
struct LG_DisplayServerOps LGDS_SDL =
{
.setup = sdlSetup,
.probe = sdlProbe,
.earlyInit = sdlEarlyInit,
.init = sdlInit,

View File

@ -42,6 +42,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "common/debug.h"
#include "common/locking.h"
#include "common/countedbuffer.h"
#include "common/option.h"
#include "wayland-xdg-shell-client-protocol.h"
#include "wayland-xdg-decoration-unstable-v1-client-protocol.h"
@ -166,6 +167,18 @@ struct WCBState
static struct WaylandDSState wm;
static struct WCBState wcb;
static struct Option waylandOptions[] =
{
{
.module = "wayland",
.name = "warpSupport",
.description = "Enable cursor warping",
.type = OPTION_TYPE_BOOL,
.value.x_bool = true,
},
{0}
};
static const uint32_t cursorBitmap[] = {
0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0xFFFFFF, 0xFFFFFF, 0x000000,
@ -618,6 +631,11 @@ static bool waylandEarlyInit(void)
return true;
}
static void waylandSetup(void)
{
option_register(waylandOptions);
}
static bool waylandProbe(void)
{
return getenv("WAYLAND_DISPLAY") != NULL;
@ -630,6 +648,8 @@ static bool waylandInit(const LG_DSInitParams params)
{
memset(&wm, 0, sizeof(wm));
wm.warpSupport = option_get_bool("wayland", "warpSupport");
wm.epollFd = epoll_create1(EPOLL_CLOEXEC);
if (wm.epollFd < 0)
{
@ -1514,6 +1534,7 @@ static void waylandCBRelease(void)
struct LG_DisplayServerOps LGDS_Wayland =
{
.setup = waylandSetup,
.probe = waylandProbe,
.earlyInit = waylandEarlyInit,
.init = waylandInit,

View File

@ -118,6 +118,10 @@ static void x11SetFullscreen(bool fs);
static int x11EventThread(void * unused);
static void x11GenericEvent(XGenericEventCookie *cookie);
static void x11Setup(void)
{
}
static bool x11Probe(void)
{
return getenv("DISPLAY") != NULL;
@ -1490,6 +1494,7 @@ static void x11CBRequest(LG_ClipboardData type)
struct LG_DisplayServerOps LGDS_X11 =
{
.setup = x11Setup,
.probe = x11Probe,
.earlyInit = x11EarlyInit,
.init = x11Init,

View File

@ -84,6 +84,9 @@ typedef struct LG_DSGLContext
struct LG_DisplayServerOps
{
/* called before options are parsed, useful for registering options */
void (*setup)(void);
/* return true if the selected ds is valid for the current platform */
bool (*probe)(void);
@ -175,6 +178,7 @@ struct LG_DisplayServerOps
#endif
#define ASSERT_LG_DS_VALID(x) \
assert((x)->setup ); \
assert((x)->probe ); \
assert((x)->earlyInit ); \
assert((x)->init ); \

View File

@ -1032,6 +1032,9 @@ int main(int argc, char * argv[])
for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i)
LG_Renderers[i]->setup();
for(unsigned int i = 0; i < LG_DISPLAYSERVER_COUNT; ++i)
LG_DisplayServers[i]->setup();
if (!config_load(argc, argv))
return -1;