hide mouse pointer
does anyone know a function, to hide/unhide the mouse pointer in x ?
didn''t find anything in google & co...
Use ShowCursor:
ShowCursor(false); //hides mouse pointer
ShowCursor(true); // displays mouse cursor
Not that hard, hein?
ShowCursor(false); //hides mouse pointer
ShowCursor(true); // displays mouse cursor
Not that hard, hein?
[Hugo Ferreira][Positronic Dreams][Stick Soldiers]
"Please Review my WebSite!".
September 07, 2002 11:23 AM
I''m far from an expert with XLib, but I think you use XDefineCursor with ''None'' as the cursor.
Pentium3id : was that a joke for guys knowing WinAPI, or is there really a function ''ShowCursor'' for linux ??
i didn''t find anything in the manpages, so where can i find it ?
AP : this didn''t work for me... the manpage says, when the Cursor-parameter for XDefineCusor is ''None'', it''s the same as calling XUndefineCursor().
so still can''t hide the pointer...
any other suggestions ?
i didn''t find anything in the manpages, so where can i find it ?
AP : this didn''t work for me... the manpage says, when the Cursor-parameter for XDefineCusor is ''None'', it''s the same as calling XUndefineCursor().
so still can''t hide the pointer...
any other suggestions ?
oops... i thought you meant win32, sorry... !
[Hugo Ferreira][Positronic Dreams][Stick Soldiers]
"Please Review my WebSite!".
September 07, 2002 08:24 PM
AFAIK there is no easy way to do that with Xlib. The people at Nevrax (http://www.nevrax.com) use something like this in their NeL libraries (http://www.nevrax.org):
The idea is to create a transparent cursor when you want to hide it: create a color and a "mask", then assign it to your cursor. When you want to show it again, destroy the current cursor and define a new default one.
Hope this helps.
#include <X11/Xlib.h>#include <X11/cursorfont.h>#include <string.h>Display *dpy;Window win;static Cursor pointer = None;/* open the display, create the window, etc. Please note that you''ll have to adapt this if you want it to work on multiple mice systems.*/void show_cursor( ) { if ( None != pointer ) { XFreeCursor( dpy, pointer ); cursor = None; } XUndefineCursor( dpy, win ); XSync( dpy, False ); /* optional */}void hide_cursor( ) { if ( None == pointer ) { char bm[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; Pixmap pix = XCreateBitmapFromData( dpy, win, bm, 8, 8 ); 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 */}
The idea is to create a transparent cursor when you want to hide it: create a color and a "mask", then assign it to your cursor. When you want to show it again, destroy the current cursor and define a new default one.
Hope this helps.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement