[statusbar] Separate widget cache inside widets and sbars
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
d4c8edcac0
commit
255d91c711
15
statusbar.c
15
statusbar.c
|
@ -113,6 +113,8 @@ statusbar_draw(statusbar_t *statusbar)
|
||||||
int left = 0, right = 0;
|
int left = 0, right = 0;
|
||||||
area_t rectangle = { 0, 0, 0, 0, NULL, NULL };
|
area_t rectangle = { 0, 0, 0, 0, NULL, NULL };
|
||||||
|
|
||||||
|
statusbar->need_update = false;
|
||||||
|
|
||||||
if(!statusbar->position)
|
if(!statusbar->position)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -123,27 +125,18 @@ statusbar_draw(statusbar_t *statusbar)
|
||||||
|
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if (widget->alignment == AlignLeft)
|
if (widget->alignment == AlignLeft)
|
||||||
{
|
|
||||||
widget->cache.needs_update = false;
|
|
||||||
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
||||||
}
|
|
||||||
|
|
||||||
/* renders right widget from last to first */
|
/* renders right widget from last to first */
|
||||||
for(widget = *widget_list_last(&statusbar->widgets);
|
for(widget = *widget_list_last(&statusbar->widgets);
|
||||||
widget;
|
widget;
|
||||||
widget = widget_list_prev(&statusbar->widgets, widget))
|
widget = widget_list_prev(&statusbar->widgets, widget))
|
||||||
if (widget->alignment == AlignRight)
|
if (widget->alignment == AlignRight)
|
||||||
{
|
|
||||||
widget->cache.needs_update = false;
|
|
||||||
right += widget->draw(widget, statusbar->ctx, right, (left + right));
|
right += widget->draw(widget, statusbar->ctx, right, (left + right));
|
||||||
}
|
|
||||||
|
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if (widget->alignment == AlignFlex)
|
if (widget->alignment == AlignFlex)
|
||||||
{
|
|
||||||
widget->cache.needs_update = false;
|
|
||||||
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
left += widget->draw(widget, statusbar->ctx, left, (left + right));
|
||||||
}
|
|
||||||
|
|
||||||
switch(statusbar->position)
|
switch(statusbar->position)
|
||||||
{
|
{
|
||||||
|
@ -263,14 +256,12 @@ statusbar_refresh()
|
||||||
{
|
{
|
||||||
int screen;
|
int screen;
|
||||||
statusbar_t *statusbar;
|
statusbar_t *statusbar;
|
||||||
widget_t *widget;
|
|
||||||
|
|
||||||
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
||||||
for(statusbar = globalconf.screens[screen].statusbar;
|
for(statusbar = globalconf.screens[screen].statusbar;
|
||||||
statusbar;
|
statusbar;
|
||||||
statusbar = statusbar->next)
|
statusbar = statusbar->next)
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
if(statusbar->need_update)
|
||||||
if(widget->cache.needs_update)
|
|
||||||
{
|
{
|
||||||
statusbar_draw(statusbar);
|
statusbar_draw(statusbar);
|
||||||
break;
|
break;
|
||||||
|
|
10
structs.h
10
structs.h
|
@ -136,12 +136,8 @@ struct widget_t
|
||||||
area_t area;
|
area_t area;
|
||||||
/** Buttons bindings */
|
/** Buttons bindings */
|
||||||
Button *buttons;
|
Button *buttons;
|
||||||
/** Cache */
|
/** Cache flags */
|
||||||
struct
|
int cache_flags;
|
||||||
{
|
|
||||||
bool needs_update;
|
|
||||||
int flags;
|
|
||||||
} cache;
|
|
||||||
/** Next and previous widgets */
|
/** Next and previous widgets */
|
||||||
widget_t *prev, *next;
|
widget_t *prev, *next;
|
||||||
};
|
};
|
||||||
|
@ -169,6 +165,8 @@ struct statusbar_t
|
||||||
widget_t *widgets;
|
widget_t *widgets;
|
||||||
/** Draw context */
|
/** Draw context */
|
||||||
draw_context_t *ctx;
|
draw_context_t *ctx;
|
||||||
|
/** Need update */
|
||||||
|
bool need_update;
|
||||||
/** Next and previous statusbars */
|
/** Next and previous statusbars */
|
||||||
statusbar_t *prev, *next;
|
statusbar_t *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
6
widget.c
6
widget.c
|
@ -166,8 +166,8 @@ widget_invalidate_cache(int screen, int flags)
|
||||||
statusbar;
|
statusbar;
|
||||||
statusbar = statusbar->next)
|
statusbar = statusbar->next)
|
||||||
for(widget = statusbar->widgets; widget; widget = widget->next)
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
||||||
if(widget->cache.flags & flags)
|
if(widget->cache_flags & flags)
|
||||||
widget->cache.needs_update = true;
|
statusbar->need_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send commands to widgets.
|
/** Send commands to widgets.
|
||||||
|
@ -243,7 +243,7 @@ uicb_widget_tell(int screen, char *arg)
|
||||||
property, widget->name);
|
property, widget->name);
|
||||||
break;
|
break;
|
||||||
case WIDGET_NOERROR:
|
case WIDGET_NOERROR:
|
||||||
widget->cache.needs_update = true;
|
widget->statusbar->need_update = true;
|
||||||
break;
|
break;
|
||||||
case WIDGET_ERROR_CUSTOM:
|
case WIDGET_ERROR_CUSTOM:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -98,7 +98,7 @@ focusicon_new(statusbar_t *statusbar, cfg_t *config)
|
||||||
w->alignment = cfg_getalignment(config, "align");
|
w->alignment = cfg_getalignment(config, "align");
|
||||||
|
|
||||||
/* Set cache property */
|
/* Set cache property */
|
||||||
w->cache.flags = WIDGET_CACHE_CLIENTS;
|
w->cache_flags = WIDGET_CACHE_CLIENTS;
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ layoutinfo_new(statusbar_t *statusbar, cfg_t* config)
|
||||||
w->alignment = cfg_getalignment(config, "align");
|
w->alignment = cfg_getalignment(config, "align");
|
||||||
|
|
||||||
/* Set cache property */
|
/* Set cache property */
|
||||||
w->cache.flags = WIDGET_CACHE_LAYOUTS;
|
w->cache_flags = WIDGET_CACHE_LAYOUTS;
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ taglist_new(statusbar_t *statusbar, cfg_t *config)
|
||||||
d->text_urgent = a_strdup(cfg_getstr(config, "text_urgent"));
|
d->text_urgent = a_strdup(cfg_getstr(config, "text_urgent"));
|
||||||
|
|
||||||
/* Set cache property */
|
/* Set cache property */
|
||||||
w->cache.flags = WIDGET_CACHE_TAGS | WIDGET_CACHE_CLIENTS;
|
w->cache_flags = WIDGET_CACHE_TAGS | WIDGET_CACHE_CLIENTS;
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,7 @@ tasklist_new(statusbar_t *statusbar, cfg_t *config)
|
||||||
d->show = ShowFocus;
|
d->show = ShowFocus;
|
||||||
|
|
||||||
/* Set cache property */
|
/* Set cache property */
|
||||||
w->cache.flags = WIDGET_CACHE_CLIENTS;
|
w->cache_flags = WIDGET_CACHE_CLIENTS;
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue