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

Function get_window_frame_extents

win/X11/winX.c:592–647  ·  view source on GitHub ↗

Ask the WM for window frame size */

Source from the content-addressed store, hash-verified

590
591/* Ask the WM for window frame size */
592void
593get_window_frame_extents(
594 Widget w,
595 long *top, long *bottom,
596 long *left, long *right)
597{
598 XEvent event;
599 Display *dpy = XtDisplay(w);
600 Window win = XtWindow(w);
601 Atom prop, retprop;
602 int retfmt;
603 unsigned long nitems;
604 unsigned long nbytes;
605 unsigned char *data = 0;
606 long *extents;
607
608 *top = *bottom = *left = *right = 0L;
609
610 prop = XInternAtom(dpy, "_NET_FRAME_EXTENTS", True);
611 if (prop == None) {
612 /*
613 * FIXME!
614 */
615#ifdef MACOS
616 /*
617 * Default window manager doesn't support _NET_FRAME_EXTENTS.
618 * Without this position tweak, the persistent inventory window
619 * creeps downward by approximately the height of its title bar
620 * and also a smaller amount to the left every time it gets
621 * updated. Caveat: amount determined by trial and error and
622 * could change depending upon monitor resolution....
623 *
624 * This hack could be improved by implementing the anti-creep
625 * value as an X resource so that player can adjust it.
626 */
627 *top = 22L;
628#endif
629 return;
630 }
631
632 while (XGetWindowProperty(dpy, win, prop,
633 0, 4, False, AnyPropertyType,
634 &retprop, &retfmt,
635 &nitems, &nbytes, &data) != Success
636 || nitems != 4 || nbytes != 0) {
637 XNextEvent(dpy, &event);
638 }
639
640 extents = (long *) data;
641 if (extents) {
642 *left = extents[0];
643 *right = extents[1];
644 *top = extents[2];
645 *bottom = extents[3];
646 }
647}
648
649void

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected