allow hiding items

This commit is contained in:
FelixKratz 2021-08-24 10:56:59 +02:00
parent 3862b91271
commit d3a2194f67
5 changed files with 9 additions and 2 deletions

View file

@ -175,7 +175,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];
if (!bar_item->enabled) continue;
if (!bar_item->enabled || bar_item->hidden) continue;
bar_item->is_shown = false;
if(bar_item->associated_display > 0 && !(bar_item->associated_display & (1 << did))) continue;

View file

@ -8,6 +8,7 @@ struct bar_item* bar_item_create() {
void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item) {
bar_item->enabled = true;
bar_item->hidden = false;
bar_item->is_shown = false;
bar_item->nospace = false;
bar_item->counter = 0;

View file

@ -12,6 +12,7 @@
struct bar_item {
bool enabled;
bool hidden;
bool is_shown;
bool nospace;
int counter;

View file

@ -152,7 +152,7 @@ void bar_manager_check_bar_items_for_update_pattern(struct bar_manager* bar_mana
struct bar_item* bar_manager_get_item_by_point(struct bar_manager* bar_manager, CGPoint point, uint32_t sid) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
struct bar_item* bar_item = bar_manager->bar_items[i];
if (!bar_item->enabled || bar_item->num_rects < sid || bar_item->bounding_rects[sid - 1] == NULL) continue;
if (!bar_item->enabled || bar_item->hidden || bar_item->num_rects < sid || bar_item->bounding_rects[sid - 1] == NULL) continue;
if (cgrect_contains_point(bar_item->bounding_rects[sid - 1], &point)) {
return bar_item;
}

View file

@ -29,6 +29,7 @@ extern bool g_verbose;
#define DOMAIN_SET "set"
#define COMMAND_SET_ENABLED "enabled"
#define COMMAND_SET_HIDDEN "hidden"
#define COMMAND_SET_POSITION "position"
#define COMMAND_SET_ASSOCIATED_DISPLAY "associated_display"
#define COMMAND_SET_ASSOCIATED_SPACE "associated_space"
@ -367,9 +368,13 @@ static void handle_domain_set(FILE* rsp, struct token domain, char* message) {
} else if (token_equals(property, COMMAND_SET_ENABLED)) {
struct token value = get_token(&message);
bar_item->enabled = token_equals(value, ARGUMENT_COMMON_VAL_ON) ? true : false;
} else if (token_equals(property, COMMAND_SET_HIDDEN)) {
struct token value = get_token(&message);
bar_item->hidden = token_equals(value, ARGUMENT_COMMON_VAL_ON) ? true : false;
}
if (bar_item->is_shown)
bar_manager_refresh(&g_bar_manager);
}