[GRASS5] [bug #1559] (grass) 5.1 wish: Change default background color to white or var

Glynn Clements glynn.clements at virgin.net
Fri Jan 31 12:11:52 EST 2003


Request Tracker wrote:

> this bug's URL: http://intevation.de/rt/webrt?serial_num=1559
> -------------------------------------------------------------------------
> 
> Subject: 5.1 wish: Change default background color to white or var
> 
> grass binary for platform: Compiled from Sources
> 
> Dear developers,
> 
> as monitors are much better nowadays than 10-20 years ago (refresh rate),
> I would like to propose (GRASS 5.1) to either change default background
> color to white or, better, allow for an environmental variable defining
> the color.
> 
> Such variable exists already:
>  GRASS_BACKGROUNDCOLOR
> but is currently only used for the PNG driver.
> 
> I tried to understand the related XDRIVER code, but don't know where
> to add support for GRASS_BACKGROUNDCOLOR.
> 
> Maybe we also define GRASS_FOREGROUNDCOLOR for default vector line colors etc.

At the bottom of Graph_Set.c is:

    /* Now create a pixmap that will contain same contents as the
     * window. It will be used to redraw from after expose events */
    bkupmap = XCreatePixmap(dpy, grwin, xwa.width, xwa.height, xwa.depth);
    XSetWindowBackgroundPixmap(dpy, grwin, bkupmap);
    XSetForeground(dpy, gc, BlackPixel(dpy, scrn));
    XFillRectangle(dpy, bkupmap, gc, 0, 0, xwa.width, xwa.height);

    XSetBackground(dpy, gc, BlackPixel(dpy, scrn));
    XSetForeground(dpy, gc, WhitePixel(dpy, scrn));

The first call to XSetForeground() determines the initial background
colour; the second call determines the initial foreground colour. I
suspect that the call to XSetBackground may be irrelevant (the X
background colour is only used for two-colour operations such as
bitmaps, dashed lines, stippled regions etc).

Note that this will set the *initial* colours. There aren't really
"default" background/foreground colours, in the sense that the monitor
protocol doesn't have a "reset" operation. Once any client changes
these settings, they stay changed.

Consequently, most clients will explicitly set the colour themselves
(e.g. "d.erase" will erase to black, "d.vect" will draw white lines). 
If you want persistent defaults, you would need to implement them in
the clients, not the drivers.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list