Peter,
> i'll attach a simple test program that I've used to debug a few things, I
> just verified it works correctly. (argv[1] must be the pointer ID of the
> master pointer to change).
Thanks a lot, that helped. My code works now, I simply forgot to call
XCloseDisplay/XFlush at the end. I'll attach it here again for reference
(the PNG library I'm using is a slightly modified version PicoPNG by
Lode Vandevenne, if somebody wants to give it a try).
Thanks again,
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);
Window win = RootWindow(dpy,screen);
int id = atoi(argv[1]);
Cursor foo = load(argv[2]);
Status res = XIDefineCursor( dpy, id, win, foo );
XCloseDisplay(dpy);
return res;
}
_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg