aboutsummaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authoradnano <me@adnano.co>2024-03-25 08:20:36 -0400
committeradnano <me@adnano.co>2024-03-25 08:20:36 -0400
commit41b2e8b1e1d1415a43baa6393b7237e7e77468eb (patch)
treedba597fd79717ededf272a73fd718419d2fd1715 /menu.c
parentac25b0733885b545578092c5da74c9a3122529d6 (diff)
downloadwmenu-41b2e8b1e1d1415a43baa6393b7237e7e77468eb.tar.gz
menu: Avoid adding zero-size pages
Ensure that pages always have at least one item, even if that item is too big to fit on any page.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/menu.c b/menu.c
index f95409f..e4a8e1c 100644
--- a/menu.c
+++ b/menu.c
@@ -219,11 +219,13 @@ static void page_items(struct menu *menu) {
page->first = item;
int total_width = 0;
+ int items = 0;
while (item) {
total_width += item->width + 2 * menu->padding;
- if (total_width > max_width) {
+ if (total_width > max_width && items > 0) {
break;
}
+ items++;
item->page = page;
page->last = item;