On Fri, 9 May 2025 14:56:09 +0800 "406643764" <406643...@qq.com> said:

please make your text in emails actual text, not html... it will make replies
not full of junk like this.

you need to use long, not uint32_t for a 32bit property. don't ask. history.

> Hi, all. 
> 
> I use XChangeProperty/XGetWindowProperty as following code:
> &nbsp;
> #include <stdio.h&gt;
> #include <X11/Xlib.h&gt;
> #include <X11/Xatom.h&gt;
> 
> int main(void)
> {
> &nbsp; &nbsp; Display *display=XOpenDisplay(NULL);
> &nbsp; &nbsp; int screen=DefaultScreen(display);
> &nbsp; &nbsp; Window root_win=RootWindow(display, screen);
> 
> &nbsp; &nbsp; Window win=XCreateSimpleWindow(display, root_win, -1, -1, 1, 1,
> 0, 0, 0); &nbsp; &nbsp; Atom prop=XInternAtom(display, "test_prop", False);
> &nbsp; &nbsp; Atom type=XInternAtom(display, "test_type", False);
> &nbsp; &nbsp; int32_t a[]={0x11223344, 0x55667788};
> &nbsp; &nbsp; XChangeProperty(display, win, prop, type, 32, PropModeReplace,
> (unsigned char *)a, 2);
> 
> &nbsp; &nbsp; int fmt;
> &nbsp; &nbsp; unsigned long nitems=0, n=0, rest;
> &nbsp; &nbsp; unsigned char *p=NULL;
> &nbsp; &nbsp; Atom atype;
> &nbsp; &nbsp; if( XGetWindowProperty(display, win, prop, 0, 2, False,
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; type, &amp;atype, &amp;fmt, &amp;n,
> &amp;rest, &amp;p) != Success &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; || !atype
> || !fmt || !n || !p) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XFree(p), p=NULL;
> &nbsp; &nbsp; long *d=(long *)p;
> &nbsp; &nbsp; printf("%lx, %lx, %lu\n", d[0], d[1], rest);
> 
> &nbsp; &nbsp; XCloseDisplay(display);
> 
> &nbsp; &nbsp; return 0;
> }
> 
> 
> 
> But the output is:
> 
> 
> 11223344, 1, 0
> 
> 
> It should be:
> 
> 
> 11223344, 55667788, 0
> 
> 
> 
> What's wrong ?
> 
> 
> 
> 406643764
> 406643...@qq.com
> 
> 
> 
> &nbsp;

-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
Carsten Haitzler - ras...@rasterman.com

Reply via email to