X11 mouse is invisible even if hideCursor is false

x11Init assumes you're going to be hiding the mouse, so defines the
cursor unconditionally.
This commit is contained in:
Harik 2022-09-15 16:57:10 -04:00
parent f5e68711d0
commit aa9472e6b6
3 changed files with 15 additions and 3 deletions

View File

@ -58,6 +58,7 @@
#define _NET_WM_STATE_TOGGLE 2
struct X11DSState x11;
struct LG_DisplayServerOps LGDS_X11;
struct MwmHints
{
@ -86,6 +87,7 @@ static int x11EventThread(void * unused);
static void x11XInputEvent(XGenericEventCookie *cookie);
static void x11XPresentEvent(XGenericEventCookie *cookie);
static void x11GrabPointer(void);
static void x11NoSetPointer(LG_DSPointer pointer);
static void x11DoPresent(uint64_t msc)
{
@ -643,8 +645,12 @@ static bool x11Init(const LG_DSInitParams params)
x11.cursors[i] = XcursorLibraryLoadCursor(x11.display, fallbackLookup[i]);
}
/* default to the square cursor */
/* leave the mouse alone if the user requests it. */
if (params.hideMouse)
XDefineCursor(x11.display, x11.window, x11.cursors[LG_POINTER_SQUARE]);
else
LGDS_X11.setPointer = x11NoSetPointer;
if (x11.jitRender)
{
@ -1657,6 +1663,9 @@ static void x11SetPointer(LG_DSPointer pointer)
XDefineCursor(x11.display, x11.window, x11.cursors[pointer]);
}
static void x11NoSetPointer(LG_DSPointer pointer)
{}
static void x11PrintGrabError(const char * type, int dev, Status ret)
{
const char * errStr;

View File

@ -97,6 +97,8 @@ typedef struct LG_DSInitParams
// x11 needs to know if this is in use so we can decide to setup for
// presentation times
bool jitRender;
// x11 needs this early to not override the defaults.
bool hideMouse;
}
LG_DSInitParams;

View File

@ -1305,7 +1305,8 @@ static int lg_run(void)
.borderless = g_params.borderless,
.maximize = g_params.maximize,
.opengl = needsOpenGL,
.jitRender = g_params.jitRender
.jitRender = g_params.jitRender,
.hideMouse = g_params.hideMouse
};
g_state.dsInitialized = g_state.ds->init(params);