From 13e5b9680755dc7bfa330b1344ea3b006ef38cef Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 30 Dec 2007 21:03:22 +0100 Subject: [PATCH] don't stick textbox size to the first textsize sent via widget_tell --- widgets/textbox.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/widgets/textbox.c b/widgets/textbox.c index 4ebef872..1e978fad 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -29,6 +29,7 @@ extern AwesomeConf globalconf; typedef struct { char *text; + int width; XColor fg; XColor bg; } Data; @@ -48,7 +49,9 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, { Data *d = widget->data; - if(!widget->width) + if(d->width) + widget->width = d->width; + else widget->width = textwidth(widget->font, d->text); widget->location = widget_calculate_offset(widget->statusbar->width, @@ -57,8 +60,7 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, widget->alignment); draw_text(ctx, widget->location, 0, widget->width, widget->statusbar->height, - 0, - widget->font, d->text, d->fg, d->bg); + 0, widget->font, d->text, d->fg, d->bg); return widget->width; } @@ -93,7 +95,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config) else d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; - w->width = cfg_getint(config, "width"); + d->width = cfg_getint(config, "width"); if((buf = cfg_getstr(config, "font"))) w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);