summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorN-R-K <79544946+N-R-K@users.noreply.github.com>2022-02-23 10:23:22 +0100
committerGitHub <noreply@github.com>2022-02-23 10:23:22 +0100
commite26c81fe9ab43ef0148f51464dbae0f7a0e2b91e (patch)
treed65b9950f1c9310e40490302d77782c182a47377 /window.c
parentad95012be993664e062e7724155c54a482a51315 (diff)
downloadnsxiv-e26c81fe9ab43ef0148f51464dbae0f7a0e2b91e.tar.zst
use win-title script for customizing window title (#213)
this removes the cli flag `-T` as well as related config.h options. Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
Diffstat (limited to 'window.c')
-rw-r--r--window.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/window.c b/window.c
index 8dc7d36..a305353 100644
--- a/window.c
+++ b/window.c
@@ -30,6 +30,8 @@
#include <X11/Xatom.h>
#include <X11/Xresource.h>
+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)