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.
This commit is contained in:
Pasi Kallinen
2022-04-10 16:09:40 +03:00
parent a1f2000afd
commit 24d3c96c1d
2 changed files with 19 additions and 0 deletions

View File

@@ -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);
}
}