diff options
author | adnano <me@adnano.co> | 2024-03-25 08:20:36 -0400 |
---|---|---|
committer | adnano <me@adnano.co> | 2024-03-25 08:20:36 -0400 |
commit | 41b2e8b1e1d1415a43baa6393b7237e7e77468eb (patch) | |
tree | dba597fd79717ededf272a73fd718419d2fd1715 /menu.c | |
parent | ac25b0733885b545578092c5da74c9a3122529d6 (diff) | |
download | wmenu-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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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; |