nsxiv69b2d3c
win_textwidth is no longer needed outside window.c
+8 −12
2 files changed
| @@ -442,7 +442,6 @@ void win_toggle_bar(win_t*); | |||
| 442 | 442 | void win_clear(win_t*); | |
| 443 | 443 | void win_draw(win_t*); | |
| 444 | 444 | 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*); | |
| 446 | 445 | void win_set_title(win_t*, const char*); | |
| 447 | 446 | void win_set_cursor(win_t*, cursor_t); | |
| 448 | 447 | void win_cursor_pos(win_t*, int*, int*); | |
| @@ -360,6 +360,14 @@ void win_clear(win_t *win) | |||
| 360 | 360 | XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); | |
| 361 | 361 | } | |
| 362 | 362 | ||
| 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 | + | ||
| 363 | 371 | 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) | |
| 364 | 372 | { | |
| 365 | 373 | 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, | |||
| 469 | 477 | XDrawRectangle(win->env.dpy, win->buf.pm, gc, x, y, w, h); | |
| 470 | 478 | } | |
| 471 | 479 | ||
| 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 | − | ||
| 483 | 480 | void win_set_title(win_t *win, const char *title) | |
| 484 | 481 | { | |
| 485 | 482 | if (title == NULL) | |