Subject: CVS hippo: Fvwm handles Colorsets from FvwmTheme

From: CVS <[email-masked]>
Date: Mon, 19 Jul 1999 10:46:43 -0500 (CDT)

CVSROOT:	/home/cvs/fvwm
Module name:	fvwm
Changes by:	hippo	99/07/19 10:46:42

Modified files:
	.              : ChangeLog 
	fvwm           : add_window.c builtins.c functions.c fvwm.c 
	                 icons.c misc.h module_interface.c 
	                 module_interface.h screen.h 
	libs           : Colorset.c Colorset.h 
	modules/FvwmTheme: FvwmTheme.c 

Log message:
Fvwm handles Colorsets from FvwmTheme
DefaultColors manipulates Colorset[0] and vice versa

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
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: Brad Giaccio <[email-masked]>
Date: Tue, 20 Jul 1999 08:16:56 -0400

I took the liberty of patching FvwmIdent to use the colorsets, you got
me used to those gradients in their and I just couldn't resist.  The
only thing really missing is the ability to get the colorset on init.  I
wasn't exactlly sure where this would go.  My guess is modconf.c but I
wasn't sure.

Brad

Index: FvwmIdent.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIdent/FvwmIdent.c,v
retrieving revision 1.29
diff -u -B -b -r1.29 FvwmIdent.c
--- FvwmIdent.c 1999/07/02 12:42:56     1.29
+++ FvwmIdent.c 1999/07/20 12:14:28
@@ -54,6 +54,7 @@
 
 #include "libs/Module.h"
 #include "libs/Picture.h"
+#include "libs/Colorset.h"
 #include "FvwmIdent.h"
 
 char *MyName;
@@ -506,6 +506,7 @@
     /* parse any config lines */
     if (FD_ISSET(fd[1], &fdset)) {
       char *tline;
+      int n;
 
       packet = ReadFvwmPacket( fd[1] );
       if ( packet && packet->type == M_CONFIG_INFO ) {
@@ -520,11 +521,17 @@
          tline++;
          --body_count;
        }
+       tline += 9; /*fails if I leave "Colorset "*/
+       n = LoadColorset(tline); 
+       if (-1 == n)
+         return;
+
 
-       /* this is where dynamic colorset changing happens
+       /* this is where dynamic colorset changing happens */
+          gcv.foreground = Colorset[n].fg;
+          XChangeGC(dpy, gc, gcm, &gcv);
           SetWindowBackground(dpy, main_win, mysizehints.width,
-          mysizehints.height, G->bg, G->depth, G->foreGC);
-       */
+          mysizehints.height, &Colorset[n], Pdepth, gc);
       }
     }
   }

Index: Makefile.am
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIdent/Makefile.am,v
retrieving revision 1.6
diff -u -B -b -r1.6 Makefile.am
--- Makefile.am 1999/04/04 17:08:25     1.6
+++ Makefile.am 1999/07/20 12:17:41
@@ -17,7 +17,7 @@
 ## there are sometimes dependencies through functions in libfvwm
 ## so we might as well link against libXpm, if present.
 LDADD = -L$(top_builddir)/libs -lfvwm $(xpm_LIBS)  \
-    $(X_LIBS) $(X_PRE_LIBS) -lXext -lX11 $(X_EXTRA_LIBS)
+    $(X_LIBS) $(X_PRE_LIBS) -lXext -lX11 $(X_EXTRA_LIBS) -lm
 
 INCLUDES = -I$(top_srcdir) $(xpm_CFLAGS) $(X_CFLAGS)

---

From: Tim Phipps <[email-masked]>
Date: Tue, 20 Jul 1999 16:36:33 +0100

> wasn't exactlly sure where this would go.  My guess is modconf.c but I

Great minds think alike!  I just did FvwmIdent.  The changes are almost
exactly the same as your patch.  I added a *FvwmIdentColorset option
though so you can pick one, and I made it follow any changes to the
colorsets.

