代码范例:

static void window_change_property()
{
char* cname = NULL;
XTextProperty tp;
Atom atom;
int32_t status;

//atom = XInternAtom(g_pDisplay, "WM_NAME", True);
atom = XInternAtom(g_pDisplay, "_NET_WM_NAME", True);

cname = (char*)malloc(32);
strcpy(cname, "Taishan");
status = Xutf8TextListToTextProperty(g_pDisplay, &cname, 1, XStdICCTextStyle, &tp);
if (status == Success || status > 0) {
printf("%s-%d %s\n", __func__, __LINE__, cname);
XChangeProperty(g_pDisplay, g_oWindow, atom,
tp.encoding, tp.format,
PropModeReplace,
tp.value, tp.nitems);
}

if (tp.value != NULL)
{
XFree(tp.value);
}
}