First, the module should send the ID of the window which should be
manipulated. A window ID of ``None'' may be used, in which case Fvwm
will prompt the user to select a window if needed. Next, length of
the the command line is send as an integer. After that, the command
line itself is sent. Finally, an integer 1 is sent if the module plans
to continue operating, or 0 if the module is finished. The following
subroutine is provided as an example of a suitable method of sending
messages to fvwm:
void SendText(int *fd, char *message, unsigned long window) {
int w;
if (message != NULL) {
write(fd[0],&win,sizeof(Window));
w=strlen(message); /* calc the length of the message */
write(fd[0],&w,sizeof(int)); /* send the message length */
write(fd[0],message,w); /* send the message itself */
/* send a 1, indicating that this module will keep going */
/* a 0 would mean that this module is done */
w=1;
write(fd[0],&w,sizeof(int));
}
}
This routine is available as a library function in libfvwm.
For compatibility with older code, there is a macro "SendInfo"
which can be used instead of the function name SentText.
SendText(Channel,"SendWindowList",0);Send_ConfigInfo causes fvwm to send the module a list of all some or all commands it has received which start with a ``*'', as well as the ImagePath, ColorLimit, and ClickTime commands that fvwm is currently using. This is implemented in fvwm/modconf.c. Note that "Send_ConfigInfo" is sort of a memory dump type request, and the number of commands a module might get from this request may change over time. The module should be prepared to ignore commands it is not interested in without generating a warning or error. This request is normally made during module startup for a module to read its current configuration and some general information. Fvwm provides some subroutines to make this process fairly painless. Here is an example from FvwmAnimate.c:
static void ParseOptions() { char *buf; InitGetConfigInfo(Channel,MyName); /* char *MyName = "*FvwmAnimate" */ while (GetConfigLine(Channel,&buf), buf != NULL) { ParseConfigLine(buf); } /* end config lines */ } /* end function */The call to "InitGetConfigInfo" is optional. If a module wants all the module commands (commands starting with ``*''), there is no need to use this command. Most modules only want module commands for the module itself. As shown in the example above, the second argument includes the leading asterisk. The match is caseless.
InitGetConfigInfo improves performance. Since the command matching is done in fvwm2, time is saved in both fvwm2 and the module. Remember that the module still has to name match if it wants to find its own configuration lines since other kinds of commands are sent along with module configuration lines.
SetMessageMask(Fvwm_fd,M_NEW_DESK|M_CONFIG_INFO|M_END_CONFIG_INFO);This mask is used to reduce the amount of communication between fvwm and its modules so that a module only gets the messages it needs.