Minor manpage formatting fix.
[fvwm.git] / libs / Module.h
blobe7acdad35b8a533ec7bbcad47af038d55dfbbe99
1 /* -*-c-*- */
2 #ifndef LIBS_MODULE_H
3 #define LIBS_MODULE_H
5 /*
6 ** Module.c: code for modules to communicate with fvwm
7 */
9 #include <X11/X.h>
10 #include "libs/fvwmlib.h"
12 /**
13 * fvwm sends packets of this type to modules.
14 **/
16 typedef struct
18 /* always holds START_FLAG value */
19 unsigned long start_pattern;
20 /* one of the M_xxx values, below */
21 unsigned long type;
22 /* number of unsigned longs in entire packet, *including* header */
23 unsigned long size;
24 /* last time stamp received from the X server, in milliseconds */
25 unsigned long timestamp;
26 /* variable size -- use FvwmPacketBodySize to get size */
27 unsigned long body[1];
28 } FvwmPacket;
30 typedef struct
32 Window w;
33 Window frame;
34 void *fvwmwin;
35 } FvwmWinPacketBodyHeader;
38 * If you modify constants here, please regenerate Constants.pm in perllib.
42 /** All size values in units of "unsigned long" **/
43 #define FvwmPacketHeaderSize 4
44 #define FvwmPacketBodySize(p) ((p).size - FvwmPacketHeaderSize)
45 #define FvwmPacketMaxSize 256
46 #define FvwmPacketBodyMaxSize (FvwmPacketMaxSize - FvwmPacketHeaderSize)
48 /** There seems to be some movement afoot to measure packet sizes in bytes.
49 See fvwm/module_interface.c **/
50 #define FvwmPacketHeaderSize_byte \
51 (FvwmPacketHeaderSize * sizeof(unsigned long))
52 #define FvwmPacketBodySize_byte(p) \
53 (FvwmPacketBodySize(p) * sizeof(unsigned long))
54 #define FvwmPacketMaxSize_byte \
55 (FvwmPacketMaxSize * sizeof(unsigned long))
56 #define FvwmPacketBodyMaxSize_byte \
57 (FvwmPacketBodyMaxSize * sizeof(unsigned long))
60 /* Value of start_pattern */
61 #define START_FLAG 0xffffffff
63 #define ModuleFinishedStartupResponse "NOP FINISHED STARTUP"
64 #define ModuleUnlockResponse "NOP UNLOCK"
66 /* Possible values of type */
67 #define M_NEW_PAGE (1)
68 #define M_NEW_DESK (1<<1)
69 #define M_OLD_ADD_WINDOW (1<<2)
70 #define M_RAISE_WINDOW (1<<3)
71 #define M_LOWER_WINDOW (1<<4)
72 #define M_OLD_CONFIGURE_WINDOW (1<<5)
73 #define M_FOCUS_CHANGE (1<<6)
74 #define M_DESTROY_WINDOW (1<<7)
75 #define M_ICONIFY (1<<8)
76 #define M_DEICONIFY (1<<9)
77 #define M_WINDOW_NAME (1<<10)
78 #define M_ICON_NAME (1<<11)
79 #define M_RES_CLASS (1<<12)
80 #define M_RES_NAME (1<<13)
81 #define M_END_WINDOWLIST (1<<14)
82 #define M_ICON_LOCATION (1<<15)
83 #define M_MAP (1<<16)
85 /* It turns out this is defined by <sys/stream.h> on Solaris 2.6.
86 I suspect that simply redefining this will lead to trouble;
87 at some point, these should probably be renamed (FVWM_MSG_ERROR?). */
88 #ifdef M_ERROR
89 # undef M_ERROR
90 #endif
91 #define M_ERROR (1<<17)
93 #define M_CONFIG_INFO (1<<18)
94 #define M_END_CONFIG_INFO (1<<19)
95 #define M_ICON_FILE (1<<20)
96 #define M_DEFAULTICON (1<<21)
97 #define M_STRING (1<<22)
98 #define M_MINI_ICON (1<<23)
99 #define M_WINDOWSHADE (1<<24)
100 #define M_DEWINDOWSHADE (1<<25)
101 #define M_VISIBLE_NAME (1<<26)
102 #define M_SENDCONFIG (1<<27)
103 #define M_RESTACK (1<<28)
104 #define M_ADD_WINDOW (1<<29)
105 #define M_CONFIGURE_WINDOW (1<<30)
106 #define M_EXTENDED_MSG (1<<31)
107 #define MAX_MESSAGES 31
108 #define MAX_MSG_MASK 0x7fffffff
110 /* to get more than the old maximum of 32 messages, the 32nd bit is reserved to
111 * mark another 31 messages that have this bit and another one set.
112 * When handling received messages, the message type can be compared to the
113 * MX_... macro. When using one of the calls that accepts a message mask, a
114 * separate call has to be made that ors the MX_... macros. The normal
115 * M_... and MX_... macros must *never* be or'ed in one of these operations'
117 #define MX_VISIBLE_ICON_NAME ((1<<0) | M_EXTENDED_MSG)
118 #define MX_ENTER_WINDOW ((1<<1) | M_EXTENDED_MSG)
119 #define MX_LEAVE_WINDOW ((1<<2) | M_EXTENDED_MSG)
120 #define MX_PROPERTY_CHANGE ((1<<3) | M_EXTENDED_MSG)
121 #define MX_REPLY ((1<<4) | M_EXTENDED_MSG)
122 #define MAX_EXTENDED_MESSAGES 5
123 #define DEFAULT_XMSG_MASK 0x00000000
124 #define MAX_XMSG_MASK 0x0000001f
126 #define MAX_TOTAL_MESSAGES (MAX_MESSAGES + MAX_EXTENDED_MESSAGES)
128 /* for MX_PROPERTY_CHANGE */
129 #define MX_PROPERTY_CHANGE_NONE 0
130 #define MX_PROPERTY_CHANGE_BACKGROUND 1
131 #define MX_PROPERTY_CHANGE_SWALLOW 2
134 * Reads a single packet of info from fvwm.
135 * The packet is stored into static memory that is reused during
136 * the next call to ReadFvwmPacket. Callers, therefore, must copy
137 * needed data before the next call to ReadFvwmPacket.
139 FvwmPacket* ReadFvwmPacket( int fd );
144 * SendFinishedStartupNotification - informs fvwm that the module has
145 * finished its startup procedures and is fully operational now.
148 void SendFinishedStartupNotification(int *fd);
152 * SendText - Sends arbitrary text/command back to fvwm
155 void SendText(int *fd, const char *message, unsigned long window);
158 /** Compatibility **/
159 #define SendInfo SendText
163 * SendUnlockNotification - informs fvwm that the module has
164 * finished it's procedures and fvwm may proceed.
167 void SendUnlockNotification(int *fd);
171 * SendQuitNotification - informs fvwm that the module has
172 * finished and may be killed.
175 void SendQuitNotification(int *fd);
179 * SendFvwmPipe - Sends message to fvwm: The message is a comma-delimited
180 * string separated into its component sections and sent one by one to fvwm.
181 * It is discouraged to use this function with a "synchronous" module.
182 * (Form FvwmIconMan)
185 void SendFvwmPipe(int *fd, const char *message, unsigned long window);
189 * Sets the which-message-types-do-I-want mask for modules
192 void SetMessageMask(int *fd, unsigned long mask);
196 * Sets the which-message-types-do-I-want to be lock on send for modules
199 void SetSyncMask(int *fd, unsigned long mask);
203 * Sets the which-message-types-I-do-not-want while the server is grabbed
204 * and module transmission is locked at the same time.
207 void SetNoGrabMask(int *fd, unsigned long mask);
210 * Used to ask for subset of module configuration lines.
211 * Allows modules to get configuration lines more than once.
213 void InitGetConfigLine(int *fd, char *match);
216 * Gets a module configuration line from fvwm. Returns NULL if there are
217 * no more lines to be had. "line" is a pointer to a char *.
219 void GetConfigLine(int *fd, char **line);
221 /* expands certain variables in a command to be sent by a module */
222 char *module_expand_action(
223 Display *dpy, int screen , char *in_action, rectangle *r,
224 char *forecolor, char *backcolor);
227 * Parse the command line arguments given to the module by fvwm.
228 * Input is the argc & argv from main(), and a flag to indicate
229 * if we accept a module alias as argument #6.
231 * Returns a pointer to a ModuleArgs structure, or NULL if something
232 * is not kosher. The returned memory is a static buffer.
235 typedef struct
237 /* module name */
238 char* name;
239 /* length of the module name */
240 int namelen;
241 /* file descriptor to send info back to fvwm */
242 int to_fvwm;
243 /* file descriptor to read packets from fvwm */
244 int from_fvwm;
245 /* window context of module */
246 Window window;
247 /* decoration context of module */
248 unsigned long decoration;
249 /* number of user-specified arguments */
250 int user_argc;
251 /* vector of user-specified arguments */
252 char** user_argv;
253 } ModuleArgs;
255 ModuleArgs* ParseModuleArgs( int argc, char* argv[], int use_arg6_as_alias );
257 #endif