[statusbar] Separate widget cache inside widets and sbars

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-13 16:48:33 +02:00
parent d4c8edcac0
commit 255d91c711
7 changed files with 18 additions and 29 deletions

View file

@ -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 *

View file

@ -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;
};

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}