diff --git a/statusbar.c b/statusbar.c index cdfde723..0ffa9f40 100644 --- a/statusbar.c +++ b/statusbar.c @@ -113,6 +113,8 @@ statusbar_draw(statusbar_t *statusbar) int left = 0, right = 0; area_t rectangle = { 0, 0, 0, 0, NULL, NULL }; + statusbar->need_update = false; + if(!statusbar->position) return; @@ -123,27 +125,18 @@ statusbar_draw(statusbar_t *statusbar) for(widget = statusbar->widgets; widget; widget = widget->next) if (widget->alignment == AlignLeft) - { - widget->cache.needs_update = false; left += widget->draw(widget, statusbar->ctx, left, (left + right)); - } /* renders right widget from last to first */ 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, statusbar->ctx, right, (left + right)); - } for(widget = statusbar->widgets; widget; widget = widget->next) if (widget->alignment == AlignFlex) - { - widget->cache.needs_update = false; left += widget->draw(widget, statusbar->ctx, left, (left + right)); - } switch(statusbar->position) { @@ -263,18 +256,16 @@ statusbar_refresh() { int screen; statusbar_t *statusbar; - widget_t *widget; for(screen = 0; screen < globalconf.screens_info->nscreen; screen++) for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next) - for(widget = statusbar->widgets; widget; widget = widget->next) - if(widget->cache.needs_update) - { - statusbar_draw(statusbar); - break; - } + if(statusbar->need_update) + { + statusbar_draw(statusbar); + break; + } } statusbar_t * diff --git a/structs.h b/structs.h index c6d490b6..ba918875 100644 --- a/structs.h +++ b/structs.h @@ -136,12 +136,8 @@ struct widget_t area_t area; /** Buttons bindings */ Button *buttons; - /** Cache */ - struct - { - bool needs_update; - int flags; - } cache; + /** Cache flags */ + int cache_flags; /** Next and previous widgets */ widget_t *prev, *next; }; @@ -169,6 +165,8 @@ struct statusbar_t widget_t *widgets; /** Draw context */ draw_context_t *ctx; + /** Need update */ + bool need_update; /** Next and previous statusbars */ statusbar_t *prev, *next; }; diff --git a/widget.c b/widget.c index 5c9c9926..f95542fe 100644 --- a/widget.c +++ b/widget.c @@ -166,8 +166,8 @@ widget_invalidate_cache(int screen, int flags) statusbar; statusbar = statusbar->next) for(widget = statusbar->widgets; widget; widget = widget->next) - if(widget->cache.flags & flags) - widget->cache.needs_update = true; + if(widget->cache_flags & flags) + statusbar->need_update = true; } /** Send commands to widgets. @@ -243,7 +243,7 @@ uicb_widget_tell(int screen, char *arg) property, widget->name); break; case WIDGET_NOERROR: - widget->cache.needs_update = true; + widget->statusbar->need_update = true; break; case WIDGET_ERROR_CUSTOM: break; diff --git a/widgets/focusicon.c b/widgets/focusicon.c index 296ae982..cdebae14 100644 --- a/widgets/focusicon.c +++ b/widgets/focusicon.c @@ -98,7 +98,7 @@ focusicon_new(statusbar_t *statusbar, cfg_t *config) w->alignment = cfg_getalignment(config, "align"); /* Set cache property */ - w->cache.flags = WIDGET_CACHE_CLIENTS; + w->cache_flags = WIDGET_CACHE_CLIENTS; return w; } diff --git a/widgets/layoutinfo.c b/widgets/layoutinfo.c index 748a64c5..12364670 100644 --- a/widgets/layoutinfo.c +++ b/widgets/layoutinfo.c @@ -67,7 +67,7 @@ layoutinfo_new(statusbar_t *statusbar, cfg_t* config) w->alignment = cfg_getalignment(config, "align"); /* Set cache property */ - w->cache.flags = WIDGET_CACHE_LAYOUTS; + w->cache_flags = WIDGET_CACHE_LAYOUTS; return w; } diff --git a/widgets/taglist.c b/widgets/taglist.c index 4978e4a4..a257c856 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -248,7 +248,7 @@ taglist_new(statusbar_t *statusbar, cfg_t *config) d->text_urgent = a_strdup(cfg_getstr(config, "text_urgent")); /* Set cache property */ - w->cache.flags = WIDGET_CACHE_TAGS | WIDGET_CACHE_CLIENTS; + w->cache_flags = WIDGET_CACHE_TAGS | WIDGET_CACHE_CLIENTS; return w; } diff --git a/widgets/tasklist.c b/widgets/tasklist.c index 20e1b3ae..fd968708 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -280,7 +280,7 @@ tasklist_new(statusbar_t *statusbar, cfg_t *config) d->show = ShowFocus; /* Set cache property */ - w->cache.flags = WIDGET_CACHE_CLIENTS; + w->cache_flags = WIDGET_CACHE_CLIENTS; return w; }