From 1ece615eb29fa25edbf2f71d89ccf107c357a313 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 30 Jun 2025 09:04:41 -0400 Subject: [PATCH] fixes3-7-0.txt catch-up; also replace some magic hex numbers --- doc/fixes3-7-0.txt | 3 +++ win/X11/winmap.c | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index cc3076cb2..9b36d3c3e 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2228,6 +2228,9 @@ X11: when trying to lookup scrollbars in order to handle scrolling via keys, X11: enable horizontal scrollbar for persistent inventory window X11: if a group accelerator matched a menu command ('^' in menu for '/') it wouldn't work to select, just to manipulate the menu +X11: ascii_map could try to use a color value, with some added flag bits set, + as an index into the color_gcs[] and inv_color_gcs[] arrays leading + to a segfault; clear the flag bits before using the color as an index X11+macOS: after the "bad Atom" fix (below), the persistent inventory window crept downward every time it got updated diff --git a/win/X11/winmap.c b/win/X11/winmap.c index cb86685ce..53a094c34 100644 --- a/win/X11/winmap.c +++ b/win/X11/winmap.c @@ -56,6 +56,9 @@ extern int total_tiles_used, Tile_corr; #define COL0_OFFSET 1 /* change to 0 to revert to displaying unused column 0 */ +#define NH_INVERSE_COLOR 0x40000000 +#define NH_ENHANCED_COLOR 0x80000000 + static X11_map_symbol glyph_char(const glyph_info *glyphinfo); static GC X11_make_gc(struct xwindow *wp, struct text_map_info_t *text_map, X11_color color, boolean inverted); @@ -170,9 +173,9 @@ X11_print_glyph( ? CLR_MAX : 0; color += colordif; if (nhcolor != 0) - color = nhcolor | 0x80000000; + color = nhcolor | NH_ENHANCED_COLOR; if (colordif != 0) - color |= 0x40000000; + color |= NH_INVERSE_COLOR; if (*co_ptr != color) { *co_ptr = color; @@ -1528,9 +1531,9 @@ X11_make_gc( GC ggc; #ifdef ENHANCED_SYMBOLS - if ((color & 0x80000000) != 0) { + if ((color & NH_ENHANCED_COLOR) != 0) { /* We need a new GC */ - if ((color & 0x40000000) != 0) { + if ((color & NH_INVERSE_COLOR) != 0) { cur_inv = !cur_inv; } if (iflags.use_color) { @@ -1540,7 +1543,7 @@ X11_make_gc( /* FIXME: Does this still work when the display does not support true color? */ - fgpixel = color & 0xFFFFFF; + fgpixel = COLORVAL(color); XtSetArg(arg[0], XtNbackground, &bgpixel); XtGetValues(wp->w, arg, 1); if (cur_inv) { @@ -1580,7 +1583,7 @@ X11_make_gc( static void X11_free_gc(struct xwindow *wp, GC ggc, X11_color color) { - if ((color & 0x80000000) != 0 && iflags.use_color) { + if ((color & NH_ENHANCED_COLOR) != 0 && iflags.use_color) { /* X11_make_gc allocated a new GC */ XtReleaseGC(wp->w, ggc); }