diff options
author | NRK <nrk@disroot.org> | 2022-02-28 00:38:27 +0600 |
---|---|---|
committer | N-R-K <79544946+N-R-K@users.noreply.github.com> | 2022-03-02 09:32:35 +0000 |
commit | 700d9f46c7725159a56b87d0b391a5967cfb081a (patch) | |
tree | 809bd2fc6067a790b68a61c72b28fde46a5ee8a0 | |
parent | ad571e7448eb53fb099ec0cb87baf97cb38d3450 (diff) |
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()
Closes: https://github.com/nsxiv/nsxiv/issues/233
-rw-r--r-- | nsxiv.h | 2 | ||||
-rw-r--r-- | window.c | 21 |
2 files changed, 12 insertions, 11 deletions
@@ -381,6 +381,8 @@ enum { ATOM__NET_WM_PID, ATOM__NET_WM_STATE_FULLSCREEN, ATOM_UTF8_STRING, + ATOM_WM_NAME, + ATOM_WM_ICON_NAME, ATOM_COUNT }; @@ -171,6 +171,8 @@ void win_init(win_t *win) INIT_ATOM_(_NET_WM_PID); INIT_ATOM_(_NET_WM_STATE_FULLSCREEN); INIT_ATOM_(UTF8_STRING); + INIT_ATOM_(WM_NAME); + INIT_ATOM_(WM_ICON_NAME); } void win_open(win_t *win) @@ -289,10 +291,7 @@ void win_open(win_t *win) } free(icon_data); - XStoreName(win->env.dpy, win->xwin, res_name); - XSetIconName(win->env.dpy, win->xwin, res_name); win_set_title(win, true); - classhint.res_class = res_class; classhint.res_name = options->res_name != NULL ? options->res_name : res_name; 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, void win_set_title(win_t *win, bool init) { + size_t len, i; unsigned char title[512]; - size_t len; - - if ((len = get_win_title(title, ARRLEN(title), init)) <= 0) - return; + int targets[] = { ATOM_WM_NAME, ATOM_WM_ICON_NAME, ATOM__NET_WM_NAME, ATOM__NET_WM_ICON_NAME }; - XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_NAME], - atoms[ATOM_UTF8_STRING], 8, PropModeReplace, title, len); - XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_ICON_NAME], - atoms[ATOM_UTF8_STRING], 8, PropModeReplace, title, len); + if ((len = get_win_title(title, ARRLEN(title), init)) > 0) { + for (i = 0; i < ARRLEN(targets); ++i) { + XChangeProperty(win->env.dpy, win->xwin, atoms[targets[i]], + atoms[ATOM_UTF8_STRING], 8, PropModeReplace, title, len); + } + } } void win_set_cursor(win_t *win, cursor_t cursor) |