Which ones of FvwmButtons, FvwmForm, FvwmIconBox, FvwmIconMan,
FvwmPager, FvwmScroll, FvwmTaskBar, FvwmWharf & FvwmWinList do you want
to have a go at?

Cheers,
Tim.

---

From: Brad Giaccio <[email-masked]>
Date: Tue, 20 Jul 1999 13:42:02 -0400

> though so you can pick one, and I made it follow any changes to the

Looks great I thought modconf was the right place to send the initial
one but I wasn't sure.

> FvwmPager, FvwmScroll, FvwmTaskBar, FvwmWharf & FvwmWinList do you
> want to have a go at?
>

Well should we nock out the easy ones first or just go for the big ones.
FvwmScroll should be pretty easy so maybe I'll start their then
I'll try FvwmIconMan, since I use that quite a bit.  

After looking at my FvwmIconMan resources it looks like we need six
colorsets per manager.  So for my setup that means I could configure
upto 6*5 = 30 colorsets. Does that sound right to you??

Brad

> Cheers, Tim.

-- 
--- There are two kinds of knowledge, you either know the answer or
			you know where to find it
		      -Kane, Johnson, and anonymous
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
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: Brad Giaccio <[email-masked]>
Date: Tue, 20 Jul 1999 14:26:02 -0400

> I'll try FvwmIconMan, since I use that quite a bit.  

Here is FvwmScroll:

Index: FvwmScroll.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmScroll/FvwmScroll.1,v
retrieving revision 1.3
diff -u -B -b -r1.3 FvwmScroll.1
--- FvwmScroll.1	1999/05/07 20:18:34	1.3
+++ FvwmScroll.1	1999/07/20 18:26:08
@@ -58,9 +58,12 @@
 FvwmScroll reads the same .fvwmrc file as fvwm reads when it starts up,
 and looks for lines as listed below:
 
+.IP "*FvwmScrollColorset \fIn\fP"
+Tells the module to use colorset \fIn\fP. See FvwmTheme.
+
 .IP "*FvwmScrollBack \fIcolor\fP"
 Tells the module to use \fIcolor\fP instead of black for the window
-background.
+background. Switches off the Colorset option.
 
 .SH BUGS
 When the scroll bars are removed by clicking on the button in the
Index: FvwmScroll.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmScroll/FvwmScroll.c,v
retrieving revision 1.18
diff -u -B -b -r1.18 FvwmScroll.c
--- FvwmScroll.c	1999/07/02 12:42:58	1.18
+++ FvwmScroll.c	1999/07/20 18:26:09
@@ -34,6 +34,7 @@
 #include "libs/Module.h"
 #include "libs/fvwmlib.h"
 #include "libs/Picture.h"
+#include "libs/Colorset.h"
 #include "FvwmScroll.h"
 
 char *MyName;
@@ -47,6 +48,9 @@
 int x_fd;
 int ScreenWidth, ScreenHeight;
 
+/* default colorset to use, set to -1 when explicitly setting colors */
+int colorset = 0;
+
 char *BackColor = "black";
 
 Window app_win;
@@ -117,6 +121,8 @@
 
   SetMessageMask(fd, M_CONFIG_INFO | M_END_CONFIG_INFO | M_SENDCONFIG);
   InitPictureCMap(dpy);
+  /* prevent core dumps if fvwm doesn't provide any colorsets */
+  AllocColorset(0);
 
   /* scan config file for set-up parameters */
   /* Colors and fonts */
@@ -131,6 +137,15 @@
 			   Clength+4)==0)
 	    {
 	      CopyString(&BackColor,&tline[Clength+4]);
+	      colorset = -1;
+	    }
+    else if(strncasecmp(tline,CatString3(MyName,"Colorset",""),Clength+8)==0)
+      {
+        sscanf(&tline[Clength+8], "%d", &colorset);
+      }
+    else if(strncasecmp(tline, "Colorset", 8) == 0)
+      {
+        LoadColorset(&tline[8]);
 	    }
 	}
       GetConfigLine(fd,&tline);
