diff --git a/common/tokenize.gperf b/common/tokenize.gperf index d168737e..3e9d5d64 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -23,6 +23,7 @@ east ellipsize end fg +fixed flex floating focus diff --git a/draw.c b/draw.c index d0c6d7b8..6b076445 100644 --- a/draw.c +++ b/draw.c @@ -677,8 +677,8 @@ draw_text_extents(draw_text_context_t *data) } /** Transform a string to a alignment_t type. - * Recognized string are flex, left, center or right. Everything else will be - * recognized as AlignLeft. + * Recognized string are flex, fixed, left, center or right. Everything else + * will be recognized as AlignLeft. * \param align Atring with align text. * \param len The string length. * \return An alignment_t type. @@ -691,6 +691,7 @@ draw_align_fromstr(const char *align, ssize_t len) case A_TK_CENTER: return AlignCenter; case A_TK_RIGHT: return AlignRight; case A_TK_FLEX: return AlignFlex; + case A_TK_FIXED: return AlignFixed; case A_TK_TOP: return AlignTop; case A_TK_BOTTOM: return AlignBottom; default: return AlignLeft; @@ -710,6 +711,7 @@ draw_align_tostr(alignment_t a) case AlignCenter: return "center"; case AlignRight: return "right"; case AlignFlex: return "flex"; + case AlignFixed: return "fixed"; case AlignBottom: return "bottom"; case AlignTop: return "top"; default: return NULL; diff --git a/draw.h b/draw.h index aca90d21..fde0e760 100644 --- a/draw.h +++ b/draw.h @@ -61,6 +61,7 @@ typedef enum AlignTop = (1 << 2), AlignBottom = (1 << 3), AlignFlex = (1 << 4), + AlignFixed = (1 << 5), } alignment_t; typedef struct vector_t vector_t; diff --git a/widget.c b/widget.c index a2d7534a..ffd3d850 100644 --- a/widget.c +++ b/widget.c @@ -64,6 +64,7 @@ widget_calculate_offset(int barwidth, int widgetwidth, int offset, int alignment { case AlignLeft: case AlignFlex: + case AlignFixed: return offset; } return barwidth - offset - widgetwidth; @@ -235,13 +236,14 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t /* save left value */ int fake_left = left; - /* compute width of flex aligned widgets that does not support it */ + /* compute width of flex or fixed aligned widgets */ int flex = 0; for(int i = 0; i < widgets->len; i++) - if(widgets->tab[i].widget->align == AlignFlex + if(widgets->tab[i].widget->align & (AlignFlex | AlignFixed) && widgets->tab[i].widget->isvisible) { - if(widgets->tab[i].widget->align_supported & AlignFlex) + if(widgets->tab[i].widget->align_supported & AlignFlex + && widgets->tab[i].widget->align == AlignFlex) flex++; else fake_left += widgets->tab[i].widget->geometry(widgets->tab[i].widget, @@ -252,10 +254,11 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t /* now compute everybody together! */ int flex_rendered = 0; for(int i = 0; i < widgets->len; i++) - if(widgets->tab[i].widget->align == AlignFlex + if(widgets->tab[i].widget->align & (AlignFlex | AlignFixed) && widgets->tab[i].widget->isvisible) { - if(widgets->tab[i].widget->align_supported & AlignFlex) + if(widgets->tab[i].widget->align_supported & AlignFlex + && widgets->tab[i].widget->align == AlignFlex) { int width = (ctx->width - (right + fake_left)) / flex; /* give last pixels to last flex to be rendered */ @@ -269,7 +272,7 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t else widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget, screen, ctx->height, - ctx->width - (left + right)); + ctx->width - (left + right)); widgets->tab[i].geometry.x = left; left += widgets->tab[i].geometry.width; } @@ -389,7 +392,7 @@ luaA_widget_new(lua_State *L) w->type = wc; align = luaA_getopt_lstring(L, 2, "align", "left", &len); - w->align_supported |= AlignLeft | AlignRight; + w->align_supported |= AlignLeft | AlignRight | AlignFixed; w->align = draw_align_fromstr(align, len); /* Set visible by default. */