Hello Peter,
> > when using multiple pointers through XI2, is there a way to set an
> > individual cursor image for each pointer (globally)? If so, how?
> XIDefineCursor on the root window, there's no server flag for this though.
> it's not really a global setting either, it'll get overridden by
> locally-defined cursors, pretty much in the same manner as normal cursors.
thanks for your help. I've quickly ripped some code from libXcursor and
hacked together a small tool to try this, however, it doesn't seem to
have any effect. The load() routine seems to create a correct cursor ID,
and XIDefineCursor returns 0. Is this a feature which may be missing
from my graphics driver (I'm using radeon), or is this rather overridden
by my desktop environment?
Thanks, Yours, Florian
--
0666 - Filemode of the Beast
#include <X11/extensions/XInput2.h>
#include <X11/extensions/Xrender.h>
#include "PicoPNG.h"
#include <iostream>
Display* dpy;
int screen;
static int nativeByteOrder() {
int x = 1;
return (*((char *) &x) == 1) ? LSBFirst : MSBFirst;
}
Cursor load( const char* file ) {
PNGImage image( file );
Cursor cursor = None;
XImage ximage;
Pixmap pixmap;
Picture picture;
GC gc;
XRenderPictFormat* format;
ximage.width = image.width();
ximage.height = image.height();
ximage.xoffset = 0;
ximage.format = ZPixmap;
ximage.data = (char*)image.data();
ximage.byte_order = nativeByteOrder();
ximage.bitmap_unit = 32;
ximage.bitmap_bit_order = ximage.byte_order;
ximage.bitmap_pad = 32;
ximage.depth = 32;
ximage.bits_per_pixel = 32;
ximage.bytes_per_line = image.width() * 4;
ximage.red_mask = 0xff0000;
ximage.green_mask = 0x00ff00;
ximage.blue_mask = 0x0000ff;
ximage.obdata = NULL;
if (!XInitImage (&ximage)) return None;
pixmap = XCreatePixmap( dpy, RootWindow (dpy, screen), image.width(), image.height(), 32 );
//printf("%x\n", pixmap );
gc = XCreateGC( dpy, pixmap, 0, NULL );
//printf("%x\n", gc );
XPutImage( dpy, pixmap, gc, &ximage, 0, 0, 0, 0, image.width(), image.height() );
XFreeGC( dpy, gc );
format = XRenderFindStandardFormat( dpy, PictStandardARGB32 );
picture = XRenderCreatePicture( dpy, pixmap, format, 0, NULL );
XFreePixmap( dpy, pixmap );
cursor = XRenderCreateCursor( dpy, picture, 0, 0 ); //image->xhot, image->yhot);
XRenderFreePicture( dpy, picture );
return cursor;
}
int main( int argc, char* argv[] ) {
if (argc != 3) { printf("usage: xicursor ptrid /path/to/cursor.png\n"); return 1; }
dpy = XOpenDisplay( NULL );
screen = DefaultScreen(dpy);
int id = atoi(argv[1]);
Cursor foo = load(argv[2]);
Status res = XIDefineCursor( dpy, id, RootWindow(dpy, screen), foo );
return res;
}
_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg