allocation, so that this program gives color also on TrueColor displays. The use of color plane masks is however removed.
68 lines
2.1 KiB
Text
68 lines
2.1 KiB
Text
$NetBSD: patch-ae,v 1.1 2001/08/01 20:56:30 he Exp $
|
|
|
|
--- xplot.c.orig Wed Jul 2 22:26:09 1997
|
|
+++ xplot.c
|
|
@@ -842,38 +842,39 @@
|
|
/* Allocate some color cells */
|
|
|
|
if (d_i[d].virgin ) {
|
|
+ int default_depth;
|
|
+ int default_screen;
|
|
+ int default_cmap;
|
|
+ XVisualInfo visual_info;
|
|
+
|
|
d_i[d].virgin = 0;
|
|
|
|
d_i[d].xplot_nagle_atom = XInternAtom(pl->dpy, "XPLOT_NAGLE", False);
|
|
|
|
- d_i[d].clr_map = DefaultColormap(pl->dpy, DefaultScreen(pl->dpy));
|
|
+ default_screen = ScreenNumberOfScreen(pl->screen);
|
|
+ default_depth = DefaultDepth(pl->dpy, default_screen);
|
|
+ default_cmap = DefaultColormap(pl->dpy, default_screen);
|
|
|
|
- if ( option_mono ||
|
|
+ i = DirectColor;
|
|
+ while (!XMatchVisualInfo(pl->dpy, default_screen, default_depth,
|
|
+ i--, &visual_info))
|
|
+ ;
|
|
|
|
- ! XAllocColorCells(pl->dpy,
|
|
- d_i[d].clr_map, 0,
|
|
- &d_i[d].line_plane_mask, 1,
|
|
- d_i[d].pixel, NColors) )
|
|
- {
|
|
- /* probably only one bit plane, or all the color cells are taken */
|
|
-#if 1
|
|
- if (! option_mono)
|
|
- fputs("XAllocColorCells failed, will only have one plot color\n",
|
|
- stderr);
|
|
-#endif
|
|
- for ( i = 0; i < NColors; i++) {
|
|
- d_i[d].Colors[i] = WhitePixelOfScreen(pl->screen);
|
|
- }
|
|
- } else {
|
|
- for (i = 0; i < NColors; i++) {
|
|
- XParseColor(pl->dpy, d_i[d].clr_map, ColorNames[i], &d_i[d].clr);
|
|
- d_i[d].clr.pixel = d_i[d].pixel[i];
|
|
- XStoreColor (pl->dpy, d_i[d].clr_map, &d_i[d].clr);
|
|
- d_i[d].clr.pixel |= d_i[d].line_plane_mask;
|
|
- XStoreColor (pl->dpy, d_i[d].clr_map, &d_i[d].clr);
|
|
- d_i[d].Colors[i] = d_i[d].clr.pixel;
|
|
+ if (i < StaticColor || option_mono) {
|
|
+ mono:
|
|
+ for ( i = 0; i < NColors; i++) {
|
|
+ d_i[d].Colors[i] = WhitePixelOfScreen(pl->screen);
|
|
+ }
|
|
+ } else {
|
|
+ for (i = 0; i < NColors; i++) {
|
|
+ XParseColor(pl->dpy, default_cmap, ColorNames[i], &d_i[d].clr);
|
|
+ if (!XAllocColor(pl->dpy, default_cmap, &d_i[d].clr)) {
|
|
+ fprintf(stderr, "XAllocColor failed, reverting to monochrome\n");
|
|
+ goto mono;
|
|
}
|
|
+ d_i[d].Colors[i] = d_i[d].clr.pixel;
|
|
}
|
|
+ }
|
|
}
|
|
|
|
for (i = 0; i < NColors; i++) {
|