Simple X questions

  1. how to hide the cursor in a gl window ?
  2. is it possible to redefine the coordinates of a pointer (even if hidden) ?

Thank you

The first one isn’t as simple as you might think.I haven’t looked too much into it but AFAIK you can only change the shape of the pointer not hide it.Changing the shape to a completely transparent quad might help.For more info on changing pointer settings get and read the xlib reference manual.You’re going to need it anyway if you plan to program X.
The second one is easier.Try XWarpPointer().Be carefull though that it seds move events as if the user had actually moved the mouse

Here’s my code for hiding the cursor:

Cursor myCreateNULLCursor( Display *display, Window root )
    Pixmap    cursormask;
    XGCValues xgc;
    GC        gc;
    XColor    col;
    Cursor    cursor;

    cursormask = XCreatePixmap( display, root, 1, 1, 1 );
    xgc.function = GXclear;
    gc = XCreateGC( display, cursormask, GCFunction, &xgc );
    XFillRectangle( display, cursormask, gc, 0, 0, 1, 1 );
    col.pixel = 0; = 0;
    col.flags = 4;
    cursor = XCreatePixmapCursor( display, cursormask, cursormask,
                                  &col,&col, 0,0 );
    XFreePixmap( display, cursormask );
    XFreeGC( display, gc );

    return cursor;

// ...and then

XDefineCursor( Dpy, Win, myCreateNULLCursor( Dpy, Win ) );

Where Dpy & Win are Display and Window handles, respectively:

Display *Dpy;
Window Win;

Hope this helps

I think there were some built-in cursors as well.I don’t remeber having any luck using them but wasn’t there a blank cursor in there?

thank you for your help.
So, for hidding a pointer, i need to put a transparent pointer ? isn’t it ?

Thanx a lot

AFAIK yes.That’s what marcus is doing so you can use this code as well.

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