From 8ad517944e46710ab832350c0dc3fc4e9239f7e2 Mon Sep 17 00:00:00 2001 From: rsc Date: Thu, 25 Mar 2004 23:03:57 +0000 Subject: Today's changes. More changes. --- src/libdraw/x11-init.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/libdraw/x11-init.c') diff --git a/src/libdraw/x11-init.c b/src/libdraw/x11-init.c index 1283f430..c959eee4 100644 --- a/src/libdraw/x11-init.c +++ b/src/libdraw/x11-init.c @@ -185,26 +185,22 @@ xattach(char *label) /* * Figure out underlying screen format. */ - _x.depth = DefaultDepth(_x.display, xrootid); if(XMatchVisualInfo(_x.display, xrootid, 16, TrueColor, &xvi) || XMatchVisualInfo(_x.display, xrootid, 16, DirectColor, &xvi)){ _x.vis = xvi.visual; _x.depth = 16; - _x.usetable = 1; } else if(XMatchVisualInfo(_x.display, xrootid, 15, TrueColor, &xvi) || XMatchVisualInfo(_x.display, xrootid, 15, DirectColor, &xvi)){ _x.vis = xvi.visual; _x.depth = 15; - _x.usetable = 1; } else if(XMatchVisualInfo(_x.display, xrootid, 24, TrueColor, &xvi) || XMatchVisualInfo(_x.display, xrootid, 24, DirectColor, &xvi)){ _x.vis = xvi.visual; _x.depth = 24; - _x.usetable = 1; } else if(XMatchVisualInfo(_x.display, xrootid, 8, PseudoColor, &xvi) @@ -218,6 +214,7 @@ xattach(char *label) _x.depth = 8; } else{ + _x.depth = DefaultDepth(_x.display, xrootid); if(_x.depth != 8){ werrstr("can't understand depth %d screen", _x.depth); goto err0; @@ -225,6 +222,9 @@ xattach(char *label) _x.vis = DefaultVisual(_x.display, xrootid); } + if(DefaultDepth(_x.display, xrootid) == _x.depth) + _x.usetable = 1; + /* * _x.depth is only the number of significant pixel bits, * not the total number of pixel bits. We need to walk the @@ -298,7 +298,7 @@ xattach(char *label) Dx(r), /* width */ Dy(r), /* height */ 0, /* border width */ - DefaultDepthOfScreen(xscreen), /* depth */ + _x.depth, /* depth */ InputOutput, /* class */ _x.vis, /* visual */ /* valuemask */ @@ -562,6 +562,18 @@ setupcmap(XWindow w) return 0; if(_x.depth >= 24) { + /* + * This is needed for SunOS. Ask Axel Belinfante. + */ + if(_x.usetable == 0){ + _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocAll); + XStoreColors(_x.display, _x.cmap, _x.map, 256); + for(i = 0; i < 256; i++){ + _x.tox11[i] = i; + _x.toplan9[i] = i; + } + } + /* * The pixel value returned from XGetPixel needs to * be converted to RGB so we can call rgb2cmap() @@ -573,7 +585,6 @@ setupcmap(XWindow w) * some displays say MSB even though they run on LSB. * Besides, this is more anal. */ - c = _x.map[19]; /* known to have different R, G, B values */ if(!XAllocColor(_x.display, _x.cmap, &c)){ werrstr("XAllocColor: %r"); -- cgit v1.2.3