Height hard set at number of lines #64

Closed
opened 2025-07-15 21:31:57 +02:00 by fictitiousexistence · 2 comments

If I do
printf "test\ntest" | wmenu -l 50

the resulting wmenu window is 50 lines long covering the whole screen even when there are only 2 menu items.
Is this intended? I expected if the number of lines is less than the -l option then the wmenu window would only be big enough to show all the lines.

If I do `printf "test\ntest" | wmenu -l 50` the resulting wmenu window is 50 lines long covering the whole screen even when there are only 2 menu items. Is this intended? I expected if the number of lines is less than the -l option then the wmenu window would only be big enough to show all the lines.
Owner

Yes, this was intended. However, it seems dmenu doesn't behave this way. I'd be willing to accept a patch to bring wmenu's behavior in line with dmenu's.

Yes, this was intended. However, it seems dmenu doesn't behave this way. I'd be willing to accept a patch to bring wmenu's behavior in line with dmenu's.

I'm not a developer, this works but I'm sure it not correct?

diff --git a/menu.c b/menu.c
index 207d71c..1931976 100644
--- a/menu.c
+++ b/menu.c
@@ -181,6 +181,11 @@ void menu_add_item(struct menu *menu, char *text) {
 	new->text = text;
 
 	menu->item_count++;
+
+	if ((size_t)menu->lines > menu->item_count){
+		menu->height = menu->line_height;
+		menu->height += menu->height * menu->item_count;
+	}
 }
 
 static int compare_items(const void *a, const void *b) {
I'm not a developer, this works but I'm sure it not correct? ``` diff --git a/menu.c b/menu.c index 207d71c..1931976 100644 --- a/menu.c +++ b/menu.c @@ -181,6 +181,11 @@ void menu_add_item(struct menu *menu, char *text) { new->text = text; menu->item_count++; + + if ((size_t)menu->lines > menu->item_count){ + menu->height = menu->line_height; + menu->height += menu->height * menu->item_count; + } } static int compare_items(const void *a, const void *b) { ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
adnano/wmenu#64
No description provided.