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.
This commit is contained in:
parent
ac25b07338
commit
41b2e8b1e1
1 changed files with 3 additions and 1 deletions
4
menu.c
4
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue