From e26c81fe9ab43ef0148f51464dbae0f7a0e2b91e Mon Sep 17 00:00:00 2001 From: N-R-K <79544946+N-R-K@users.noreply.github.com> Date: Wed, 23 Feb 2022 09:23:22 +0000 Subject: use win-title script for customizing window title (#213) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this removes the cli flag `-T` as well as related config.h options. Co-authored-by: Berke Kocaoğlu --- window.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 8dc7d36..a305353 100644 --- a/window.c +++ b/window.c @@ -30,6 +30,8 @@ #include #include +extern size_t get_win_title(char *, int); + #if HAVE_LIBFONTS #include "utf8.h" static XftFont *font; @@ -499,27 +501,20 @@ 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, const char *path) +void win_set_title(win_t *win) { - enum { title_max = 512 }; - char title[title_max]; - const char *basename = strrchr(path, '/') + 1; + char title[512]; + size_t len; - /* Return if window is not ready yet */ - if (win->xwin == None) + if ((len = get_win_title(title, ARRLEN(title))) <= 0) return; - snprintf(title, title_max, "%s%s", options->title_prefix, - options->title_suffixmode == SUFFIX_BASENAME ? basename : path); - if (options->title_suffixmode == SUFFIX_EMPTY) - *(title+strlen(options->title_prefix)) = '\0'; - XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_NAME], XInternAtom(win->env.dpy, "UTF8_STRING", False), 8, - PropModeReplace, (unsigned char *) title, strlen(title)); + PropModeReplace, (unsigned char *) title, len); XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_ICON_NAME], XInternAtom(win->env.dpy, "UTF8_STRING", False), 8, - PropModeReplace, (unsigned char *) title, strlen(title)); + PropModeReplace, (unsigned char *) title, len); } void win_set_cursor(win_t *win, cursor_t cursor) -- cgit v1.2.3