X11: Obey menu movement keys

This commit is contained in:
Pasi Kallinen
2018-10-18 18:39:27 +03:00
parent c687bb7cd8
commit fa5e5ac4b4
4 changed files with 40 additions and 7 deletions

View File

@@ -241,6 +241,7 @@ X11: remember perm_invent window geometry
X11: handle X errors via panic
X11: don't reuse perm_invent window for picking an object
X11: obey mouse_support and allow toggling it in game
X11: obey menu movement keys
General New Features

View File

@@ -307,6 +307,7 @@ E void FDECL(highlight_yn, (BOOLEAN_P));
E void FDECL(nh_XtPopup, (Widget, int, Widget));
E void FDECL(nh_XtPopdown, (Widget));
E void FDECL(win_X11_init, (int));
E void FDECL(find_scrollbars, (Widget, Widget *, Widget *));
E void FDECL(nh_keyscroll, (Widget, XEvent *, String *, Cardinal *));
/* ### winmesg.c ### */

View File

@@ -2548,6 +2548,20 @@ int dir;
return;
}
void
find_scrollbars(w, horiz, vert)
Widget w;
Widget *horiz, *vert;
{
if (w) {
do {
*horiz = XtNameToWidget(w, "*horizontal");
*vert = XtNameToWidget(w, "*vertical");
w = XtParent(w);
} while (!*horiz && !*vert && w);
}
}
/* Callback
* Scroll a viewport, using standard NH 1,2,3,4,6,7,8,9 directions.
*/
@@ -2560,7 +2574,7 @@ String *params;
Cardinal *num_params;
{
Arg arg[2];
Widget horiz_sb, vert_sb, scrollw;
Widget horiz_sb = (Widget) 0, vert_sb = (Widget) 0;
float top, shown;
Boolean do_call;
int direction;
@@ -2573,12 +2587,7 @@ Cardinal *num_params;
direction = atoi(params[0]);
scrollw = viewport;
do {
horiz_sb = XtNameToWidget(scrollw, "*horizontal");
vert_sb = XtNameToWidget(scrollw, "*vertical");
scrollw = XtParent(scrollw);
} while (!horiz_sb && !vert_sb && scrollw);
find_scrollbars(viewport, &horiz_sb, &vert_sb);
#define H_DELTA 0.25 /* distance of horiz shift */
/* vert shift is half of curr distance */

View File

@@ -21,6 +21,7 @@
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/Cardinals.h>
#include <X11/Xaw/Scrollbar.h>
#include <X11/Xaw/Box.h>
#include <X11/Xos.h>
@@ -324,6 +325,27 @@ Cardinal *num_params;
else
X11_nhbell();
return;
} else if (ch == MENU_FIRST_PAGE || ch == MENU_LAST_PAGE) {
Widget hbar = (Widget) 0, vbar = (Widget) 0;
float top = (ch == MENU_FIRST_PAGE) ? 0.0 : 1.0;
find_scrollbars(wp->w, &hbar, &vbar);
if (vbar)
XtCallCallbacks(vbar, XtNjumpProc, &top);
return;
} else if (ch == MENU_NEXT_PAGE || ch == MENU_PREVIOUS_PAGE) {
Widget hbar = (Widget) 0, vbar = (Widget) 0;
find_scrollbars(wp->w, &hbar, &vbar);
if (vbar) {
float shown, top;
Arg arg[2];
XtSetArg(arg[0], nhStr(XtNshown), &shown);
XtSetArg(arg[1], nhStr(XtNtopOfThumb), &top);
XtGetValues(vbar, arg, TWO);
top += ((ch == MENU_NEXT_PAGE) ? shown : -shown);
if (vbar)
XtCallCallbacks(vbar, XtNjumpProc, &top);
}
return;
} else if (index(menu_info->curr_menu.gacc, ch)) {
group_accel:
/* matched a group accelerator */