Advertisement

hide mouse pointer

Started by September 07, 2002 10:45 AM
5 comments, last by uNiQue0815 22 years, 4 months ago
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?

[Hugo Ferreira][Positronic Dreams][Stick Soldiers]
"Please Review my WebSite!".

Advertisement
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 ?
oops... i thought you meant win32, sorry... !

[Hugo Ferreira][Positronic Dreams][Stick Soldiers]
"Please Review my WebSite!".

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):


  #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.
Advertisement
pentium3id : think, it would be more than a sin, asking a win32 question in the ''everything unix'' forum, right ?

AP : yeah !!! at last !! these functions work perfectly !

thx very much !

This topic is closed to new replies.

Advertisement