nsxiv700d9f4
fix: window title not working on certain WMs
not all WMs support `_NET_WM_NAME` and `_NET_WM_ICON_NAME` this patch sets `WM_NAME` and `WM_ICON_NAME` inside win_set_title()
+12 −11
2 files changed
| @@ -381,6 +381,8 @@ enum { | |||
| 381 | 381 | ATOM__NET_WM_PID, | |
| 382 | 382 | ATOM__NET_WM_STATE_FULLSCREEN, | |
| 383 | 383 | ATOM_UTF8_STRING, | |
| 384 | + | ATOM_WM_NAME, | |
| 385 | + | ATOM_WM_ICON_NAME, | |
| 384 | 386 | ATOM_COUNT | |
| 385 | 387 | }; | |
| 386 | 388 | ||
| @@ -171,6 +171,8 @@ void win_init(win_t *win) | |||
| 171 | 171 | INIT_ATOM_(_NET_WM_PID); | |
| 172 | 172 | INIT_ATOM_(_NET_WM_STATE_FULLSCREEN); | |
| 173 | 173 | INIT_ATOM_(UTF8_STRING); | |
| 174 | + | INIT_ATOM_(WM_NAME); | |
| 175 | + | INIT_ATOM_(WM_ICON_NAME); | |
| 174 | 176 | } | |
| 175 | 177 | ||
| 176 | 178 | void win_open(win_t *win) | |
| @@ -289,10 +291,7 @@ void win_open(win_t *win) | |||
| 289 | 291 | } | |
| 290 | 292 | free(icon_data); | |
| 291 | 293 | ||
| 292 | − | XStoreName(win->env.dpy, win->xwin, res_name); | |
| 293 | − | XSetIconName(win->env.dpy, win->xwin, res_name); | |
| 294 | 294 | win_set_title(win, true); | |
| 295 | − | ||
| 296 | 295 | classhint.res_class = res_class; | |
| 297 | 296 | classhint.res_name = options->res_name != NULL ? options->res_name : res_name; | |
| 298 | 297 | XSetClassHint(e->dpy, win->xwin, &classhint); | |
| @@ -505,16 +504,16 @@ void win_draw_rect(win_t *win, int x, int y, int w, int h, bool fill, int lw, | |||
| 505 | 504 | ||
| 506 | 505 | void win_set_title(win_t *win, bool init) | |
| 507 | 506 | { | |
| 507 | + | size_t len, i; | |
| 508 | 508 | unsigned char title[512]; | |
| 509 | − | size_t len; | |
| 510 | − | ||
| 511 | − | if ((len = get_win_title(title, ARRLEN(title), init)) <= 0) | |
| 512 | − | return; | |
| 509 | + | int targets[] = { ATOM_WM_NAME, ATOM_WM_ICON_NAME, ATOM__NET_WM_NAME, ATOM__NET_WM_ICON_NAME }; | |
| 513 | 510 | ||
| 514 | − | XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_NAME], | |
| 515 | − | atoms[ATOM_UTF8_STRING], 8, PropModeReplace, title, len); | |
| 516 | − | XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_ICON_NAME], | |
| 517 | − | atoms[ATOM_UTF8_STRING], 8, PropModeReplace, title, len); | |
| 511 | + | if ((len = get_win_title(title, ARRLEN(title), init)) > 0) { | |
| 512 | + | for (i = 0; i < ARRLEN(targets); ++i) { | |
| 513 | + | XChangeProperty(win->env.dpy, win->xwin, atoms[targets[i]], | |
| 514 | + | atoms[ATOM_UTF8_STRING], 8, PropModeReplace, title, len); | |
| 515 | + | } | |
| 516 | + | } | |
| 518 | 517 | } | |
| 519 | 518 | ||
| 520 | 519 | void win_set_cursor(win_t *win, cursor_t cursor) | |