Subject: FVWM: FvwmButtons on the fly reconfigure

From: Marcus Lundblad <[email-masked]>
Date: Tue, 6 Nov 2001 20:14:27 +0100 (CET)

Is possible to "force" FvwmButtons and FvwmPager to reread setting "on the
the fly"?
I am making a setpu that enables setting colours in run time, so to speak
(and it remebers them, values are read using PipeRead commands from a
setup directory.
Setting window border colours and menu colours work fine, but the
buttonbar needs to be reset...
Is there a way to communicate with modules?

I'm building a setup system. I can release a link to this when it gets a
little more stable...

//Marcus

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Suzanne Britton <[email-masked]>
Date: Tue, 6 Nov 2001 19:38:02 -0500

> Is possible to "force" FvwmButtons and FvwmPager to reread setting "on the
[snip]
> Is there a way to communicate with modules?

There's a command for communicating with modules, SendToModule, but I think
each module has to be programmed individually to interpret and respond to such
an event (and most don't). There's no general infrastructure for dynamic
reconfiguration. Normally you have to restart a module to get it to
recognize new configuration.

I've developed a rough patch (on v. 2.4.3) to do this sort of thing with
FvwmPager, for my own purposes. It can respond to the following three messages:

SendToModule FvwmPager Pixmap <pixmap>
SendToModule FvwmPager Hilight <color>
SendToModule FvwmPager HilightPixmap <pixmap>

Here's the patch; maybe it'll be useful to you.

--- FvwmPager.h.orig	Wed Oct 10 01:33:26 2001
+++ FvwmPager.h	Wed Oct 10 01:32:55 2001
@@ -176,6 +176,8 @@
 void list_end(void);
 int My_XNextEvent(Display *dpy, XEvent *event);
 
+void dynamic_config(char *command);
+
 /* Stuff in x_pager.c */
 void change_colorset(int colorset);
 void initialize_pager(void);
--- FvwmPager.c.orig	Wed Oct 10 01:33:30 2001
+++ FvwmPager.c	Thu Nov  1 16:24:46 2001
@@ -324,6 +324,7 @@
 #endif
 
   SetMessageMask(fd,
+                 M_STRING|
                  M_ADD_WINDOW|
                  M_CONFIGURE_WINDOW|
                  M_DESTROY_WINDOW|
@@ -556,6 +557,9 @@
     case M_CONFIG_INFO:
       list_config_info(body);
       break;
+    case M_STRING:
+      dynamic_config((char*)&(body[3]));
+      break;
     default:
       /* ignore unknown packet */
       break;
@@ -2169,4 +2173,65 @@
   }
   XUngrabKeyboard(dpy, CurrentTime);
   exit(0);
+}
+
+void dynamic_config(char *command)
+{
+  char *resource, *value, *next;
+
+  next = command;
+  next = GetNextToken(next, &resource);
+  next = GetNextToken(next, &value);
+  if (!resource || !value) {
+    fprintf(stderr, "%s warning: dynamic config command '%s' unrecognized\n",
+            MyName, command);
+    if (resource)
+      free(resource);
+    if (value)
+      free(value);
+    return;
+  }
+  if (resource[strlen(resource)-1] == ':')
+    resource[strlen(resource)-1] = '\0';
+
+  if (StrEquals(resource, "Pixmap")) {
+    if (PixmapBack)
+      DestroyPicture(dpy, PixmapBack);
+    PixmapBack = CachePicture(dpy, Scr.Pager_w, ImagePath, value, 0);
+    if (!PixmapBack) {
+      fprintf(stderr, "%s warning: Couldn't load pixmap '%s'\n", MyName,
+              value);
+      return;
+    }
+    XSetWindowBackgroundPixmap(dpy, Desks[0].w, PixmapBack->picture);
+    ReConfigure();
+  }
+  else if (StrEquals(resource, "Hilight")) {
+    if (HilightC)
+      free(HilightC);
+    CopyString(&HilightC, value);
+    XSetForeground(dpy, Desks[0].HiliteGC, GetColor(HilightC));
+    XSetWindowBackground(dpy, Desks[0].CPagerWin, GetColor(HilightC));
+    XClearWindow(dpy, Desks[0].CPagerWin);
+    ReConfigure();
+  }
+  else if (StrEquals(resource, "HilightPixmap")) {
+    if (HilightPixmap)
+      DestroyPicture (dpy, HilightPixmap);
+    HilightPixmap = CachePicture(dpy, Scr.Pager_w, ImagePath, value, 0);
+    if (!HilightPixmap) {
+      fprintf(stderr, "%s warning: Couldn't load pixmap '%s'\n", MyName,
+              value);
+      return;
+    }
+    XSetWindowBackgroundPixmap(dpy, Desks[0].CPagerWin,
+                               HilightPixmap->picture);
+    XClearWindow(dpy, Desks[0].CPagerWin);
+  }
+  else
+    fprintf(stderr, "%s warning: dynamic config command '%s' unrecognized\n",
+            MyName, command);
+
+  free(resource);
+  free(value);
 }

Suzanne

-- 
[email-masked] - http://www.igs.net/~tril/
"I'm aware of that, sweetheart. It's just that when I wake up to a hissing
goat skull on my nightstand, and it hops off and runs across the floor on
spider legs, I sleep a lot better knowing where it ran off to."
                                                          - Ted (Red Meat)
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dominik Vogt <[email-masked]>
Date: Wed, 7 Nov 2001 14:19:28 +0100

> Is possible to "force" FvwmButtons and FvwmPager to reread setting "on the

Yes and no.  Most modules don't react to configuration changes on
the fly in general.  But since the "colour set" concept was
implemented (2.4), all colours can be controlled via a central
module called FvwmTheme.  You can basically specify sets of four
colours each (foreground, background, shadow and hilight) and
assign them to the various colours used in the modules (and fvwm
itself).  These can be changed at any time and take effect
immediately.  To learn about colour sets look for the keyword
"colorset" in the fvwm2 man page and read the FvwmTheme man page.

> I'm building a setup system. I can release a link to this when it gets a

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: [email-masked]
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dominik Vogt <[email-masked]>
Date: Wed, 7 Nov 2001 14:20:35 +0100

> SendToModule FvwmPager HilightPixmap <pixmap>

You don't really need that.  It can already be done with colour
sets.

Bye

Dominik ^_^  ^_^