don't stick textbox size to the first textsize sent via widget_tell

This commit is contained in:
Julien Danjou 2007-12-30 21:03:22 +01:00
parent f7f6951957
commit 13e5b96807
1 changed files with 6 additions and 4 deletions

View File

@ -29,6 +29,7 @@ extern AwesomeConf globalconf;
typedef struct typedef struct
{ {
char *text; char *text;
int width;
XColor fg; XColor fg;
XColor bg; XColor bg;
} Data; } Data;
@ -48,7 +49,9 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
{ {
Data *d = widget->data; Data *d = widget->data;
if(!widget->width) if(d->width)
widget->width = d->width;
else
widget->width = textwidth(widget->font, d->text); widget->width = textwidth(widget->font, d->text);
widget->location = widget_calculate_offset(widget->statusbar->width, widget->location = widget_calculate_offset(widget->statusbar->width,
@ -57,8 +60,7 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
widget->alignment); widget->alignment);
draw_text(ctx, widget->location, 0, widget->width, widget->statusbar->height, draw_text(ctx, widget->location, 0, widget->width, widget->statusbar->height,
0, 0, widget->font, d->text, d->fg, d->bg);
widget->font, d->text, d->fg, d->bg);
return widget->width; return widget->width;
} }
@ -93,7 +95,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
else else
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; 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"))) if((buf = cfg_getstr(config, "font")))
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf); w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);