diff --git a/awesomerc.1.txt b/awesomerc.1.txt index b64a9246..6db4a9c9 100644 --- a/awesomerc.1.txt +++ b/awesomerc.1.txt @@ -141,6 +141,8 @@ This widget shows the tag list. Horizontal offset (auto-alignment if not set). *y*:: Vertical offset (auto-alignment if not set). +*align*:: + Widget alignment. layoutinfo ~~~~~~~~~~ @@ -152,6 +154,8 @@ This widget shows a icon for the selected layout. Horizontal offset (auto-alignment if not set). *y*:: Vertical offset (auto-alignment if not set). +*align*:: + Widget alignment. focusicon ~~~~~~~~~ @@ -163,6 +167,8 @@ This widget shows a icon for the focused window using NET_WM_ICON or icon file Horizontal offset (auto-alignment if not set). *y*:: Vertical offset (auto-alignment if not set). +*align*:: + Widget alignment. tasklist ~~~~~~~~ @@ -213,6 +219,8 @@ This widget shows a text. Horizontal offset (auto-alignment if not set). *y*:: Vertical offset (auto-alignment if not set). +*align*:: + Widget alignment. iconbox ~~~~~~~ @@ -228,6 +236,8 @@ This widget shows an icon. Horizontal offset (auto-alignment if not set). *y*:: Vertical offset (auto-alignment if not set). +*align*:: + Widget alignment. progressbar ~~~~~~~~~~~ @@ -257,6 +267,8 @@ This widget shows one or more progress-bars. Horizontal offset (auto-alignment if not set). *y*:: Vertical offset (auto-alignment if not set). +*align*:: + Widget alignment. graph ~~~~~ @@ -292,6 +304,8 @@ This widget shows a graph. Horizontal offset (auto-alignment if not set). *y*:: Vertical offset (auto-alignment if not set). +*align*:: + Widget alignment. OPTIONS -------- @@ -379,6 +393,7 @@ screen [MULTI] taglist [MULTI] { x = y = + align = <{auto,right,left}> mouse [MULTI] { button = modkey = {, ...} @@ -388,6 +403,7 @@ screen [MULTI] layoutinfo { x = y = + align = <{auto,right,left}> mouse [MULTI] { button = modkey = {, ...} @@ -397,6 +413,7 @@ screen [MULTI] focusicon { x = y = + align = <{auto,right,left}> mouse [MULTI] { button = modkey = {, ...} @@ -412,7 +429,7 @@ screen [MULTI] font = show_icons = show = <{all,tags,focus}> - align = <{center,left,right}> + text_align = <{center,left,right}> x = y = mouse [MULTI] { @@ -427,8 +444,9 @@ screen [MULTI] fg = font = width = - align = <{center,left,right}> + text_align = <{center,left,right}> x = y = + align = <{auto,right,left}> mouse [MULTI] { button = modkey = {, ...} @@ -440,6 +458,7 @@ screen [MULTI] image = resize = x = y = + align = <{auto,right,left}> mouse [MULTI] { button = modkey = {, ...} @@ -458,6 +477,7 @@ screen [MULTI] height = padding = x = y = + align = <{auto,right,left}> mouse [MULTI] { button = modkey = {, ...} @@ -477,6 +497,7 @@ screen [MULTI] bg = bordercolor = x = y = + align = <{auto,right,left}> mouse [MULTI] { button = modkey = {, ...} diff --git a/common/configopts.c b/common/configopts.c index 6977ac79..aef97186 100644 --- a/common/configopts.c +++ b/common/configopts.c @@ -71,6 +71,7 @@ cfg_opt_t widget_opts[] = { CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), + CFG_STR((char *) "align", (char *) "auto", CFGF_NONE), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_END() }; @@ -78,6 +79,7 @@ cfg_opt_t widget_taglist_opts[] = { CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), + CFG_STR((char *) "align", (char *) "auto", CFGF_NONE), CFG_SEC((char *) "mouse", mouse_taglist_opts, CFGF_MULTI), CFG_END() }; @@ -85,6 +87,7 @@ cfg_opt_t widget_iconbox_opts[] = { CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), + CFG_STR((char *) "align", (char *) "auto", CFGF_NONE), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_STR((char *) "image", (char *) NULL, CFGF_NONE), CFG_BOOL((char *) "resize", cfg_true, CFGF_NONE), @@ -94,6 +97,7 @@ cfg_opt_t widget_textbox_opts[] = { CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), + CFG_STR((char *) "align", (char *) "auto", CFGF_NONE), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_INT((char *) "width", 0, CFGF_NONE), CFG_STR((char *) "text", (char *) NULL, CFGF_NONE), @@ -132,6 +136,7 @@ cfg_opt_t widget_graph_opts[] = { CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), + CFG_STR((char *) "align", (char *) "auto", CFGF_NONE), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "data", widget_graph_data_opts, CFGF_MULTI), CFG_INT((char *) "width", 100, CFGF_NONE), @@ -154,6 +159,7 @@ cfg_opt_t widget_progressbar_opts[] = { CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), + CFG_STR((char *) "align", (char *) "auto", CFGF_NONE), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "bar", widget_progressbar_bar_opts, CFGF_MULTI), CFG_INT((char *) "width", 100, CFGF_NONE), diff --git a/common/draw.c b/common/draw.c index 475cb077..0db339f1 100644 --- a/common/draw.c +++ b/common/draw.c @@ -535,12 +535,14 @@ draw_textwidth(Display *disp, XftFont *font, char *text) Alignment draw_get_align(const char *align) { - if(!a_strncmp(align, "center", 6)) + if(!a_strncmp(align, "left", 4)) + return AlignLeft; + else if(!a_strncmp(align, "center", 6)) return AlignCenter; else if(!a_strncmp(align, "right", 5)) return AlignRight; - return AlignLeft; + return AlignAuto; } /** Initialize an X color diff --git a/common/draw.h b/common/draw.h index 695518f6..1437d61c 100644 --- a/common/draw.h +++ b/common/draw.h @@ -33,8 +33,9 @@ typedef enum { AlignLeft, AlignRight, + AlignCenter, AlignFlex, - AlignCenter + AlignAuto } Alignment; typedef struct Area Area; diff --git a/statusbar.c b/statusbar.c index c0bbe8e0..5b51df97 100644 --- a/statusbar.c +++ b/statusbar.c @@ -72,7 +72,7 @@ static void statusbar_draw(Statusbar *statusbar) { int phys_screen = get_phys_screen(statusbar->screen); - Widget *widget, *last_drawn = NULL; + Widget *widget; int left = 0, right = 0; Area rectangle = { 0, 0, 0, 0, NULL }; Drawable d; @@ -116,13 +116,13 @@ statusbar_draw(Statusbar *statusbar) } /* renders right widget from last to first */ - for(widget = statusbar->widgets; widget; widget = widget->next) - if (widget->alignment == AlignRight && last_drawn == widget->next) + for(widget = *widget_list_last(&statusbar->widgets); + widget; + widget = widget_list_prev(&statusbar->widgets, widget)) + if (widget->alignment == AlignRight) { widget->cache.needs_update = False; right += widget->draw(widget, ctx, right, (left + right)); - last_drawn = widget; - widget = statusbar->widgets; } for(widget = statusbar->widgets; widget; widget = widget->next) diff --git a/widget.c b/widget.c index 68159c04..2b6ebbe7 100644 --- a/widget.c +++ b/widget.c @@ -31,23 +31,18 @@ extern AwesomeConf globalconf; void widget_calculate_alignments(Widget *widget) { - for(; widget; widget = widget->next) - { - if(widget->alignment == AlignFlex) - { - widget = widget->next; - break; - } - widget->alignment = AlignLeft; - } + for(; widget && widget->alignment != AlignFlex; widget = widget->next) + if(widget->alignment == AlignAuto) + widget->alignment = AlignLeft; if(widget) - for(; widget; widget = widget->next) + for(widget = widget->next; widget; widget = widget->next) { - if (widget->alignment == AlignFlex) + if(widget->alignment == AlignFlex) warn("Multiple flex widgets in panel -" " ignoring flex for all but the first."); - widget->alignment = AlignRight; + if(widget->alignment == AlignAuto) + widget->alignment = AlignRight; } } diff --git a/widgets/focusicon.c b/widgets/focusicon.c index 862ff163..0c7599d6 100644 --- a/widgets/focusicon.c +++ b/widgets/focusicon.c @@ -100,6 +100,7 @@ focusicon_new(Statusbar *statusbar, cfg_t *config) w = p_new(Widget, 1); widget_common_new(w, statusbar, config); w->draw = focusicon_draw; + w->alignment = draw_get_align(cfg_getstr(config, "align")); /* Set cache property */ w->cache.flags = WIDGET_CACHE_CLIENTS; diff --git a/widgets/iconbox.c b/widgets/iconbox.c index fa4855e7..9b9d2428 100644 --- a/widgets/iconbox.c +++ b/widgets/iconbox.c @@ -81,6 +81,7 @@ iconbox_new(Statusbar *statusbar, cfg_t *config) w = p_new(Widget, 1); widget_common_new(w, statusbar, config); + w->alignment = draw_get_align(cfg_getstr(config, "align")); w->draw = iconbox_draw; w->tell = iconbox_tell; w->data = d = p_new(Data, 1); diff --git a/widgets/layoutinfo.c b/widgets/layoutinfo.c index 111aec27..460978cb 100644 --- a/widgets/layoutinfo.c +++ b/widgets/layoutinfo.c @@ -64,6 +64,7 @@ layoutinfo_new(Statusbar *statusbar, cfg_t* config) w = p_new(Widget, 1); widget_common_new(w, statusbar, config); w->draw = layoutinfo_draw; + w->alignment = draw_get_align(cfg_getstr(config, "align")); /* Set cache property */ w->cache.flags = WIDGET_CACHE_LAYOUTS; diff --git a/widgets/progressbar.c b/widgets/progressbar.c index da3c2524..7a029f79 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -149,6 +149,7 @@ progressbar_new(Statusbar *statusbar, cfg_t *config) w->tell = progressbar_tell; d = w->data = p_new(Data, 1); d->width = cfg_getint(config, "width"); + w->alignment = draw_get_align(cfg_getstr(config, "align")); if(!(d->bars = cfg_size(config, "bar"))) { diff --git a/widgets/taglist.c b/widgets/taglist.c index 7f806275..bd398d8f 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -193,6 +193,7 @@ taglist_new(Statusbar *statusbar, cfg_t *config) widget_common_new(w, statusbar, config); w->draw = taglist_draw; w->button_press = taglist_button_press; + w->alignment = draw_get_align(cfg_getstr(config, "align")); /* Set cache property */ w->cache.flags = WIDGET_CACHE_TAGS | WIDGET_CACHE_CLIENTS; diff --git a/widgets/textbox.c b/widgets/textbox.c index bf7fcaca..48c7a1c9 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -104,6 +104,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config) widget_common_new(w, statusbar, config); w->draw = textbox_draw; w->tell = textbox_tell; + w->alignment = draw_get_align(cfg_getstr(config, "align")); w->data = d = p_new(Data, 1); @@ -127,6 +128,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config) w->font = globalconf.screens[statusbar->screen].font; d->text = a_strdup(cfg_getstr(config, "text")); + return w; } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80