partial fix for #K3262 - X11 perm_invent panic

Prevent the "X Error (bad Atom)" situation that causes an
"X Error" panic.

The issue isn't fixed.  This fails to implement the intended
functionality of having the X server remember the persistent
inventory window's location across games (until the next time
that the X server restarts).  Worse, on OSX the window creeps
each time it is updated (visually it seems to be moving down by
the height of the window's title bar).

That's not as bad as having it move to the pointer's location as
it did in 3.6.1, but prior to the commit which introduced this
code that had been fixed and it stayed put during the current
game, so more work is definitely needed.
This commit is contained in:
PatR
2021-02-06 16:04:44 -08:00
parent 4e0a1e0462
commit 67d94d2930
2 changed files with 14 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.443 $ $NHDT-Date: 1612400970 2021/02/04 01:09:30 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.446 $ $NHDT-Date: 1612656277 2021/02/07 00:04:37 $
General Fixes and Modified Features
-----------------------------------
@@ -657,6 +657,8 @@ X11: substantial overhaul of status display, both 'fancy' and 'tty-style'
X11: extend fancy status one-turn inverse video status-change highlighting to
hunger, encumbrance, and conditions
X11: stop including unused column 0 in the map
X11: avoid 'bad Atom X Error' when perm_invent is enabled (seemingly window
manager dependent)
General New Features

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 winX.c $NHDT-Date: 1611105313 2021/01/20 01:15:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.90 $ */
/* NetHack 3.7 winX.c $NHDT-Date: 1612656277 2021/02/07 00:04:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.93 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -559,7 +559,9 @@ nhCvtStringToPixel(Display *dpy, XrmValuePtr args, Cardinal *num_args,
/* Ask the WM for window frame size */
void
get_window_frame_extents(Widget w, long *top, long *bottom, long *left, long *right)
get_window_frame_extents(Widget w,
long *top, long *bottom,
long *left, long *right)
{
XEvent event;
Display *dpy = XtDisplay(w);
@@ -571,16 +573,19 @@ get_window_frame_extents(Widget w, long *top, long *bottom, long *left, long *ri
unsigned char *data = 0;
long *extents;
*top = *bottom = *left = *right = 0L;
prop = XInternAtom(dpy, "_NET_FRAME_EXTENTS", True);
if (prop == None)
return;
while (XGetWindowProperty(dpy, win, prop,
0, 4, False, AnyPropertyType,
&retprop, &retfmt,
&nitems, &nbytes, &data) != Success
|| nitems != 4 || nbytes != 0)
{
XNextEvent(dpy, &event);
}
|| nitems != 4 || nbytes != 0) {
XNextEvent(dpy, &event);
}
extents = (long *) data;