* FvwmTheme/FvwmTheme.1: Language check, general edits,
[fvwm.git] / libs / Module.h
blob2e481a7019ac47c90654f6b6a6567a295329063f
1 #ifndef LIBS_MODULE_H
2 #define LIBS_MODULE_H
3 /* This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ** Module.c: code for modules to communicate with fvwm
22 #include <X11/X.h>
23 #include "libs/fvwmlib.h"
26 /**
27 * FVWM sends packets of this type to modules.
28 **/
31 typedef struct {
32 unsigned long start_pattern; /* always holds START_FLAG value */
33 unsigned long type; /* one of the M_xxx values, below */
34 unsigned long size; /* number of unsigned longs in
35 entire packet, *including* header */
36 unsigned long timestamp; /* last time stamp received from the
37 X server, in milliseconds */
38 unsigned long body[1]; /* variable size -- use
39 FvwmPacketBodySize to get size */
40 } FvwmPacket;
42 typedef struct
44 Window w;
45 Window frame;
46 void *fvwmwin;
47 } FvwmWinPacketBodyHeader;
50 * If you modify constants here, please regenerate Constants.pm in perllib.
54 /** All size values in units of "unsigned long" **/
55 #define FvwmPacketHeaderSize 4
56 #define FvwmPacketBodySize(p) ((p).size - FvwmPacketHeaderSize)
57 #define FvwmPacketMaxSize 256
58 #define FvwmPacketBodyMaxSize (FvwmPacketMaxSize - FvwmPacketHeaderSize)
60 /** There seems to be some movement afoot to measure packet sizes in bytes.
61 See fvwm/module_interface.c **/
62 #define FvwmPacketHeaderSize_byte (FvwmPacketHeaderSize * sizeof(unsigned long))
63 #define FvwmPacketBodySize_byte(p) (FvwmPacketBodySize(p) * sizeof(unsigned long))
64 #define FvwmPacketMaxSize_byte (FvwmPacketMaxSize * sizeof(unsigned long))
65 #define FvwmPacketBodyMaxSize_byte (FvwmPacketBodyMaxSize * sizeof(unsigned long))
68 /* Value of start_pattern */
69 #define START_FLAG 0xffffffff
71 #define ModuleFinishedStartupResponse "NOP FINISHED STARTUP"
72 #define ModuleUnlockResponse "NOP UNLOCK"
74 /* Possible values of type */
75 #define M_NEW_PAGE (1)
76 #define M_NEW_DESK (1<<1)
77 #define M_OLD_ADD_WINDOW (1<<2)
78 #define M_RAISE_WINDOW (1<<3)
79 #define M_LOWER_WINDOW (1<<4)
80 #define M_OLD_CONFIGURE_WINDOW (1<<5)
81 #define M_FOCUS_CHANGE (1<<6)
82 #define M_DESTROY_WINDOW (1<<7)
83 #define M_ICONIFY (1<<8)
84 #define M_DEICONIFY (1<<9)
85 #define M_WINDOW_NAME (1<<10)
86 #define M_ICON_NAME (1<<11)
87 #define M_RES_CLASS (1<<12)
88 #define M_RES_NAME (1<<13)
89 #define M_END_WINDOWLIST (1<<14)
90 #define M_ICON_LOCATION (1<<15)
91 #define M_MAP (1<<16)
93 /* It turns out this is defined by <sys/stream.h> on Solaris 2.6.
94 I suspect that simply redefining this will lead to trouble;
95 at some point, these should probably be renamed (FVWM_MSG_ERROR?). */
96 #ifdef M_ERROR
97 # undef M_ERROR
98 #endif
99 #define M_ERROR (1<<17)
101 #define M_CONFIG_INFO (1<<18)
102 #define M_END_CONFIG_INFO (1<<19)
103 #define M_ICON_FILE (1<<20)
104 #define M_DEFAULTICON (1<<21)
105 #define M_STRING (1<<22)
106 #define M_MINI_ICON (1<<23)
107 #define M_WINDOWSHADE (1<<24)
108 #define M_DEWINDOWSHADE (1<<25)
109 #define M_VISIBLE_NAME (1<<26)
110 #define M_SENDCONFIG (1<<27)
111 #define M_RESTACK (1<<28)
112 #define M_ADD_WINDOW (1<<29)
113 #define M_CONFIGURE_WINDOW (1<<30)
114 #define M_EXTENDED_MSG (1<<31)
115 #define MAX_MESSAGES 31
116 #define MAX_MSG_MASK 0x7fffffff
118 /* to get more than the old maximum of 32 messages, the 32nd bit is reserved to
119 * mark another 31 messages that have this bit and another one set.
120 * When handling received messages, the message type can be compared to the
121 * MX_... macro. When using one of the calls that accepts a message mask, a
122 * separate call has to be made that ors the MX_... macros. The normal
123 * M_... and MX_... macros must *never* be or'ed in one of these operations'
125 #define MX_VISIBLE_ICON_NAME ((1<<0) | M_EXTENDED_MSG)
126 #define MX_ENTER_WINDOW ((1<<1) | M_EXTENDED_MSG)
127 #define MX_LEAVE_WINDOW ((1<<2) | M_EXTENDED_MSG)
128 #define MX_PROPERTY_CHANGE ((1<<3) | M_EXTENDED_MSG)
129 #define MAX_EXTENDED_MESSAGES 4
130 #define DEFAULT_XMSG_MASK 0x00000000
131 #define MAX_XMSG_MASK 0x0000000f
133 #define MAX_TOTAL_MESSAGES (MAX_MESSAGES + MAX_EXTENDED_MESSAGES)
135 /* for MX_PROPERTY_CHANGE */
136 #define MX_PROPERTY_CHANGE_NONE 0
137 #define MX_PROPERTY_CHANGE_BACKGROUND 1
138 #define MX_PROPERTY_CHANGE_SWALLOW 2
141 * Reads a single packet of info from FVWM.
142 * The packet is stored into static memory that is reused during
143 * the next call to ReadFvwmPacket. Callers, therefore, must copy
144 * needed data before the next call to ReadFvwmPacket.
146 FvwmPacket* ReadFvwmPacket( int fd );
149 /************************************************************************
151 * SendFinishedStartupNotification - informs fvwm that the module has
152 * finished its startup procedures and is fully operational now.
154 ***********************************************************************/
155 void SendFinishedStartupNotification(int *fd);
157 /************************************************************************
159 * SendText - Sends arbitrary text/command back to fvwm
161 ***********************************************************************/
162 void SendText(int *fd, const char *message, unsigned long window);
165 /** Compatibility **/
166 #define SendInfo SendText
168 /************************************************************************
170 * SendFinishedStartupNotification - informs fvwm that the module has
171 * finished its startup procedures and is fully operational now.
173 ***********************************************************************/
174 void SendFinishedStartupNotification(int *fd);
176 /************************************************************************
178 * SendUnlockNotification - informs fvwm that the module has
179 * finished it's procedures and fvwm may proceed.
181 ***********************************************************************/
182 void SendUnlockNotification(int *fd);
184 /************************************************************************
186 * SendQuitNotification - informs fvwm that the module has
187 * finished and may be killed.
189 ***********************************************************************/
190 void SendQuitNotification(int *fd);
192 /************************************************************************
194 * SendFvwmPipe - Sends message to fvwm: The message is a comma-delimited
195 * string separated into its component sections and sent one by one to fvwm.
196 * It is discouraged to use this function with a "synchronous" module.
197 * (Form FvwmIconMan)
199 ***********************************************************************/
200 void SendFvwmPipe(int *fd, const char *message, unsigned long window);
202 /***************************************************************************
204 * Sets the which-message-types-do-I-want mask for modules
206 **************************************************************************/
207 void SetMessageMask(int *fd, unsigned long mask);
209 /***************************************************************************
211 * Sets the which-message-types-do-I-want to be lock on send for modules
213 **************************************************************************/
214 void SetSyncMask(int *fd, unsigned long mask);
216 /***************************************************************************
218 * Sets the which-message-types-I-do-not-want while the server is grabbed
219 * and module transmission is locked at the same time.
221 **************************************************************************/
222 void SetNoGrabMask(int *fd, unsigned long mask);
225 * Used to ask for subset of module configuration lines.
226 * Allows modules to get configuration lines more than once.
228 void InitGetConfigLine(int *fd, char *match);
232 * Gets a module configuration line from fvwm. Returns NULL if there are
233 * no more lines to be had. "line" is a pointer to a char *.
235 void GetConfigLine(int *fd, char **line);
238 /* expands certain variables in a command to be sent by a module */
239 char *module_expand_action(
240 Display *dpy, int screen , char *in_action, rectangle *r,
241 char *forecolor, char *backcolor);
244 * Parse the command line arguments given to the module by FVWM.
245 * Input is the argc & argv from main(), and a flag to indicate
246 * if we accept a module alias as argument #6.
248 * Returns a pointer to a ModuleArgs structure, or NULL if something
249 * is not kosher. The returned memory is a static buffer.
252 typedef struct {
253 char* name; /* module name */
254 int to_fvwm; /* file descriptor to send info back to FVWM */
255 int from_fvwm; /* file descriptor to read packets from FVWM */
256 Window window; /* window context of module */
257 unsigned long decoration; /* decoration context of module */
258 int user_argc; /* number of user-specified arguments */
259 char** user_argv; /* vector of user-specified arguments */
260 } ModuleArgs;
263 ModuleArgs* ParseModuleArgs( int argc, char* argv[], int use_arg6_as_alias );
266 #endif