Using Xlib to create a colored hardware cursor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would like to use a different mouse cursor in my application instead of the standard X11 one (it uses Ogre3D)

Here is what I've tried

    // getting the X11 window from OIS (ogre's input library)
    OIS::ParamList::iterator i = pl.find("WINDOW");
    Window window  = strtoul(i->second.c_str(), 0, 10);

    Display* display = XOpenDisplay(0);
    XcursorImage* image;

    Image im;
im.load("cursor.png", ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
    PixelBox pb = im.getPixelBox();

    unsigned int w = pb.getWidth();
    unsigned int h = pb.getHeight();

    image = XcursorImageCreate(w, h);

    int c = 0;
    for (size_t y = 0; y < w; ++y)
    {
        for (size_t x = 0; x < h; ++x)
        {
            const ColourValue& cv = pb.getColourAt(x, y, 0);
            unsigned char r, g, b, a;
            r = cv.r; g = cv.g; b = cv.b; a = cv.a;

            image->pixels[c++] = (a<<24) | (r<<16) | (g<<8) | (b);
        }
    }

    Cursor xcursor = XcursorImageLoadCursor(display, image);
    XcursorImageDestroy(image);

    XDefineCursor(display, window, xcursor);
    XFlush(display);

But when starting my application I still see the standard X cursor, not the colored one. What am I doing wrong?

Also, how can I check for any X11 errors that might have occured? I couldnt find any good documentation on this.
_______________________________________________
xorg@xxxxxxxxxxx: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: list-xorg@xxxxxxxxxxx


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [X Forum]     [Intel Graphics]     [AMD Graphics]     [Nouveau Driver]     [XFree86]     [XFree86 Newbie]     [IETF Annouce]     [Security]     [Fontconfig]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Video for Linux]     [Linux RAID]

  Powered by Linux