From 24d3c96c1df3172e1e3dd3759e292e7256a76fd6 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 10 Apr 2022 16:09:40 +0300 Subject: [PATCH] X11: set menu entries to same length While testing the new mouse action menus, it was quite annoying to try and hit some shorter entries. Make all the selectable entries the same maximum length, and with text left justified. --- doc/fixes3-7-0.txt | 1 + win/X11/winmenu.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 7e76d7abc..494e4c1b8 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1371,6 +1371,7 @@ X11: with 'slow' resource set to False, the pop up yn_function didn't always X11: (possibly X11+OSX): if persistent inventory was displayed at time of end-of-game prompting, prompting would stall until that window was manually dismissed +X11: set all selectable menu lines to the same length, left justified General New Features diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index 92bad502d..4b8d15b63 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -1285,6 +1285,7 @@ menu_create_entries(struct xwindow *wp, struct menu *curr_menu) int how = wp->menu_information->how; Arg args[15]; Cardinal num_args; + Dimension cwidth, maxwidth = 0; for (curr = curr_menu->base; curr; curr = curr->next) { char tmpbuf[BUFSZ]; @@ -1296,6 +1297,7 @@ menu_create_entries(struct xwindow *wp, struct menu *curr_menu) num_args = 0; XtSetArg(args[num_args], nhStr(XtNlabel), str); num_args++; + XtSetArg(args[num_args], nhStr(XtNjustify), XtJustifyLeft); num_args++; XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; @@ -1352,6 +1354,22 @@ menu_create_entries(struct xwindow *wp, struct menu *curr_menu) XtAddCallback(linewidget, XtNcallback, menu_select, (XtPointer) curr); prevlinewidget = linewidget; + + if (canpick) { + /* get the current line width */ + XtSetArg(args[0], XtNwidth, &cwidth); + XtGetValues(curr->w, args, ONE); + if (maxwidth < cwidth) + maxwidth = cwidth; + } + } + + /* set all selectable menu entries to the maximum width */ + if (how != PICK_NONE) { + XtSetArg(args[0], XtNwidth, maxwidth); + for (curr = curr_menu->base; curr; curr = curr->next) + if (curr->identifier.a_void) + XtSetValues(curr->w, args, ONE); } }