Fixed crash in systray with non-Latin languagess (thanks zcodes)
This commit is contained in:
parent
fea91746a4
commit
690f30308f
4 changed files with 41 additions and 18 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2016-05-07 master
|
||||||
|
- Fixes:
|
||||||
|
- Fixed crash in systray with non-Latin languagess (thanks zcodes)
|
||||||
|
- Invalidate cached pixmaps on resize/move (issue #576)
|
||||||
|
- Battery: do not show negative durations when the sensors return garbage
|
||||||
|
- Proper workaround for issue #555
|
||||||
|
|
||||||
2016-04-02 0.12.9
|
2016-04-02 0.12.9
|
||||||
- Fixes:
|
- Fixes:
|
||||||
- Regression: Do not detect empty areas as clickable (issue #572)
|
- Regression: Do not detect empty areas as clickable (issue #572)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "systraybar.h"
|
#include "systraybar.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
GSList *icons;
|
GSList *icons;
|
||||||
|
|
||||||
|
@ -534,15 +535,7 @@ gboolean add_icon(Window win)
|
||||||
|
|
||||||
XSelectInput(server.display, win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
|
XSelectInput(server.display, win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
|
||||||
|
|
||||||
XTextProperty xname;
|
char *name = get_window_name(win);
|
||||||
char *name;
|
|
||||||
if (XGetWMName(server.display, win, &xname)) {
|
|
||||||
name = strdup((char *)xname.value);
|
|
||||||
XFree(xname.value);
|
|
||||||
} else {
|
|
||||||
name = strdup("");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (systray_profile)
|
if (systray_profile)
|
||||||
fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, win, name);
|
fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, win, name);
|
||||||
Panel *panel = systray.area.panel;
|
Panel *panel = systray.area.panel;
|
||||||
|
@ -1068,15 +1061,7 @@ void systray_property_notify(TrayWindow *traywin, XEvent *e)
|
||||||
Atom at = e->xproperty.atom;
|
Atom at = e->xproperty.atom;
|
||||||
if (at == server.atom.WM_NAME) {
|
if (at == server.atom.WM_NAME) {
|
||||||
free(traywin->name);
|
free(traywin->name);
|
||||||
|
traywin->name = get_window_name(traywin->win);
|
||||||
XTextProperty xname;
|
|
||||||
if (XGetWMName(server.display, traywin->win, &xname)) {
|
|
||||||
traywin->name = strdup((char *)xname.value);
|
|
||||||
XFree(xname.value);
|
|
||||||
} else {
|
|
||||||
traywin->name = strdup("");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) {
|
if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) {
|
||||||
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
|
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
|
||||||
// print_icons();
|
// print_icons();
|
||||||
|
|
|
@ -320,3 +320,32 @@ gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, i
|
||||||
*ih = height[icon_num];
|
*ih = height[icon_num];
|
||||||
return icon_data[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);
|
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);
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue