XChangeProperty no effect after client exit

I am trying to write a simple program that changes the name of a window with a specific window identifier.

/* See LICENSE file for copyright and license details. */ #include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <X11/Xlib.h> static void usage(char *); static void set_title(Display* d, Window w, char* name); static void usage(char *name) { fprintf(stderr, "usage: %s <name> <wid>\n", name); exit(1); } static void set_title(Display* d, Window w, char* name) { XEvent e; XSync(d, False); int ret=XChangeProperty(d, w, XInternAtom(d, "WM_NAME", False), XInternAtom(d, "STRING", False), 8, PropModeReplace, (unsigned char*)name, strlen(name)+1); if(ret==0) return; ret=XChangeProperty(d, w, XInternAtom(d, "_NET_WM_NAME", False), XInternAtom(d, "STRING", False), 8, PropModeReplace, (unsigned char*)name, strlen(name)+1); } int main(int argc, char **argv) { Display* d; char* name=argv[1]; if (argc != 3) usage(argv[0]); d=XOpenDisplay(NULL); set_title(d, strtoul(argv[2], NULL, 16), name); XFlush(d); XCloseDisplay(d); return 0; } 

This works fine in the debugger, however, after the program finishes, the window name is not saved (using wname from wmutils ( http://wmutils.io )).

Should I explicitly wait for XEvent when I change the property before I can exit? What can I do to change the window property forever?

+7
c x11 xlib
source share
1 answer

I can not reproduce this. I tried this with the "Xfburn" application. Please view this session and let me know if I don’t understand something (xchangeproperty.c is your code):

 $ gcc -g -O0 -o xchangeproperty xchangeproperty.c -lX11 $ xwininfo -name Xfburn | grep "Window id" xwininfo: Window id: 0x4600003 "Xfburn" $ ./wname 0x4600003 Xfburn $ ./xchangeproperty pranomostro 0x4600003 $ echo $? 0 $ ./wname 0x4600003 pranomostro 

I can also see the title in the Change window window. This is tested on XUbuntu 16.04 with gcc:

 $ gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609 
+2
source share

All Articles