Skip to content

Commit

Permalink
Fix popup rendering when first adding an item in and removing all ite…
Browse files Browse the repository at this point in the history
…ms (#631)

* Fixed off-by-1 error

* Separate popup_close_window from popup.drawing and draw/close popups when first/last items are being added/removed
  • Loading branch information
Capybara121 authored Nov 8, 2024
1 parent cf45542 commit dc5d29c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ static void popup_create_window(struct popup* popup) {
}

static void popup_close_window(struct popup* popup) {
popup->drawing = false;
if (popup == &g_bar_manager.default_item.popup) return;
window_close(&popup->window);
}
Expand All @@ -276,6 +275,9 @@ void popup_add_item(struct popup* popup, struct bar_item* bar_item) {
popup->items[popup->num_items - 1] = bar_item;
bar_item->parent = popup->host;
popup->needs_ordering = true;
if (popup->num_items == 1){
popup_draw(popup);
}
}

void popup_remove_item(struct popup* popup, struct bar_item* bar_item) {
Expand All @@ -285,6 +287,7 @@ void popup_remove_item(struct popup* popup, struct bar_item* bar_item) {
free(popup->items);
popup->items = NULL;
popup->num_items = 0;
popup_close_window(popup);
return;
}

Expand Down

0 comments on commit dc5d29c

Please sign in to comment.