Re: FVWM: FvwmButtons on the fly reconfigure

From: Suzanne Britton <tril_at_igs.net>
Date: Tue, 6 Nov 2001 19:38:02 -0500

> Is possible to "force" FvwmButtons and FvwmPager to reread setting "on the
> the fly"?
[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
_at_@ -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
_at_@ -324,6 +324,7 @@
 #endif
 
   SetMessageMask(fd,
+ M_STRING|
                  M_ADD_WINDOW|
                  M_CONFIGURE_WINDOW|
                  M_DESTROY_WINDOW|
_at_@ -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;
_at_@ -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

-- 
tril_at_igs.net - 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 majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Tue Nov 06 2001 - 18:38:23 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:52 BST