OT: How to hide mouse cursor under X?

Sorry for the off-topic, but at least it’s needed for an OpenGL framework. I’m porting my framework to Linux.

Anyway, I’m quite new to X programming. Despite heavy googling I have not found any appropriate function for hiding the mouse cursor. Having the busy cursor in the middle of the screen of a fullscreen app feels a little annoying. What function do I use to hide it?

You can use XDefineCursor. The SDL source code demonstrates it’s usage rather well (src/video/x11/SDL_x11mouse.c), as well as the X man pages.

afaik it’s indeed only possible to hide it by using a 0x0 pixmap…

Great btw to see your framework coming to Linux!
I would really like to see those new demos running in realtime

Are you using XGrabPointer when you switch to a fullscreen mode? If you do, you can create a blank cursor image (either through font or glyph) before you call XGrabPointer and use that cursor when you issue that call, or else use XDefineCursor aftwards.

as far as I know, you are not allowed to create a 0x0 pixmap
From the XCreatePixmap man page
The width and height arguments must be nonzero, or a BadValue error results.
I think Humus is going to need to try and find a font or glyph that is blank and create a cursor out of that.


Originally posted by Dan82181:
The width and height arguments must be nonzero, or a BadValue error results.

True, but you can use a 1x1 bitmap with an empty mask.


Thanks all.
Using a 1x1 blank cursor worked fine

Dan82181, it was early… I meant 1x1 but I wrote 0x0

Yes, I haven’t used pixmap cursors that much. I knew that pixmaps couldn’t be 0x0, but I had totally forgotten about the mask used when creating the cursor. But don’t feel bad, I never think straight until about half way through my second pot of coffee


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.