XChangeProperty/XGetWindowProperty problem

406643764 406643764 at qq.com
Fri May 9 06:56:09 UTC 2025


Hi, all. 

I use XChangeProperty/XGetWindowProperty as following code:
 
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>

int main(void)
{
    Display *display=XOpenDisplay(NULL);
    int screen=DefaultScreen(display);
    Window root_win=RootWindow(display, screen);

    Window win=XCreateSimpleWindow(display, root_win, -1, -1, 1, 1, 0, 0, 0);
    Atom prop=XInternAtom(display, "test_prop", False);
    Atom type=XInternAtom(display, "test_type", False);
    int32_t a[]={0x11223344, 0x55667788};
    XChangeProperty(display, win, prop, type, 32, PropModeReplace, (unsigned char *)a, 2);

    int fmt;
    unsigned long nitems=0, n=0, rest;
    unsigned char *p=NULL;
    Atom atype;
    if( XGetWindowProperty(display, win, prop, 0, 2, False,
        type, &atype, &fmt, &n, &rest, &p) != Success
        || !atype || !fmt || !n || !p)
        XFree(p), p=NULL;
    long *d=(long *)p;
    printf("%lx, %lx, %lu\n", d[0], d[1], rest);

    XCloseDisplay(display);

    return 0;
}



But the output is:


11223344, 1, 0


It should be:


11223344, 55667788, 0



What's wrong ?



406643764
406643764 at qq.com



 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg/attachments/20250509/c8426e17/attachment.htm>


More information about the xorg mailing list