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
This commit is contained in:
NRK 2022-02-28 00:38:27 +06:00 committed by N-R-K
parent ad571e7448
commit 700d9f46c7
2 changed files with 12 additions and 11 deletions

View file

@ -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
};

View file

@ -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;
int targets[] = { ATOM_WM_NAME, ATOM_WM_ICON_NAME, ATOM__NET_WM_NAME, ATOM__NET_WM_ICON_NAME };
if ((len = get_win_title(title, ARRLEN(title), init)) <= 0)
return;
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)