Krolyxon
Commit 700d9f4

Branches

Refs →

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()
Author
NRK
Date
2022-02-28 00:38 +0600
Committer
N-R-K · 2022-03-02 09:32 +0000
Parent
ad571e7
Commit
700d9f46c7725159a56b87d0b391a5967cfb081a

+12 −11

2 files changed

  1. M nsxiv.h +2 −0
  2. M window.c +10 −11
M nsxiv.h View
@@ -381,6 +381,8 @@ enum {
381381 ATOM__NET_WM_PID,
382382 ATOM__NET_WM_STATE_FULLSCREEN,
383383 ATOM_UTF8_STRING,
384+ ATOM_WM_NAME,
385+ ATOM_WM_ICON_NAME,
384386 ATOM_COUNT
385387 };
386388
M window.c View
@@ -171,6 +171,8 @@ void win_init(win_t *win)
171171 INIT_ATOM_(_NET_WM_PID);
172172 INIT_ATOM_(_NET_WM_STATE_FULLSCREEN);
173173 INIT_ATOM_(UTF8_STRING);
174+ INIT_ATOM_(WM_NAME);
175+ INIT_ATOM_(WM_ICON_NAME);
174176 }
175177
176178 void win_open(win_t *win)
@@ -289,10 +291,7 @@ void win_open(win_t *win)
289291 }
290292 free(icon_data);
291293
292− XStoreName(win->env.dpy, win->xwin, res_name);
293− XSetIconName(win->env.dpy, win->xwin, res_name);
294294 win_set_title(win, true);
295−
296295 classhint.res_class = res_class;
297296 classhint.res_name = options->res_name != NULL ? options->res_name : res_name;
298297 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,
505504
506505 void win_set_title(win_t *win, bool init)
507506 {
507+ size_t len, i;
508508 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 };
513510
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+ }
518517 }
519518
520519 void win_set_cursor(win_t *win, cursor_t cursor)