Subject: Patch Color-Colorset-problem in FvwmScript

From: Uwe Pross <[email-masked]>
Date: Sat, 5 Feb 2005 13:51:26 +0100

Hi there,

I wrote a small and very very straight forward patch for
FvwmScript module so that a previously (or higher) given
colorset is not overwritten by a color definition. Take a
look at the attached script and both screenshots.

I know the patch is not very nice and leads to unnecessary
memory consumtion. Maybe someone can make better ;-) I see
it as a prov-of-concept.

Cheers, Uwe
-- 
  ,_,   For personal reply/mail put "fvwm"
 (O,O)  in the subject.
 (   )  Otherwise your mail is discarded by a filter.
=-"-"-= http://www.tu-chemnitz.de/~uwp
? patch.FvwmScript
Index: FvwmScript.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmScript/FvwmScript.c,v
retrieving revision 1.71
diff -u -r1.71 FvwmScript.c
--- FvwmScript.c	7 Jun 2004 13:53:50 -0000	1.71
+++ FvwmScript.c	5 Feb 2005 12:35:20 -0000
@@ -529,12 +529,31 @@
   }
 }
 
+char* CreateColorString(Pixel pixel) {
+    char tmp[128];
+    XColor color;
+    color.pixel=pixel;
+    color.red=0;
+    color.green=0;
+    color.blue=0;
+    XQueryColor(dpy, Pcmap, &color);
+    sprintf(tmp, "#%02x%02x%02x", (color.red>>8)&0xff, (color.green>>8)&0xff, (color.blue>>8)&0xff);
+    return safestrdup(tmp);
+}
 
 /* Construction de l'interface graphique */
 void BuildGUI(int IsFather)
 {
   int i;
 
+  /* Inherit color values from colorset */
+  if (scriptprop->colorset != -1) {
+    x11base->backcolor=CreateColorString(Colorset[scriptprop->colorset].bg);
+    x11base->forecolor=CreateColorString(Colorset[scriptprop->colorset].fg);
+    x11base->hilicolor=CreateColorString(Colorset[scriptprop->colorset].hilite);
+    x11base->shadcolor=CreateColorString(Colorset[scriptprop->colorset].shadow);
+  }
+
   if (scriptprop->font != NULL)
   {
     /* leak! */

---

From: Uwe Pross <[email-masked]>
Date: Sat, 5 Feb 2005 20:48:43 +0100

Hi there,

> look at the attached script and both screenshots.

For the moment I use 

PipeRead "echo SetEnv FvwmScriptBg `echo $[bg.cs1] | sed 's/rgb:/#/;s+../++g;s+..$++'`"
PipeRead "echo SetEnv FvwmScriptFg `echo $[fg.cs1] | sed 's/rgb:/#/;s+../++g;s+..$++'`"
PipeRead "echo SetEnv FvwmScriptSh `echo $[shadow.cs1] | sed 's/rgb:/#/;s+../++g;s+..$++'`"
PipeRead "echo SetEnv FvwmScriptHi `echo $[hilight.cs1] | sed 's/rgb:/#/;s+../++g;s+..$++'`"
*FvwmScript: DefaultFore    $[FvwmScriptFg]
*FvwmScript: DefaultBack    $[FvwmScriptBg]
*FvwmScript: DefaultHilight $[FvwmScriptHi]
*FvwmScript: DefaultShadow  $[FvwmScriptSh]

which gives the same result ;-) Both the patch and the
workaround do not work if not "plain" colorsets are used.
Colorset support seems to be very limited in FvwmScript. 

Using 

Colorset 10 fg $[fg.cs1], bg $[bg.cs1], HGradient 128 red yellow

and the attached script one gets the attached screenshot
(which is quite ugly).

Cheers, Uwe