aboutsummaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2022-06-01 12:47:17 +0200
committerN-R-K <nrk@disroot.org>2022-06-02 10:09:51 +0200
commite9a0096d6df602aefac5ce63b4bda2e1c85ed846 (patch)
treef49db09049324a1280c2aaf86d5a2de15471e22b /window.c
parent810a9651a362992383081619ca63122f41f1cd0a (diff)
downloadnsxiv-e9a0096d6df602aefac5ce63b4bda2e1c85ed846.tar.zst
code-style: simplify window title related code
instead of dancing around with some `init` parameter, directly give `win_set_title()` what it needs. `get_win_title()` now also does *just* what the name says. this simplifies things quite a bit and the functions now do what their name implies more closely instead of doing some `init` dance internally.
Diffstat (limited to 'window.c')
-rw-r--r--window.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/window.c b/window.c
index 1e1ac59..e13dd83 100644
--- a/window.c
+++ b/window.c
@@ -288,7 +288,7 @@ void win_open(win_t *win)
}
free(icon_data);
- win_set_title(win, true);
+ win_set_title(win, res_name, strlen(res_name));
classhint.res_class = res_class;
classhint.res_name = options->res_name != NULL ? options->res_name : res_name;
XSetClassHint(e->dpy, win->xwin, &classhint);
@@ -504,17 +504,14 @@ void win_draw_rect(win_t *win, int x, int y, int w, int h, bool fill, int lw,
XDrawRectangle(win->env.dpy, win->buf.pm, gc, x, y, w, h);
}
-void win_set_title(win_t *win, bool init)
+void win_set_title(win_t *win, const char *title, size_t len)
{
- size_t len, i;
- unsigned char title[512];
- 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) {
- for (i = 0; i < ARRLEN(targets); ++i) {
- XChangeProperty(win->env.dpy, win->xwin, atoms[targets[i]],
- atoms[ATOM_UTF8_STRING], 8, PropModeReplace, title, len);
- }
+ int i, targets[] = { ATOM_WM_NAME, ATOM_WM_ICON_NAME, ATOM__NET_WM_NAME, ATOM__NET_WM_ICON_NAME };
+
+ for (i = 0; i < ARRLEN(targets); ++i) {
+ XChangeProperty(win->env.dpy, win->xwin, atoms[targets[i]],
+ atoms[ATOM_UTF8_STRING], 8, PropModeReplace,
+ (unsigned char *)title, len);
}
}