Fixed crash in systray with non-Latin languagess (thanks zcodes)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user