mirror of
https://github.com/FelixKratz/SketchyBar
synced 2025-02-17 13:08:28 +00:00
component refresh overhault
This commit is contained in:
parent
8000a3dfcc
commit
ee2918b376
5 changed files with 22 additions and 22 deletions
19
src/bar.c
19
src/bar.c
|
@ -142,25 +142,6 @@ void bar_draw_graph(struct bar* bar, struct bar_item* bar_item, uint32_t x, bool
|
|||
bar_draw_graph_line(bar, &bar_item->graph_data, x, 0, right_to_left);
|
||||
}
|
||||
|
||||
void bar_refresh_components(struct bar *bar) {
|
||||
uint32_t did = display_arrangement(bar->did);
|
||||
uint32_t sid = mission_control_index(display_space_id(bar->did));
|
||||
if (sid == 0) return;
|
||||
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
|
||||
struct bar_item* bar_item = g_bar_manager.bar_items[i];
|
||||
if (((1 << did) & bar_item->associated_display) && strcmp(bar_item->identifier, BAR_COMPONENT_SPACE)== 0) {
|
||||
if (!bar_item->selected && bar_item->associated_space & (1 << sid)) {
|
||||
bar_item->selected = true;
|
||||
strncpy(&bar_item->signal_args.value[1][0], "true", 255);
|
||||
}
|
||||
else if (bar_item->selected && !(bar_item->associated_space & (1 << sid))) {
|
||||
bar_item->selected = false;
|
||||
strncpy(&bar_item->signal_args.value[1][0], "false", 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bar_draw_background(struct bar* bar) {
|
||||
CGContextClearRect(bar->context, bar->frame);
|
||||
CGContextSetRGBFillColor(bar->context, g_bar_manager.background_color.r, g_bar_manager.background_color.g, g_bar_manager.background_color.b, g_bar_manager.background_color.a);
|
||||
|
|
|
@ -47,7 +47,6 @@ struct bar {
|
|||
CGPoint origin;
|
||||
};
|
||||
|
||||
void bar_refresh_components(struct bar *bar);
|
||||
void bar_refresh(struct bar *bar);
|
||||
void bar_resize(struct bar *bar);
|
||||
struct bar *bar_create(uint32_t did);
|
||||
|
|
|
@ -67,6 +67,7 @@ void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item) {
|
|||
|
||||
strncpy(&bar_item->signal_args.name[0][0], "NAME", 255);
|
||||
strncpy(&bar_item->signal_args.name[1][0], "SELECTED", 255);
|
||||
strncpy(&bar_item->signal_args.value[1][0], "false", 255);
|
||||
}
|
||||
|
||||
void bar_item_script_update(struct bar_item* bar_item, bool forced) {
|
||||
|
|
|
@ -136,8 +136,26 @@ void bar_manager_init(struct bar_manager *bar_manager) {
|
|||
}
|
||||
|
||||
void bar_manager_update_components(struct bar_manager* bar_manager) {
|
||||
for (int i = 0; i < bar_manager->bar_count; i++) {
|
||||
bar_refresh_components(bar_manager->bars[i]);
|
||||
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
|
||||
struct bar_item* bar_item = g_bar_manager.bar_items[i];
|
||||
|
||||
for (int j = 0; j < bar_manager->bar_count; j++) {
|
||||
struct bar* bar = bar_manager->bars[j];
|
||||
uint32_t did = display_arrangement(bar->did);
|
||||
uint32_t sid = mission_control_index(display_space_id(bar->did));
|
||||
if (sid == 0) continue;
|
||||
|
||||
if (((1 << did) & bar_item->associated_display) && strcmp(bar_item->identifier, BAR_COMPONENT_SPACE)== 0) {
|
||||
if (!bar_item->selected && bar_item->associated_space & (1 << sid)) {
|
||||
bar_item->selected = true;
|
||||
strncpy(&bar_item->signal_args.value[1][0], "true", 255);
|
||||
}
|
||||
else if (bar_item->selected && !(bar_item->associated_space & (1 << sid))) {
|
||||
bar_item->selected = false;
|
||||
strncpy(&bar_item->signal_args.value[1][0], "false", 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -419,6 +419,7 @@ static void handle_domain_set(FILE* rsp, struct token domain, char* message) {
|
|||
bar_item->drawing = token_equals(value, ARGUMENT_COMMON_VAL_ON) ? true : false;
|
||||
} else if (token_equals(property, COMMAND_SET_LABEL_HIGHLIGHT)) {
|
||||
struct token value = get_token(&message);
|
||||
printf("Name: %s, value %s \n", token_to_string(name), token_to_string(value));
|
||||
bar_item->label_highlight = token_equals(value, ARGUMENT_COMMON_VAL_ON) ? true : false;
|
||||
bar_item_update_label_color(bar_item);
|
||||
} else if (token_equals(property, COMMAND_SET_ICON_HIGHLIGHT)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue