Krolyxon
Commit 69b2d3c

Branches

Refs →

nsxiv69b2d3c

win_textwidth is no longer needed outside window.c

Author
Bert Münnich
Date
2017-12-07 14:19 +0100
Parent
30e2356
Commit
69b2d3cafdb580a5123747191c4fe92fccc47ced

+8 −12

2 files changed

  1. M sxiv.h +0 −1
  2. M window.c +8 −11
M sxiv.h View
@@ -442,7 +442,6 @@ void win_toggle_bar(win_t*);
442442 void win_clear(win_t*);
443443 void win_draw(win_t*);
444444 void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long);
445−int win_textwidth(const win_env_t*, const char*, unsigned int, bool, XftFont*);
446445 void win_set_title(win_t*, const char*);
447446 void win_set_cursor(win_t*, cursor_t);
448447 void win_cursor_pos(win_t*, int*, int*);
M window.c View
@@ -360,6 +360,14 @@ void win_clear(win_t *win)
360360 XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h);
361361 }
362362
363+int win_textwidth(const win_env_t *e, const char *text, unsigned int len, bool with_padding, XftFont *fnt)
364+{
365+ XGlyphInfo ext;
366+
367+ XftTextExtentsUtf8(e->dpy, fnt, (XftChar8*)text, len, &ext);
368+ return ext.xOff + (with_padding ? 2 * H_TEXT_PAD : 0);
369+}
370+
363371 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)
364372 {
365373 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,
469477 XDrawRectangle(win->env.dpy, win->buf.pm, gc, x, y, w, h);
470478 }
471479
472−int win_textwidth(const win_env_t *e, const char *text, unsigned int len, bool with_padding, XftFont *fnt)
473−{
474− XGlyphInfo ext;
475−
476− if(!fnt)
477− fnt = font;
478−
479− XftTextExtentsUtf8(e->dpy, fnt, (XftChar8*)text, len, &ext);
480− return ext.xOff + (with_padding ? 2 * H_TEXT_PAD : 0);
481−}
482−
483480 void win_set_title(win_t *win, const char *title)
484481 {
485482 if (title == NULL)