Subject: unsolicited patch: user-specified top and bottom shadow colors

From: Eddie Kohler <[email-masked]>
Date: Sun, 06 Dec 1998 19:40:34 -0500

Hi,

This patch to the distributed 2.1.4 source adds support to FVWM2 for
user-specified top and bottom shadow colors (only i called them 'highlight'
and 'shadow' colors, because the man page did). I find this very useful.

Specifically:

  * Style command `Color' accepts max 4 slash-separated colors:
    fore/back/highlight/shadow
  * New style commands `HighlightColor', `ShadowColor' (analogous to
    ForeColor/BackColor)
  * MenuStyle change: the 2nd argument, `backcolor', may have the form
    `backcolor,highlightcolor,shadowcolor'
  * HighlightColor change: the 2nd argument, `backcolor', may have the form
    `backcolor,highlightcolor,shadowcolor'

Hope this makes it in.
love,
ed

diff -cr fvwm-2.1.4/fvwm/add_window.c fvwm-2.1.4-mod/fvwm/add_window.c
*** fvwm-2.1.4/fvwm/add_window.c	Fri Nov 27 05:43:19 1998
--- fvwm-2.1.4-mod/fvwm/add_window.c	Sun Dec  6 18:57:08 1998
***************
*** 373,380 ****
        {
          tmp_win->BackPixel = color.pixel;
        }
!     tmp_win->ShadowPixel = GetShadow(tmp_win->BackPixel);
!     tmp_win->ReliefPixel = GetHilite(tmp_win->BackPixel);
    }

--- 373,404 ----
        {
          tmp_win->BackPixel = color.pixel;
        }
!     if (styles.ShadowColor != NULL) {
!       tmp_win->ShadowPixel = GetShadow(tmp_win->BackPixel);
!     }
!     if (styles.HighlightColor != NULL) {
!       tmp_win->ReliefPixel = GetHilite(tmp_win->BackPixel);
!     }
!   }
!   if(styles.ShadowColor != NULL) {
!     XColor color;
! 
!     if((XParseColor (dpy, Scr.FvwmRoot.attr.colormap,styles.ShadowColor, &color))
!        &&(XAllocColor (dpy, Scr.FvwmRoot.attr.colormap, &color)))
! 
!       {
!         tmp_win->ShadowPixel = color.pixel;
!       }
!   }
!   if(styles.HighlightColor != NULL) {
!     XColor color;
! 
!     if((XParseColor (dpy, Scr.FvwmRoot.attr.colormap,styles.HighlightColor, &color))
!        &&(XAllocColor (dpy, Scr.FvwmRoot.attr.colormap, &color)))
! 
!       {
!         tmp_win->ReliefPixel = color.pixel;
!       }
    }

***************
*** 1132,1139 ****
      styles->border_width = nptr->border_width;
    if(nptr->off_flags & FORE_COLOR_FLAG)
      styles->ForeColor = nptr->ForeColor;
!   if(nptr->off_flags & BACK_COLOR_FLAG)
      styles->BackColor = nptr->BackColor;
    if(nptr->off_flags & NOBW_FLAG)
      styles->resize_width = nptr->resize_width;
    styles->on_flags |= nptr->off_flags;  /* combine on and off flags */
--- 1156,1166 ----
      styles->border_width = nptr->border_width;
    if(nptr->off_flags & FORE_COLOR_FLAG)
      styles->ForeColor = nptr->ForeColor;
!   if(nptr->off_flags & BACK_COLOR_FLAG) {
      styles->BackColor = nptr->BackColor;
+     styles->HighlightColor = nptr->HighlightColor;
+     styles->ShadowColor = nptr->ShadowColor;
+   }
    if(nptr->off_flags & NOBW_FLAG)
      styles->resize_width = nptr->resize_width;
    styles->on_flags |= nptr->off_flags;  /* combine on and off flags */
diff -cr fvwm-2.1.4/fvwm/builtins.c fvwm-2.1.4-mod/fvwm/builtins.c
*** fvwm-2.1.4/fvwm/builtins.c	Wed Dec  2 17:05:35 1998
--- fvwm-2.1.4-mod/fvwm/builtins.c	Sun Dec  6 19:27:36 1998
***************
*** 1389,1394 ****
--- 1389,1433 ----
  }

