diff --git a/src/bar.c b/src/bar.c index e153e1cb..4a3d1b04 100644 --- a/src/bar.c +++ b/src/bar.c @@ -40,7 +40,7 @@ void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, struct bar_item* b if (!bar_item->popup.overrides_cell_size) bar_item->popup.cell_size = window->frame.size.height; - popup_calculate_bounds(&bar_item->popup); + popup_calculate_bounds(&bar_item->popup, bar); CGPoint anchor = window->origin; if (bar_item->popup.align == POSITION_CENTER) { @@ -57,6 +57,7 @@ void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, struct bar_item* b : window->frame.size.height); popup_set_anchor(&bar_item->popup, anchor, bar->adid); + popup_calculate_bounds(&bar_item->popup, bar); } void bar_order_item_windows(struct bar* bar) { @@ -218,10 +219,17 @@ void bar_calculate_bounds(struct bar* bar) { window_set_frame(bar_item_get_window(bar_item, bar->adid), frame); if (bar_item->group && group_is_first_member(bar_item->group, bar_item)) { + group_calculate_bounds(bar_item->group, + bar, + (shadow_offsets.x > 0 ? shadow_offsets.x : 0), + y, + bar_item->position == POSITION_RIGHT + || bar_item->position == POSITION_CENTER_LEFT); + CGPoint shadow_offsets = bar_item_calculate_shadow_offsets(bar_item->group->members[0]); - uint32_t group_length = group_get_length(bar_item->group); + uint32_t group_length = group_get_length(bar_item->group, bar); uint32_t group_offset = (bar_item->position == POSITION_RIGHT || bar_item->position == POSITION_CENTER_LEFT) ? group_length diff --git a/src/bar_item.c b/src/bar_item.c index 38844a68..0ac85e0b 100644 --- a/src/bar_item.c +++ b/src/bar_item.c @@ -525,13 +525,6 @@ uint32_t bar_item_calculate_bounds(struct bar_item* bar_item, uint32_t bar_heigh label_position += alias_get_length(&bar_item->alias); } - if (bar_item->group && group_is_first_member(bar_item->group, bar_item)) - group_calculate_bounds(bar_item->group, - x, - y, - bar_item->position == POSITION_RIGHT - || bar_item->position == POSITION_CENTER_LEFT); - text_calculate_bounds(&bar_item->icon, icon_position, content_y + bar_item->y_offset); diff --git a/src/group.c b/src/group.c index cf347844..1bbf6493 100644 --- a/src/group.c +++ b/src/group.c @@ -1,4 +1,5 @@ #include "group.h" +#include "bar.h" struct group* group_create() { struct group* group = malloc(sizeof(struct group)); @@ -44,10 +45,10 @@ bool group_is_first_member(struct group* group, struct bar_item* item) { return false; } -uint32_t group_get_length(struct group* group) { +uint32_t group_get_length(struct group* group, struct bar* bar) { uint32_t length = 0; for (int i = 1; i < group->num_members; i++) { - if (group->members[i]->drawing) { + if (bar_draws_item(bar, group->members[i])) { if (!group->members[i]->has_const_width) length += group->members[i]->background.padding_left + group->members[i]->background.padding_right; @@ -80,9 +81,9 @@ void group_destroy(struct group* group) { free(group); } -void group_calculate_bounds(struct group* group, uint32_t x, uint32_t y, bool rtl) { +void group_calculate_bounds(struct group* group, struct bar* bar, uint32_t x, uint32_t y, bool rtl) { background_calculate_bounds(&group->members[0]->background, x, y); - group->members[0]->background.bounds.size.width = group_get_length(group); + group->members[0]->background.bounds.size.width = group_get_length(group, bar); group->members[0]->background.bounds.origin.x = x; group->members[0]->background.bounds.origin.y = y - group->members[0]->background.bounds.size.height / 2 diff --git a/src/group.h b/src/group.h index 1967e539..c3cbf240 100644 --- a/src/group.h +++ b/src/group.h @@ -1,6 +1,8 @@ #pragma once #include "bar_item.h" +struct bar; + struct group { CGRect bounds; uint32_t num_members; @@ -12,11 +14,11 @@ void group_init(struct group* group); void group_set_name(struct group* group, char* _name); void group_add_member(struct group* group, struct bar_item* item); void group_remove_member(struct group* group, struct bar_item* bar_item); -uint32_t group_get_length(struct group* group); +uint32_t group_get_length(struct group* group, struct bar* bar); bool group_is_first_member(struct group* group, struct bar_item* item); struct bar_item* group_get_first_member(struct group* group); -void group_calculate_bounds(struct group* group, uint32_t x, uint32_t y, bool rtl); +void group_calculate_bounds(struct group* group, struct bar* bar, uint32_t x, uint32_t y, bool rtl); void group_draw(struct group* group, CGContextRef context); void group_destroy(struct group* group); diff --git a/src/mach.c b/src/mach.c index 17f3ca04..b27a4fda 100644 --- a/src/mach.c +++ b/src/mach.c @@ -31,7 +31,7 @@ void mach_receive_message(mach_port_t port, struct mach_buffer* buffer, bool tim 0, sizeof(struct mach_buffer), port, - 10, + 100, MACH_PORT_NULL ); else msg_return = mach_msg(&buffer->message.header, diff --git a/src/popup.c b/src/popup.c index c6a742d6..20473acf 100644 --- a/src/popup.c +++ b/src/popup.c @@ -1,6 +1,7 @@ #include "popup.h" #include "bar_item.h" #include "bar_manager.h" +#include "bar.h" void popup_init(struct popup* popup, struct bar_item* host) { popup->drawing = false; @@ -60,14 +61,14 @@ void popup_order_windows(struct popup* popup) { } } -void popup_calculate_popup_anchor_for_bar_item(struct popup* popup, struct bar_item* bar_item) { +void popup_calculate_popup_anchor_for_bar_item(struct popup* popup, struct bar_item* bar_item, struct bar* bar) { if (popup->adid != g_bar_manager.active_adid) return; struct window* window = bar_item_get_window(bar_item, popup->adid); if (!bar_item->popup.overrides_cell_size) bar_item->popup.cell_size = window->frame.size.height; - popup_calculate_bounds(&bar_item->popup); + popup_calculate_bounds(&bar_item->popup, bar); CGPoint anchor = window->origin; if (bar_item->position != POSITION_POPUP || popup->horizontal) { @@ -97,7 +98,7 @@ void popup_calculate_popup_anchor_for_bar_item(struct popup* popup, struct bar_i popup_set_anchor(&bar_item->popup, anchor, popup->adid); } -void popup_calculate_bounds(struct popup* popup) { +void popup_calculate_bounds(struct popup* popup, struct bar* bar) { uint32_t y = popup->background.border_width; uint32_t x = 0; uint32_t total_item_width = 0; @@ -166,7 +167,7 @@ void popup_calculate_bounds(struct popup* popup) { if (bar_item->group && group_is_first_member(bar_item->group, bar_item)) { - uint32_t group_length = group_get_length(bar_item->group); + uint32_t group_length = group_get_length(bar_item->group, bar); CGRect group_frame = {{frame.origin.x, frame.origin.y }, {group_length, @@ -179,7 +180,7 @@ void popup_calculate_bounds(struct popup* popup) { } if (bar_item->popup.drawing) - popup_calculate_popup_anchor_for_bar_item(popup, bar_item); + popup_calculate_popup_anchor_for_bar_item(popup, bar_item, bar); if (item_width > width && !popup->horizontal) width = item_width; if (popup->horizontal) x += item_width; @@ -278,7 +279,6 @@ void popup_set_anchor(struct popup* popup, CGPoint anchor, uint32_t adid) { } popup->adid = adid; - popup_calculate_bounds(popup); } bool popup_set_drawing(struct popup* popup, bool drawing) { diff --git a/src/popup.h b/src/popup.h index 5f391168..8a5b67dd 100644 --- a/src/popup.h +++ b/src/popup.h @@ -4,6 +4,7 @@ #include "window.h" struct bar_item; +struct bar; struct popup { bool drawing; @@ -36,7 +37,7 @@ bool popup_set_drawing(struct popup* popup, bool drawing); void popup_remove_item(struct popup* popup, struct bar_item* bar_item); uint32_t popup_get_width(struct popup* popup); -void popup_calculate_bounds(struct popup* popup); +void popup_calculate_bounds(struct popup* popup, struct bar* bar); void popup_draw(struct popup* popup); void popup_destroy(struct popup* popup);