Index: GrabWindow.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmScroll/GrabWindow.c,v
retrieving revision 1.19
diff -u -B -b -r1.19 GrabWindow.c
--- GrabWindow.c	1999/07/02 12:42:58	1.19
+++ GrabWindow.c	1999/07/20 18:26:09
@@ -45,6 +45,7 @@
 #include "libs/Module.h"
 #include "libs/fvwmlib.h"
 #include "libs/Picture.h"
+#include "libs/Colorset.h"
 
 #include "FvwmScroll.h"
 
@@ -63,6 +64,7 @@
 
 Window main_win,holder_win;
 Pixel hilite_pix,shadow_pix;
+extern int colorset;
 extern char *BackColor;
 
 #define MW_EVENTS   (ExposureMask | StructureNotifyMask| ButtonReleaseMask |\
@@ -109,7 +111,8 @@
   mysizehints.win_gravity = NorthWestGravity;
 
   attributes.colormap = Pcmap;
-  attributes.background_pixel = GetColor(BackColor);
+  attributes.background_pixel = (colorset<0)  ?GetColor(BackColor)
+				  : Colorset[colorset % nColorsets].bg;
   attributes.border_pixel = 0;
   main_win = XCreateWindow(dpy, Root, mysizehints.x, mysizehints.y,
 			   mysizehints.width, mysizehints.height, 0, Pdepth,
@@ -141,6 +144,10 @@
   gcv.foreground = shadow_pix;
   shadowGC = XCreateGC(dpy, holder_win, gcm, &gcv);
 
+  if (colorset >= 0)
+    SetWindowBackground(dpy, main_win, mysizehints.width, mysizehints.height,
+			&Colorset[(colorset % nColorsets)], Pdepth, shadowGC);
+
   _XA_WM_COLORMAP_WINDOWS = XInternAtom (dpy, "WM_COLORMAP_WINDOWS", False);
  }
 
@@ -173,6 +180,7 @@
   unsigned long nitems, bytesafter;
 
   while(1) {
+    FvwmPacket* packet;
     fd_set fdset;
 
     FD_ZERO(&fdset);
@@ -504,18 +512,23 @@
 
     /* parse any config lines (colorsets) */
     if (FD_ISSET(fd[1], &fdset)) {
-      char *tline;
+      char *tline, *token;
 
-      GetConfigLine(fd, &tline);
-      if (tline != NULL && (strlen(tline) > 1)) {
-/* this is where dynamic colorset changinf happens
-            SetWindowBackground(dpy, main_win, tw, th, G->bg, G->depth,
-				G->shadowGC);
-*/
+      packet = ReadFvwmPacket(fd[1]);
+      if (packet && packet->type == M_CONFIG_INFO ) {
+	tline = (char*)&(packet->body[3]);
+	tline = GetNextToken(tline, &token);
+	if (StrEquals(token, "Colorset")) {
+	  /* track all colorset changes and update display if necessary */
+	  if (LoadColorset(tline) == colorset) {
+	    SetWindowBackground(dpy, main_win, mysizehints.width,
+				mysizehints.height,
+				&Colorset[colorset % nColorsets], Pdepth, shadowGC);
+	  }
+	}
+	free(token);
       }
 
-      /* free up line malloc'd by GetConfigLine */
-      if (tline) free(tline);
     }
   }
   return;
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
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: Tim Phipps <[email-masked]>
Date: Wed, 21 Jul 1999 12:38:10 +0100

> Here is FvwmScroll:

Thanks.

---

From: Tim Phipps <[email-masked]>
Date: Wed, 21 Jul 1999 12:57:52 +0100

> upto 6*5 = 30 colorsets. Does that sound right to you??

The six colorsets per manager looks right. It's up to you if you want
each manager to have a completely diferent look to the others.  If
you're goinf to delve into it could you add a PlainIconButton option for
normal buttons of iconified windows?

Cheers,
Tim.