• Advertisement


This topic is now archived and is closed to further replies.

hiding the mouse-pointer in XFree86

This topic is 5324 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! Anyone here knows a way to hide the mouse pointer in X? I''ve been browsing thru the manpages a bit and it seems like the only thing with that effect would be to create an ''empty'' cursor and make it active. However I really dont know how to create the pixmaps that are needed for the CreatePointerFromPixmap-thing. Any help? or at least a reference to a _good_ XFree86 API doc?

Share this post

Link to post
Share on other sites
I haven't found any other way than creating an empty cursor actually... and I don't know if there IS a way of doing it without creating an empty cursor...

here's my function to hide/restore the cursor:

void ui_set_cursor(int state)
Pixmap blank;
XColor dummy;
char data[1] = {0};
static Cursor cursor;
static BOOL blanked;

if (state == UI_CURSOR_HIDDEN)
blank = XCreateBitmapFromData(p_win->dpy, p_win->root, data, 1, 1);
if (blank == None)
log_printf("error: out of memory.\n");
cursor = XCreatePixmapCursor(p_win->dpy, blank, blank, &dummy, &dummy, 0, 0);
XFreePixmap (p_win->dpy, blank);
log_printf("cursor blanked...\n");
XGrabPointer(p_win->dpy, p_win->win, True, 0,
GrabModeAsync, GrabModeAsync,
p_win->win, cursor, CurrentTime);
blanked = TRUE;
XUngrabPointer(p_win->dpy, CurrentTime);
if (blanked)
XFreeCursor(p_win->dpy, cursor);
blanked = FALSE;

(p_win is a custom window structure, you should already have everything like dpy and win if you created a window when you call that function)

btw, this function will also grab/ungrab the mouse pointer to the window... you only need to remove XgrabPointer and XUngrabPointer to get rid of it...

[edited by - sBibi on July 26, 2003 4:03:24 PM]

Share this post

Link to post
Share on other sites

  • Advertisement