[x11] Implement mouse visibility control

That was nicely easy.
This commit is contained in:
Bill Currie 2023-06-30 14:53:47 +09:00
parent ec0c6ad906
commit 759e67bb7c
3 changed files with 14 additions and 7 deletions

View file

@ -57,6 +57,7 @@ extern int x_height;
extern int x_shmeventtype;
extern Time x_time;
extern Time x_mouse_time;
extern Cursor x_nullcursor;
extern bool oktodraw;
extern bool x_have_focus;

View file

@ -78,7 +78,6 @@ bool oktodraw = false;
int x_shmeventtype;
static int x_disp_ref_count = 0;
static Cursor nullcursor = None;
Display *x_disp = NULL;
int x_screen;
@ -91,6 +90,7 @@ Window x_win;
Colormap x_cmap;
Time x_time;
Time x_mouse_time;
Cursor x_nullcursor = None;
bool x_have_focus = false;
@ -315,9 +315,9 @@ X11_CloseDisplay (void)
X11_RestoreGamma ();
if (nullcursor != None) {
XFreeCursor (x_disp, nullcursor);
nullcursor = None;
if (x_nullcursor != None) {
XFreeCursor (x_disp, x_nullcursor);
x_nullcursor = None;
}
XCloseDisplay (x_disp);
@ -338,7 +338,7 @@ X11_CreateNullCursor (void)
GC gc;
XColor dummycolour = { };
if (nullcursor != None)
if (x_nullcursor != None)
return;
cursormask = XCreatePixmap (x_disp, x_root, 1, 1, 1);
@ -351,11 +351,10 @@ X11_CreateNullCursor (void)
dummycolour.pixel = 0;
dummycolour.red = 0;
dummycolour.flags = 04;
nullcursor = XCreatePixmapCursor (x_disp, cursormask, cursormask,
x_nullcursor = XCreatePixmapCursor (x_disp, cursormask, cursormask,
&dummycolour, &dummycolour, 0, 0);
XFreePixmap (x_disp, cursormask);
XFreeGC (x_disp, gc);
XDefineCursor (x_disp, x_win, nullcursor);
}
#ifdef HAVE_VIDMODE

View file

@ -104,6 +104,12 @@ X11_VID_SetPalette (byte *palette, byte *colormap)
vid_internal.set_palette (vid_internal.ctx, viddef.palette);
}
static void
X11_VID_SetCursor (bool visible)
{
XDefineCursor (x_disp, x_win, visible ? None : x_nullcursor);
}
/*
Set up color translation tables and the window. Takes a 256-color 8-bit
palette. Palette data will go away after the call, so copy it if you'll
@ -158,6 +164,7 @@ vid_system_t vid_system = {
.init_cvars = X11_VID_Init_Cvars,
.update_fullscreen = X11_UpdateFullscreen,
.set_palette = X11_VID_SetPalette,
.set_cursor = X11_VID_SetCursor,
};
#if 0