aktau / hhpc

A small utility to hide the mouse pointer with X.org (X11)
76 stars 15 forks source link

Undefined pixmap contents #3

Closed guillerodriguez closed 10 years ago

guillerodriguez commented 10 years ago

When XCreatePixmap is initially called, the contents of the pixmap are undefined. The following code:

static Cursor nullCursor(Display *dpy, Drawable dw) {
    XColor color  = { 0 };
    Pixmap pixmap = XCreatePixmap(dpy, dw, 1, 1, 1);
    Cursor cursor = XCreatePixmapCursor(dpy, pixmap, pixmap, &color, &color, 0, 0);

    XFreePixmap(dpy, pixmap);

    return cursor;
}

should probably be:

static Cursor nullCursor(Display *dpy, Drawable dw) {
    XColor color  = { 0 };
    const char pixmapData[] = { 0 }; 
    Pixmap pixmap = XCreateBitmapFromData(dpy, dw, emptyData, 1, 1);
    Cursor cursor = XCreatePixmapCursor(dpy, pixmap, pixmap, &color, &color, 0, 0);

    XFreePixmap(dpy, pixmap);

    return cursor;
}
aktau commented 10 years ago

I checked the docs (tronche...) and it doesn't make a mention of initializing the data indeed. I'll change it, but have you noticed problems with it?

guillerodriguez commented 10 years ago

No, no actual problems noticed. Just reading through the docs and found that this could maybe be an issue.

El lunes, 3 de febrero de 2014, Nicolas Hillegeer notifications@github.com escribió:

I checked the docs (tronche...) and it doesn't make a mention of initializing the data indeed. I'll change it, but have you noticed problems with it?

Reply to this email directly or view it on GitHubhttps://github.com/aktau/hhpc/issues/3#issuecomment-33992955 .

Guillermo Rodriguez Garcia guille.rodriguez@gmail.com

aktau commented 10 years ago

Alright, the code you suggested shows no bad behaviour in my very small test (i.e.: trying to run it and verifying that it still hides the pointer), so I added it just to be on the safe side. Thanks for reporting it, I appreciate it.

guillerodriguez commented 10 years ago

You're welcome!

El 03/02/2014 21:17, Nicolas Hillegeer escribió:

Alright, the code you suggested shows no bad behaviour in my very small test (i.e.: trying to run it and verifying that it still hides the pointer), so I added it just to be on the safe side. Thanks for reporting it, I appreciate it.

— Reply to this email directly or view it on GitHub https://github.com/aktau/hhpc/issues/3#issuecomment-33995165.