4
我正在學習使用xlib,我無法獲得XChangeProperty()
爲我工作。XChangeProperty()總是失敗
我有一個簡單的程序,顯示一個窗口成功。但撥打XChangeProperty()
始終會失敗,錯誤代碼爲error 1 (BadRequest)
。
有人能告訴我我做錯了什麼嗎?
這是我的代碼來更改屬性。
static void
change_prop(Display *display, Window window)
{
unsigned char some_text[40] = "hello world!";
int retval;
Atom my_atom;
my_atom = XInternAtom(display, "PERSONAL_PROPERTY", False);
if (my_atom == None)
{
printf("### failed to create atom with name PERSONAL_PROPERTY\n");
return;
}
retval = XChangeProperty(display, /* connection to x server */
window, /* window whose property we want to change */
my_atom, /* property name */
XA_STRING, /* type of property */
8, /* format of prop; can be 8, 16, 32 */
PropModeReplace,
some_text, /* actual data */
10 /* number of elements */
);
printf("###### XChangeProperty() reted %d\n", retval);
}