Fixed crash in systray with non-Latin languagess (thanks zcodes)

This commit is contained in:
o9000
2016-05-07 00:38:52 +02:00
parent fea91746a4
commit 690f30308f
4 changed files with 41 additions and 18 deletions

View File

@@ -320,3 +320,32 @@ gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, i
*ih = height[icon_num];
return icon_data[icon_num];
}
// Thanks zcodes!
char *get_window_name(Window win)
{
XTextProperty text_property;
Status status = XGetWMName(server.display, win, &text_property);
if (!status || !text_property.value || !text_property.nitems) {
return strdup("");
}
char **name_list;
int count;
status = Xutf8TextPropertyToTextList(server.display, &text_property, &name_list, &count);
if (status < Success || !count) {
XFree(text_property.value);
return strdup("");
}
if (!name_list[0]) {
XFreeStringList(name_list);
XFree(text_property.value);
return strdup("");
}
char *result = strdup(name_list[0]);
XFreeStringList(name_list);
XFree(text_property.value);
return result;
}

View File

@@ -33,4 +33,6 @@ void change_window_desktop(Window win, int desktop);
int get_icon_count(gulong *data, int num);
gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size);
char *get_window_name(Window win);
#endif