diff --git a/config.h b/config.h index f6125143a..eec067c39 100644 --- a/config.h +++ b/config.h @@ -224,7 +224,7 @@ typedef struct struct Widget { char *name; - int (*draw)(DrawCtx *, int, int, int, int); + int (*draw)(Widget *, DrawCtx *, int, int); Statusbar *statusbar; int alignment; Widget *next; diff --git a/statusbar.c b/statusbar.c index 0055e13ae..db2f27446 100644 --- a/statusbar.c +++ b/statusbar.c @@ -50,13 +50,13 @@ statusbar_draw(int screen) for(widget = vscreen.statusbar.widgets; widget; widget = widget->next) if (widget->alignment == AlignLeft) - left += widget->draw(ctx, screen, left, (left + right), AlignLeft); + left += widget->draw(widget, ctx, left, (left + right)); else if (widget->alignment == AlignRight) - right += widget->draw(ctx, screen, right, (left + right), AlignRight); + right += widget->draw(widget, ctx, right, (left + right)); for(widget = vscreen.statusbar.widgets; widget; widget = widget->next) if (widget->alignment == AlignFlex) - left += widget->draw(ctx, screen, left, (left + right), AlignFlex); + left += widget->draw(widget, ctx, left, (left + right)); if(vscreen.statusbar.position == BarRight || vscreen.statusbar.position == BarLeft) { diff --git a/widget.c b/widget.c index 0b3193b33..f4830774c 100644 --- a/widget.c +++ b/widget.c @@ -24,8 +24,11 @@ calculate_alignments(Widget *widget) } if(widget) - for(; widget; widget = widget->next) + for(; widget; widget = widget->next){ + if (widget->alignment == AlignFlex) + warn("Multiple flex widgets in panel - ignoring flex for all but the first."); widget->alignment = AlignRight; + } } int diff --git a/widgets/focustitle.c b/widgets/focustitle.c index 75429c164..7aad756ad 100644 --- a/widgets/focustitle.c +++ b/widgets/focustitle.c @@ -6,11 +6,11 @@ extern awesome_config globalconf; static char name[] = "focustitle"; static int -focustitle_draw(DrawCtx *ctx, int screen, int offset, int used, int align) +focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used) { Client *sel = globalconf.focus->client; - VirtScreen vscreen = globalconf.screens[screen]; - int location = calculate_offset(vscreen.statusbar.width, 0, offset, align); + VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; + int location = calculate_offset(vscreen.statusbar.width, 0, offset, widget->alignment); if(sel) { diff --git a/widgets/layoutinfo.c b/widgets/layoutinfo.c index 4937364e6..497c51bd5 100644 --- a/widgets/layoutinfo.c +++ b/widgets/layoutinfo.c @@ -7,21 +7,19 @@ extern awesome_config globalconf; static char name[] = "layoutinfo"; static int -layoutinfo_draw(DrawCtx *ctx, int screen, int offset, - int used __attribute__ ((unused)), - int align __attribute__ ((unused))) +layoutinfo_draw(Widget *widget, DrawCtx *ctx, int offset, int used __attribute__ ((unused))) { int width = 0, location; - VirtScreen vscreen = globalconf.screens[screen]; + VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; Layout *l; for(l = vscreen.layouts ; l; l = l->next) width = MAX(width, (textwidth(ctx, vscreen.font, l->symbol))); - location = calculate_offset(vscreen.statusbar.width, width, offset, align); + location = calculate_offset(vscreen.statusbar.width, width, offset, widget->alignment); drawtext(ctx, location, 0, width, vscreen.statusbar.height, vscreen.font, - get_current_layout(screen)->symbol, + get_current_layout(widget->statusbar->screen)->symbol, vscreen.colors_normal); return width; } diff --git a/widgets/taglist.c b/widgets/taglist.c index 9c96327d2..5bce17e61 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -25,15 +25,14 @@ isoccupied(int screen, Tag *t) } static int -taglist_draw(DrawCtx *ctx, - int screen, +taglist_draw(Widget *widget, + DrawCtx *ctx, int offset, - int used __attribute__ ((unused)), - int align __attribute__ ((unused))) + int used __attribute__ ((unused))) { Tag *tag; Client *sel = globalconf.focus->client; - VirtScreen vscreen = globalconf.screens[screen]; + VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; int w = 0, width = 0, location; int flagsize; XColor *colors; @@ -44,7 +43,7 @@ taglist_draw(DrawCtx *ctx, { width += textwidth(ctx, vscreen.font, tag->name); } - location = calculate_offset(vscreen.statusbar.width, width, offset, align); + location = calculate_offset(vscreen.statusbar.width, width, offset, widget->alignment); width = 0; for(tag = vscreen.tags; tag; tag = tag->next) @@ -56,9 +55,9 @@ taglist_draw(DrawCtx *ctx, colors = vscreen.colors_normal; drawtext(ctx, location + width, 0, w, vscreen.statusbar.height, vscreen.font, tag->name, colors); - if(isoccupied(screen, tag)) + if(isoccupied(widget->statusbar->screen, tag)) drawrectangle(ctx, location + width, 0, flagsize, flagsize, - sel && is_client_tagged(sel, tag, screen), + sel && is_client_tagged(sel, tag, widget->statusbar->screen), colors[ColFG]); width += w; } diff --git a/widgets/textbox.c b/widgets/textbox.c index a8f8b6ca0..4233204b6 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -6,15 +6,14 @@ extern awesome_config globalconf; static char name[] = "textbox"; static int -textbox_draw(DrawCtx *ctx, - int screen __attribute__ ((unused)), +textbox_draw(Widget *widget, + DrawCtx *ctx, int offset, - int used __attribute__ ((unused)), - int align) + int used __attribute__ ((unused))) { - VirtScreen vscreen = globalconf.screens[screen]; + VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; int width = textwidth(ctx, vscreen.font, vscreen.statustext); - int location = calculate_offset(vscreen.statusbar.width, width, offset, align); + int location = calculate_offset(vscreen.statusbar.width, width, offset, widget->alignment); drawtext(ctx, location, 0, width, vscreen.statusbar.height, vscreen.font, vscreen.statustext, vscreen.colors_normal); return width;