MCPcopy Create free account
hub / github.com/NetHack/NetHack / menu_scrollmask

Function menu_scrollmask

win/X11/winmenu.c:619–649  ·  view source on GitHub ↗

construct a bit mask specifying which scrolling operations are allowed */

Source from the content-addressed store, hash-verified

617
618/* construct a bit mask specifying which scrolling operations are allowed */
619static unsigned
620menu_scrollmask(struct xwindow *wp)
621{
622 float shown, top;
623 Arg args[2];
624 Widget hbar = (Widget) 0, vbar = (Widget) 0;
625 unsigned scrlmask = 0U;
626
627 /* set up args once, then use twice (provided that both scrollbars are
628 present); 'top' is left for horizontal scrollbar */
629 (void) memset(args, 0, sizeof args);
630 XtSetArg(args[0], nhStr(XtNshown), &shown);
631 XtSetArg(args[1], nhStr(XtNtopOfThumb), &top);
632
633 find_scrollbars(wp->w, wp->popup, &hbar, &vbar);
634 if (vbar) {
635 XtGetValues(vbar, args, TWO);
636 if (top > 0.0)
637 scrlmask |= 1U; /* not at top; can scroll up */
638 if (top + shown < 1.0)
639 scrlmask |= 2U; /* more beyond bottom; can scroll down */
640 }
641 if (hbar) {
642 XtGetValues(hbar, args, TWO);
643 if (top > 0.0)
644 scrlmask |= 4U; /* not at left edge; can scroll to left */
645 if (top + shown < 1.0)
646 scrlmask |= 8U; /* more beyond right side; can scroll to right */
647 }
648 return scrlmask;
649}
650
651/* if a menu is scrolled vertically and/horizontally, return it to the top
652 and far left */

Callers 1

x11_scroll_perminvFunction · 0.85

Calls 1

find_scrollbarsFunction · 0.85

Tested by

no test coverage detected