+ static void SetColorPair(char *fore, char *in_back,
+ 			 ColorPair *colors, ColorPair *relief)
+ {
+   char *back = NULL, *highlight = NULL, *shadow = NULL;
+   
+   in_back = GetNextOption(in_back, &back);
+   in_back = GetNextOption(in_back, &highlight);
+   GetNextOption(in_back, &shadow);
+   
+   if(fore != NULL)
+     {
+       colors->fore = GetColor(fore);
+     }
+   if(back != NULL)
+     {
+       colors->back = GetColor(back);
+     }
+   /* allow user to specify highlight & shadow colors as well */
+   if(highlight != NULL)
+     {
+       relief->fore = GetColor(highlight);
+     }
+   else
+     {
+       relief->fore = GetHilite(colors->back);
+     }
+   if(shadow != NULL)
+     {
+       relief->back = GetColor(shadow);
+     }
+   else
+     {
+       relief->back = GetShadow(colors->back);
+     }
+   if (back) free(back);
+   if (highlight) free(highlight);
+   if (shadow) free(shadow);
+ }
+ 
  void SetHiColor(XEvent *eventp,Window w,FvwmWindow *tmp_win,
  		unsigned long context, char *action,int* Module)
  {
***************
*** 1406,1421 ****
    GetNextToken(action,&hiback);
    if(Scr.d_depth > 2)
    {
!     if(hifore != NULL)
!     {
! 	fl->HiColors.fore = GetColor(hifore);
!     }
!     if(hiback != NULL)
!     {
! 	fl->HiColors.back = GetColor(hiback);
!     }
!     fl->HiRelief.back  = GetShadow(fl->HiColors.back);
!     fl->HiRelief.fore  = GetHilite(fl->HiColors.back);
    }
    else
    {
--- 1445,1451 ----
    GetNextToken(action,&hiback);
    if(Scr.d_depth > 2)
    {
!     SetColorPair(hifore, hiback, &fl->HiColors, &fl->HiRelief);
    }
    else
    {
***************
*** 1748,1763 ****
  
    if(Scr.d_depth > 2)
    {
!     if(fore != NULL)
!     {
!       tmpmf->MenuColors.fore = GetColor(fore);
!     }
!     if(back != NULL)
!     {
!       tmpmf->MenuColors.back = GetColor(back);
!     }
!     tmpmf->MenuRelief.back = GetShadow(tmpmf->MenuColors.back);
!     tmpmf->MenuRelief.fore = GetHilite(tmpmf->MenuColors.back);
      tmpmf->MenuStippleColors.back = tmpmf->MenuColors.back;
      tmpmf->MenuStippleColors.fore = GetColor(stipple);
      tmpmf->MenuActiveColors.back = tmpmf->MenuColors.back;
--- 1778,1784 ----
  
    if(Scr.d_depth > 2)
    {
!     SetColorPair(fore, back, &tmpmf->MenuColors, &tmpmf->MenuRelief);
      tmpmf->MenuStippleColors.back = tmpmf->MenuColors.back;
      tmpmf->MenuStippleColors.fore = GetColor(stipple);
      tmpmf->MenuActiveColors.back = tmpmf->MenuColors.back;
diff -cr fvwm-2.1.4/fvwm/misc.h fvwm-2.1.4-mod/fvwm/misc.h
*** fvwm-2.1.4/fvwm/misc.h	Tue Nov 24 05:25:28 1998
--- fvwm-2.1.4-mod/fvwm/misc.h	Sun Dec  6 18:23:34 1998
***************
*** 41,46 ****
--- 41,48 ----
    int resize_width;
    char *ForeColor;
    char *BackColor;
+   char *HighlightColor;
+   char *ShadowColor;
    icon_boxes *IconBoxes;                /* pointer to iconbox(s) */
    unsigned long on_buttons;
    unsigned long off_buttons;
diff -cr fvwm-2.1.4/fvwm/style.c fvwm-2.1.4-mod/fvwm/style.c
*** fvwm-2.1.4/fvwm/style.c	Mon Nov 23 05:40:07 1998
--- fvwm-2.1.4-mod/fvwm/style.c	Sun Dec  6 19:17:43 1998
***************
*** 215,220 ****
--- 215,262 ----
                tname.off_flags |= BACK_COLOR_FLAG;
              }
            }
+ 
+           while(isspace(*tmp))tmp++;
+           if(*tmp == '/')
+           {
+             tmp++;
+             while(isspace(*tmp))tmp++;
+             restofline = tmp;
+             len = 0;
+             while((tmp != NULL)&&(*tmp != 0)&&(*tmp != ',')&&
+                   (*tmp != '\n')&&(*tmp != '/')&&(!isspace(*tmp)))
+             {
+               tmp++;
+               len++;
+             }
+             if(len > 0)
+             {
+               tname.HighlightColor = safemalloc(len+1);
+               strncpy(tname.HighlightColor,restofline,len);
+               tname.HighlightColor[len] = 0;
+             }
+           }
+ 
+           while(isspace(*tmp))tmp++;
+           if(*tmp == '/')
+           {
+             tmp++;
+             while(isspace(*tmp))tmp++;
+             restofline = tmp;
+             len = 0;
+             while((tmp != NULL)&&(*tmp != 0)&&(*tmp != ',')&&
+                   (*tmp != '\n')&&(*tmp != '/')&&(!isspace(*tmp)))
+             {
+               tmp++;
+               len++;
+             }
+             if(len > 0)
+             {
+               tname.ShadowColor = safemalloc(len+1);
+               strncpy(tname.HighlightColor,restofline,len);
+               tname.ShadowColor[len] = 0;
+             }
+           }
            restofline = tmp;
          }
          else if(ITIS("CirculateSkipIcon"))
***************
*** 311,316 ****
--- 353,371 ----
            restofline = tmp;
            SKIPSPACE;
          }
+         else if(ITIS("HighlightColor"))
+ 	{
+           SKIP("HighlightColor");
+           GETWORD;
+           if(len > 0)
+           {
+             tname.HighlightColor = safemalloc(len+1);
+             strncpy(tname.HighlightColor,restofline,len);
+             tname.HighlightColor[len] = 0;
+             tname.off_flags |= BACK_COLOR_FLAG;
+           }
+           restofline = tmp;
+         }
          break;
        case 'i':
          if(ITIS("IconTitle"))
***************
*** 761,766 ****
--- 816,834 ----
            SKIP("STARTSANYWHERE");
            tname.on_flags |= STARTSONDESK_FLAG;
          }
