Fix popup rendering when first adding an item in and removing all items (#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
This commit is contained in:
Capybara121 2024-11-09 03:04:42 +13:00 committed by GitHub
parent cf45542410
commit dc5d29cd0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}
@ -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) {
@ -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;
}