1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-03-20 01:33:34 +01:00

Prevent XAllocColor() call on TrueColor display

As reported in bug https://github.com/window-maker/wmaker/issues/50
X11 XAllocColor() call from wGetColorForColormap() in src/resources.c is returning some errors
especially seen when running GZDoom.

TrueColor display has been the dominant standard for well over a decade, meaning almost all modern X servers default to a TrueColor visual.
The default colormap is predefined and read-only, making allocation with XAllocColor() unnecessary (and meaning no need to free it too).
The patch is checking the display visual, and in case the display is truecolor, it does not allocate or free the color, just looking up for it.
Once the patch applied, GZDoom is not reporting warnings anymore.
This commit is contained in:
David Maciejak
2025-12-25 16:19:05 -05:00
committed by Carlos R. Mafra
parent 3579c85af1
commit 67e2f5e1ca
3 changed files with 20 additions and 9 deletions

View File

@@ -58,14 +58,14 @@ static void paintButton(WCoreWindow * button, WTexture * texture,
static void updateTitlebar(WFrameWindow * fwin);
static void allocFrameBorderPixel(Colormap colormap, const char *color_name, unsigned long **pixel);
static void allocFrameBorderPixel(WFrameWindow *fwin, const char *color_name, unsigned long **pixel);
static void allocFrameBorderPixel(Colormap colormap, const char *color_name, unsigned long **pixel) {
static void allocFrameBorderPixel(WFrameWindow *fwin, const char *color_name, unsigned long **pixel) {
XColor xcol;
*pixel = NULL;
if (! wGetColorForColormap(colormap, color_name, &xcol))
if (! wGetColorForColormap(fwin->screen_ptr, fwin->colormap, color_name, &xcol))
return;
*pixel = wmalloc(sizeof(unsigned long));
@@ -412,9 +412,9 @@ void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags)
checkTitleSize(fwin);
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_border_color), &fwin->border_pixel);
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_focused_border_color), &fwin->focused_border_pixel);
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_selected_border_color), &fwin->selected_border_pixel);
allocFrameBorderPixel(fwin, WMGetColorRGBDescription(scr->frame_border_color), &fwin->border_pixel);
allocFrameBorderPixel(fwin, WMGetColorRGBDescription(scr->frame_focused_border_color), &fwin->focused_border_pixel);
allocFrameBorderPixel(fwin, WMGetColorRGBDescription(scr->frame_selected_border_color), &fwin->selected_border_pixel);
if (flags & WFF_SELECTED) {
if (fwin->selected_border_pixel)