From 69b2d3cafdb580a5123747191c4fe92fccc47ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Thu, 7 Dec 2017 14:19:35 +0100 Subject: [PATCH] win_textwidth is no longer needed outside window.c --- sxiv.h | 1 - window.c | 19 ++++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sxiv.h b/sxiv.h index b95d7ff..29bdb2b 100644 --- a/sxiv.h +++ b/sxiv.h @@ -442,7 +442,6 @@ void win_toggle_bar(win_t*); void win_clear(win_t*); void win_draw(win_t*); void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long); -int win_textwidth(const win_env_t*, const char*, unsigned int, bool, XftFont*); void win_set_title(win_t*, const char*); void win_set_cursor(win_t*, cursor_t); void win_cursor_pos(win_t*, int*, int*); diff --git a/window.c b/window.c index 46c3c6d..d1a96fb 100644 --- a/window.c +++ b/window.c @@ -360,6 +360,14 @@ void win_clear(win_t *win) XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); } +int win_textwidth(const win_env_t *e, const char *text, unsigned int len, bool with_padding, XftFont *fnt) +{ + XGlyphInfo ext; + + XftTextExtentsUtf8(e->dpy, fnt, (XftChar8*)text, len, &ext); + return ext.xOff + (with_padding ? 2 * H_TEXT_PAD : 0); +} + void win_draw_bar_text(win_t *win, XftDraw *d, XftColor *color, XftFont *font, int x, int y, char *text, int maxlen, int maximum_x) { size_t len = 0; @@ -469,17 +477,6 @@ 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); } -int win_textwidth(const win_env_t *e, const char *text, unsigned int len, bool with_padding, XftFont *fnt) -{ - XGlyphInfo ext; - - if(!fnt) - fnt = font; - - XftTextExtentsUtf8(e->dpy, fnt, (XftChar8*)text, len, &ext); - return ext.xOff + (with_padding ? 2 * H_TEXT_PAD : 0); -} - void win_set_title(win_t *win, const char *title) { if (title == NULL)