minor popup fixes

This commit is contained in:
Felix Kratz 2022-06-14 18:38:35 +02:00
parent 1061558427
commit 1e049fff3a
5 changed files with 13 additions and 9 deletions

View file

@ -36,6 +36,7 @@ bool bar_draws_item(struct bar* bar, struct bar_item* bar_item) {
void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, struct bar_item* bar_item) { void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, struct bar_item* bar_item) {
if (bar->adid != g_bar_manager.active_adid) return; if (bar->adid != g_bar_manager.active_adid) return;
struct window* window = bar_item_get_window(bar_item, bar->adid); struct window* window = bar_item_get_window(bar_item, bar->adid);
if (!bar_item->popup.overrides_cell_size) if (!bar_item->popup.overrides_cell_size)
bar_item->popup.cell_size = window->frame.size.height; bar_item->popup.cell_size = window->frame.size.height;

View file

@ -433,6 +433,7 @@ void bar_manager_update(struct bar_manager* bar_manager, bool forced) {
} }
void bar_manager_reset(struct bar_manager* bar_manager) { void bar_manager_reset(struct bar_manager* bar_manager) {
bar_manager_reset_bar_association(bar_manager);
for (int i = 0; i < bar_manager->bar_count; i++) { for (int i = 0; i < bar_manager->bar_count; i++) {
for (int j = 0; j < bar_manager->bar_item_count; j++) { for (int j = 0; j < bar_manager->bar_item_count; j++) {
struct bar_item* bar_item = bar_manager->bar_items[j]; struct bar_item* bar_item = bar_manager->bar_items[j];

View file

@ -153,7 +153,7 @@ static void handle_domain_add(FILE* rsp, struct token domain, char* message) {
int index = bar_manager_get_item_index_for_name(&g_bar_manager, int index = bar_manager_get_item_index_for_name(&g_bar_manager,
member.text ); member.text );
if (index > 0 if (index >= 0
&& g_bar_manager.bar_items[index]->position == POSITION_POPUP) { && g_bar_manager.bar_items[index]->position == POSITION_POPUP) {
popup_add_item(&g_bar_manager.bar_items[index]->parent->popup, popup_add_item(&g_bar_manager.bar_items[index]->parent->popup,

View file

@ -46,7 +46,7 @@ void popup_order_windows(struct popup* popup, int mode) {
SLSAddWindowToWindowOrderingGroup(g_connection, SLSAddWindowToWindowOrderingGroup(g_connection,
popup->window.id, popup->window.id,
window->id, window->id,
1 ); 1 );
continue; continue;
} }
@ -239,6 +239,9 @@ void popup_set_anchor(struct popup* popup, CGPoint anchor, uint32_t adid) {
if (adid > 0 && (popup->adid != adid)) { if (adid > 0 && (popup->adid != adid)) {
popup->needs_ordering = true; popup->needs_ordering = true;
for (int i = 0; i < popup->num_items; i++) {
bar_item_needs_update(popup->items[i]);
}
} }
popup->adid = adid; popup->adid = adid;
@ -255,13 +258,7 @@ bool popup_set_drawing(struct popup* popup, bool drawing) {
void popup_draw(struct popup* popup) { void popup_draw(struct popup* popup) {
if (!popup->drawing || popup->adid <= 0) return; if (!popup->drawing || popup->adid <= 0) return;
if (popup->needs_ordering) {
popup_order_windows(popup, 1);
popup->needs_ordering = false;
}
window_apply_frame(&popup->window); window_apply_frame(&popup->window);
CGContextClearRect(popup->window.context, popup->background.bounds); CGContextClearRect(popup->window.context, popup->background.bounds);
SLSRemoveAllTrackingAreas(g_connection, popup->window.id); SLSRemoveAllTrackingAreas(g_connection, popup->window.id);
@ -273,6 +270,11 @@ void popup_draw(struct popup* popup) {
popup->background.shadow.enabled = shadow; popup->background.shadow.enabled = shadow;
CGContextFlush(popup->window.context); CGContextFlush(popup->window.context);
if (popup->needs_ordering) {
popup_order_windows(popup, 1);
popup->needs_ordering = false;
}
} }
void popup_destroy(struct popup* popup) { void popup_destroy(struct popup* popup) {

View file

@ -14,7 +14,7 @@ void window_create(struct window* window, CGRect frame) {
window->frame.origin = (CGPoint){0, 0}; window->frame.origin = (CGPoint){0, 0};
window->frame.size = frame.size; window->frame.size = frame.size;
frame.origin = (CGPoint){0, 0}; frame.origin = CGPointZero;
CFTypeRef frame_region = window_create_region(window, frame); CFTypeRef frame_region = window_create_region(window, frame);
uint64_t id; uint64_t id;
SLSNewWindow(g_connection, 2, window->origin.x, window->origin.y, SLSNewWindow(g_connection, 2, window->origin.x, window->origin.y,