+         else if(ITIS("ShadowColor"))
+ 	{
+           SKIP("ShadowColor");
+           GETWORD;
+           if(len > 0)
+           {
+             tname.ShadowColor = safemalloc(len+1);
+             strncpy(tname.ShadowColor,restofline,len);
+             tname.ShadowColor[len] = 0;
+             tname.off_flags |= BACK_COLOR_FLAG;
+           }
+ 	  restofline = tmp;
+         }
          break;
        case 't':
          if(ITIS("TITLE"))
***************
*** 831,838 ****
                      tname.resize_width = nptr->resize_width;
                    if(nptr->off_flags & FORE_COLOR_FLAG)
                      tname.ForeColor = nptr->ForeColor;
!                   if(nptr->off_flags & BACK_COLOR_FLAG)
                      tname.BackColor = nptr->BackColor;
                    tname.IconBoxes = nptr->IconBoxes; /* use same chain */
                  } /* end hit/not hit */
                } /* end found matching style */
--- 899,909 ----
                      tname.resize_width = nptr->resize_width;
                    if(nptr->off_flags & FORE_COLOR_FLAG)
                      tname.ForeColor = nptr->ForeColor;
!                   if(nptr->off_flags & BACK_COLOR_FLAG) {
                      tname.BackColor = nptr->BackColor;
+ 		    tname.HighlightColor = nptr->HighlightColor;
+ 		    tname.ShadowColor = nptr->ShadowColor;
+ 		  }
                    tname.IconBoxes = nptr->IconBoxes; /* use same chain */
                  } /* end hit/not hit */
                } /* end found matching style */
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dan Espen <[email-masked]>
Date: Mon, 07 Dec 1998 08:42:45 -0500

