only refresh bar for items that are actually shown

This commit is contained in:
FelixKratz 2021-08-22 22:56:44 +02:00
parent 1eefbe821d
commit 58683ba4c2
4 changed files with 6 additions and 1 deletions

View file

@ -211,6 +211,7 @@ void bar_refresh(struct bar *bar)
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
struct bar_item* bar_item = g_bar_manager.bar_items[i];
bar_item->is_shown = false;
if(bar_item->associated_display > 0 && !(bar_item->associated_display & (1 << did))) continue;
if((strcmp(bar_item->identifier, BAR_COMPONENT_SPACE) != 0) && bar_item->associated_space > 0 && !(bar_item->associated_space & (1 << sid))) continue;
@ -257,6 +258,7 @@ void bar_refresh(struct bar *bar)
bar_draw_line(bar, *label, label_position.x, label_position.y);
bar_item->label_line.bounds.origin = label_position;
bar_item->icon_line.bounds.origin = icon_position;
bar_item->is_shown = true;
bar_item_set_bounding_rect_for_space(bar_item, sid, bar->origin);
}

View file

@ -7,6 +7,7 @@ struct bar_item* bar_item_create() {
}
void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item) {
bar_item->is_shown = false;
bar_item->nospace = false;
bar_item->counter = 0;
bar_item->name = "";

View file

@ -13,6 +13,7 @@
#define UPDATE_TITLE_CHANGE 1 << 5
struct bar_item {
bool is_shown;
bool nospace;
int counter;
char type;

View file

@ -352,6 +352,7 @@ static void handle_domain_set(FILE* rsp, struct token domain, char* message) {
bar_item->cache_scripts = token_equals(value, ARGUMENT_COMMON_VAL_ON) ? true : false;
}
if (bar_item->is_shown)
bar_manager_refresh(&g_bar_manager);
}