From 81b320ae264772eb3036d88bea53811ccf1c6dfc Mon Sep 17 00:00:00 2001 From: Capybara121 <97924274+Capybara121@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:27:58 +1200 Subject: [PATCH 1/2] Fixed off-by-1 error --- src/bar.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bar.c b/src/bar.c index 7d43b07..3816e13 100644 --- a/src/bar.c +++ b/src/bar.c @@ -244,10 +244,10 @@ static void bar_calculate_bounds_top_bottom(struct bar* bar) { - center_length) / 2 - 1; uint32_t bar_center_right_first_item_x = (bar->window.frame.size.width - + notch_width) / 2 - 1; + + notch_width) / 2; uint32_t bar_center_left_first_item_x = (bar->window.frame.size.width - - notch_width) / 2 - 1; + - notch_width) / 2; uint32_t* next_position = NULL; uint32_t y = bar->window.frame.size.height / 2; @@ -364,10 +364,10 @@ static void bar_calculate_bounds_left_right(struct bar* bar) { - center_length) / 2 - 1; uint32_t bar_center_right_first_item_y = (bar->window.frame.size.height - + notch_width) / 2 - 1; + + notch_width) / 2; uint32_t bar_center_left_first_item_y = (bar->window.frame.size.height - - notch_width) / 2 - 1; + - notch_width) / 2 ; uint32_t* next_position = NULL; From c1c607a5f186e60e3eef5bf6a8abd9be46b7f22f Mon Sep 17 00:00:00 2001 From: Capybara121 <97924274+Capybara121@users.noreply.github.com> Date: Mon, 14 Oct 2024 08:24:32 +1300 Subject: [PATCH 2/2] Separate popup_close_window from popup.drawing and draw/close popups when first/last items are being added/removed --- src/popup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/popup.c b/src/popup.c index 65cc49f..c770851 100644 --- a/src/popup.c +++ b/src/popup.c @@ -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; }