>     `backcolor,highlightcolor,shadowcolor'

The Shadow/Hilight logic was redone in 2.1.4.   This was partly due to
my  feeling that the calculations  weren't any good for certain colors
and partly in response  to a patch just like  yours.  I reasoned  that
the patch  was submitted  because the  submittor felt that  the colors
calculated weren't very good.

Would you please share  with us why  you  think fvwm needs  logic that
allows  the user  to pick the  shadow  and hilite colors,  rather than
using a calculation.

Even  if you convince one of  us that this patch   is a good idea, its
good form for a patch to include man page updates.  I am also a little
concerned that there are shadows calculated in a number of the modules
that this patch doesn't address.

Before extending your patch, please share with us what your patch does
for you that the built in code doesn't.

--
Dan Espen                                Phone: (732) 699-5570
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Roland Rosenfeld <[email-masked]>
Date: 7 Dec 1998 14:41:34 GMT

First I should say, that I didn't work on fvwm yet, so excuse me, if
I'm not allowed to write here...

> allows the user to pick the shadow and hilite colors, rather than

I don't think that fvwm needs such a logic, but I think, that the new
Shadow/Hilight isn't optimal. Maybe that depends on me using fvwm for
a long time now and the look simply changed, which confused me...

I configured very thin borders (only 5 points), which are reduced to
show only Shadow and Hilight, but not the original color. No problem
before, but the new code uses the factors 0.5 (darkness) and 1.4
(brightness), which leads to very light borders (light gray with only
a little bit color).

Maybe it would be a good idea to make these factors configurable?

Another problem: I use "Color black/#60c0a0" a light green for all
sticky windows. With this color the borders have a tinge of yellow.
Don't ask me whether this is correct, but it looks wrong for me...

Tschoeeee

        Roland

-- 
 * [email-masked] * http://www.rhein.de/~roland/ *
 PGP: 1024/DD08DD6D   2D E7 CC DE D5 8D 78 BE  3C A0 A4 F1 4B 09 CE AF
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Eddie Kohler <[email-masked]>
Date: Mon, 07 Dec 1998 11:01:31 -0500

> allows  the user  to pick the  shadow  and hilite colors,  rather than

In no particular order,

1. Mwm "compatibility": mwm allows you to explicity set top and bottom
shadow colors with *topShadowColor and *bottomShadowColor

2. Existing shadow/hilight logic was bad; given my background colors,
shadow color was too dark, highlight color too bright, creating distracting
visual noise

3. Specialized top and bottom shadow colors can create some neat-looking
windows (random ex: dark gray background, dark red top shadow, dark
gray-blue bottom shadow looks cool if you pick the right colors)

The code in libs/Colors.c has hardcoded constants for shadow and highlight
calculation. Number 2 could be addressed by making those constants
user-configurable. (They should probably be user-configurable anyway;
you're never going to pick constants that everyone likes.) The other two,
however, need individually settable colors.

I'd love to extend the patch to manpage updates and modules if asked.

I do wish there were more consistency in color specifications -- there are
so many ways of saying "foreground and background". (Space-separated?
slash-separated? two options?) maybe options could sometimes take take
semicolon-separated colors instead of slash. (Unlike the slash in the
Style:Color option, the semicolon is not part of any valid X11 color.) Is
this interesting?

love,
ed

---

From: "Randall S. Winchester" <[email-masked]>
Date: Mon, 7 Dec 1998 12:33:31 -0500 (EST)

On Mon, 7 Dec 1998, Eddie Kohler wrote:

: > Would you please share  with us why  you  think fvwm needs  logic that
: > allows  the user  to pick the  shadow  and hilite colors,  rather than
: > using a calculation.
: 
: In no particular order,
: 
: 1. Mwm "compatibility": mwm allows you to explicity set top and bottom
: shadow colors with *topShadowColor and *bottomShadowColor

Whatever happens, do people not think that "topShadowColor" and
"topShadowColor" make more sense then "shadow" and "hilite". Heh, someone
may want a "leftShadowColor" and rightShadowColor" sometime...

Randall

---

From: Dan Espen <[email-masked]>
Date: Mon, 07 Dec 1998 14:33:21 -0500

> however, need individually settable colors.

I found point 2  convincing until I read  point 3.  Ie. you  found the
calculated colors not-pleasing, but then you create a dark gray window
and attempt to give it a 3D effect  with dark red  and dark grey blue?

On your side, you are not  the first person  to submit a patch of this
type.

> I'd love to extend the patch to manpage updates and modules if asked.

I guess I might give in, this looks like unnecessary  bloat to me, but
I don't  like being an obstacle  to  other peoples  desires.  Lets see
what some other people on the workers list think.

I don't recommend this patch for the upcoming release, it seems to me
like a post 2.2 enhancement.

Eddie, I  don't recommend that you extend  this patch to FvwmForm, its
in the process of being re-written.  I also recommend waiting for some
of the other people on fvwm-workers to check in on this subject before
you put any more work into this.   Are you on the  workers list so you
will see any reaction?

> Style:Color option, the semicolon is not part of any valid X11 color.) Is

Anything    that  is consistent   with    and  doesn't  break  current
configuration files  is good.  Slashes  aren't good, "Color fore/back"
is  already broken, since "rgb:FF/00/FF"   is a valid  color.  I don't
think we currently use semi-colons for lists of things.

topShadowColor and bottomShadowColor  are appealing since they've been
used in mwm.

---

From: Tim Phipps <[email-masked]>
Date: Tue, 08 Dec 1998 09:25:18 +0000

> like a post 2.2 enhancement.

Looks like bloat to me too.  As a post 2.2 project I'd like to think about having
fvwm hand over window decoration to a module with a fall back to a single, very
simple style if the decoration module isn't used.  There is a huge amount of code
for all the different styles. All fvwm would need to provide would be the
WindowId's of the frame, the module could send back the sizes of the edges and
would create the buttons, handles and title bar. One day maybe.

Cheers,
Tim.

---

From: Dominik Vogt <[email-masked]>
Date: Tue, 8 Dec 1998 10:45:27 +0100

On Tue, Dec 08, 1998 at 09:25:18AM +0000, Tim Phipps wrote:
> Looks like bloat to me too.

Me too as I said before. We can't possibly make each and every
colour configurable by the user. If we'd finally have a module
for the window decorations so what, but I do not see this
in the main executable.

Bye

Dominik
-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].