# xlib - Hiding a hardware cursor

## Recommended Posts

Dom_tucker    122
Hi Everyone, I am using the below function to hide the cursor. The problem is that the function has no effect. Other than I may have done something stupid here, the only thing I can think of is that I have a hardware cursor provided by my Nvidia drivers. Function to hide a cursor:
void hide_cursor(void)
{
char bm[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
Pixmap pix = XCreateBitmapFromData(dpy, win, data, 1, 1);
XColor black;
memset(&black, 0, sizeof(XColor));
black.flags = DoRed | DoGreen | DoBlue;
pointer = XCreatePixmapCursor(dpy, pix, pix, &black, &black, 0, 0);
XFreePixmap(dpy, pix);

XDefineCursor(dpy, win, pointer);
XSync(dpy, False); /* again, optional */
}


Calling event:
Screen *screen;
dpy = XOpenDisplay(":0.0");
screen = XScreenOfDisplay(dpy, 0);
win = screen->root;

//Hide cursor
hide_cursor();


Any thoughts as to why this cursor is still visible?

##### Share on other sites
Dom_tucker    122
I have tried the above code (see previous post) with both software and hardware cursors. The cursor is always visible.

I've designed an app using xlib and I have created crosshairs to replace the standard cursor. The problem is that the cursor appears in the middle of crosshairs.

Does anyone know of any other way to disable the cursor that will function with xlib?

## Create an account

Register a new account