How do I hide the mouse pointer under X11? I would like to use the built in libraries in order to do this and not something like SDL (SDL_ShowCursor(0)) or glut (glutSetCur
There is a -no-cursor
option for Xorg 1.7 and later. https://www.x.org/wiki/AdvancedTopicsFAQ/
xinit -- -nocursor
or startx -- -nocursor
could work.
Unclutter didn't work for me, as it doesn't play well with hardware accelerated surfaces (such as for example those produced by intels' VA-API when decoding video). So I found a program that hid the mouse pointer in a less roundabout way, hhp, and rewrote it in C with minimal dependencies, the result is hhpc. I did this to obviate the need to have haskell to compile it and because hhp sometimes stopped hiding the mouse pointer.
hhpc, relies only on glibc
and xlib
, so it's easy to build, just do make release
. You can get the code and instructions from my repository. It's very memory and CPU efficient (because it does almost nothing).
All right!
I guess this post may be getting a little bit old, but if what I've found can help some of us, I definitely have to post it here ;)
I found myself a clean and simple solution that works fine, without using "xcb" ( for what I tried to achieve, it was a little over-engineering (..)
All you need is the xsetroot
command, with appropriate arguments:
To hide the mouse cursor, you need an extra little file (I called mine blnk_ptr.xbm
)
the content of this file:
#define blnk_ptr_width 1
#define blnk_ptr_height 1
#define blnk_ptr_x_hot 0
#define blnk_ptr_y_hot 0
static unsigned char blnk_ptr_bits[] = { 0x00 };
Then, we can use the two following commands:
To hide the mouse pointer cursor,
$ xsetroot -cursor blnk_ptr.xbm blnk_ptr.xbm
To show the mouse pointer cursor again,
$ xsetroot -cursor_name left_ptr
(You can use a mouse pointer cursor other than "left_ptr", but this one seems to be widely available across *nix systems (..)
Btw, I don't know yet how to get the name of the pointer currently used by the system using xsetroot. I guess I'll [as usual] digg that too, but I'd be happy to have someone who knows the how-to giving me the answer ( It'd be nice ;) )
Enjoy ? ;p
There is an X11 extension called Fixes which has a function one can use to hide the cursor. The advantage of this function is that this sends a message to the X server which hides the sprite. No trick (i.e. invisible cursor from a pixmap) and from what I understand it works on the entire screen.
#include <X11/extensions/Xfixes.h>
...
XFixesHideCursor(dpy, window);
XFlush(dpy); // not required unless you want an immediate effect
Source: How to hide the mouse cursor in X11/Xorg
I'd rather use simpler method:
unclutter -idle 0
You almost do not see cursor, still it is available. To disable mouse:
rmmod psmouse
Or disable mouse module permanently somewhere in /etc/. See your distribution manual.
Use xbanish! It "banish the mouse cursor when typing"! Start it with
xbanish &
and enjoy!