From e9a0096d6df602aefac5ce63b4bda2e1c85ed846 Mon Sep 17 00:00:00 2001 From: NRK Date: Wed, 1 Jun 2022 16:47:17 +0600 Subject: 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. --- window.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'window.c') 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); } } -- cgit v1.2.3-54-g00ecf