fvwm-convert-2.6: Only print out StartFunction when defined.
[fvwm.git] / modules / FvwmButtons / FvwmButtons.h
blob7ae63083be88fad6b80e213112eddeb5038e7483
1 /* -*-c-*- */
2 /*
3 * FvwmButtons, copyright 1996, Jarl Totland
5 * This module, and the entire GoodStuff program, and the concept for
6 * interfacing this module to the Window Manager, are all original work
7 * by Robert Nation
9 * Copyright 1993, Robert Nation. No guarantees or warantees or anything
10 * are provided or implied in any way whatsoever. Use this program at your
11 * own risk. Permission to use this program for any purpose is given,
12 * as long as the copyright is kept intact.
16 /* -------------------------------- DEBUG ---------------------------------- */
18 /* Uncomment some of these defines to get (lots of) debug output. If you can't
19 get it started, DEBUG_LOADDATA and DEBUG_INIT might be handy. The default
20 DEBUG only generates output on warnings, and adds the functions DumpButtons
21 and SaveButtons */
22 #if 0
23 #define DEBUG
24 #define DEBUG_LOADDATA /* Get updates on loading */
25 #define DEBUG_INIT /* Get startup progress */
26 #define DEBUG_HANGON /* Debug hangon, swallow and unswallow */
27 /* #define DEBUG_EVENTS */ /* Get much info on events */
28 #define DEBUG_FVWM /* Debug communciation with fvwm */
29 /* #define DEBUG_X */
30 #endif
32 /* ---------------------------- compatibility ------------------------------ */
34 /*#define OLD_EXPOSE*/ /* Try this if resizing/exposes screw up */
36 /* -------------------------------- more ---------------------------------- */
38 #include "libs/fvwmlib.h"
39 #include "libs/Picture.h"
40 #include "libs/Flocale.h"
42 /* ------------------------------- structs --------------------------------- */
44 /* flags for b->flags */
45 typedef struct
47 unsigned b_Container : 1; /* Contains several buttons */
48 unsigned b_Font : 1; /* Has personal font data */
49 unsigned b_Fore : 1; /* Has personal text color */
50 unsigned b_Back : 1; /* Has personal background color (or "none") */
51 unsigned b_Padding : 1; /* Has personal padding data */
52 unsigned b_Frame : 1; /* Has personal framewidth */
53 unsigned b_Title : 1; /* Contains title */
54 unsigned b_Icon : 1; /* Contains icon */
55 unsigned b_Swallow : 1; /* Contains swallowed window */
56 unsigned b_Action : 1; /* Fvwm action when clicked on */
57 unsigned b_Hangon : 1; /* Is waiting for a window before
58 turning active */
59 unsigned b_Justify : 1; /* Has justification info */
60 unsigned b_Size : 1; /* Has a minimum size, don't guess */
61 unsigned b_IconBack : 1; /* Has an icon as background */
62 unsigned b_IconParent : 1; /* Parent has an icon as background */
63 unsigned b_TransBack : 1; /* Transparent background */
64 unsigned b_Left : 1; /* Button is left-aligned */
65 unsigned b_Right : 1; /* Button is right-aligned */
66 unsigned b_Top : 1; /* Button is aligned at the top */
67 unsigned b_SizeFixed : 1; /* User provided rows/columns may not be
68 altered */
69 unsigned b_PosFixed : 1; /* User provided button position */
70 unsigned b_SizeSmart : 1; /* Improved button box sizing */
71 unsigned b_Colorset : 1; /* use colorset instead of fore/back */
72 unsigned b_ColorsetParent : 1; /* Parent has a colorset background */
73 unsigned b_Panel : 1; /* like swallow but drawn differently */
74 unsigned b_ActionIgnoresClientWindow : 1;
75 /* Actions work only on the background
76 of a button with a swallowed app. */
77 unsigned b_ActionOnPress : 1; /* By default this only done on Popup */
78 unsigned b_Id : 1; /* Has user-defined id for referencing */
79 unsigned b_ActiveIcon : 1; /* Use alternate Icon on hover */
80 unsigned b_ActiveColorset : 1; /* Use alternate colorset on hover */
81 unsigned b_ActiveTitle : 1; /* Use alternate Title text on hover */
82 unsigned b_PressIcon : 1; /* Use alternate Icon on press */
83 unsigned b_PressColorset : 1; /* Use alternate Colorset on press */
84 unsigned b_PressTitle : 1; /* Use alternate Title text on press */
85 } flags_type;
87 /* Flags for b->swallow */
88 #define b_Count 0x0003 /* Init counter for swallowing */
89 #define b_NoHints 0x0004 /* Ignore window hints from swallowed window */
90 #define b_NoClose 0x0008 /* Don't close window when exiting, unswallow it */
91 #define b_Kill 0x0010 /* Don't close window when exiting, kill it */
92 #define b_Respawn 0x0020 /* Respawn if swallowed window dies */
93 #define b_UseOld 0x0040 /* Try to capture old window, don't spawn it */
94 #define b_UseTitle 0x0080 /* Allow window to write to b->title */
95 #define b_FvwmModule 0x0100 /* consider the swallowed app as module */
97 /* Flags for b->justify */
98 #define b_TitleHoriz 0x03 /* Mask for title x positioning info */
99 #define b_Horizontal 0x04 /* HACK: stack title and iconwin horizontally */
101 typedef struct button_info_struct button_info;
102 typedef struct container_info_struct container_info;
103 #define ushort unsigned int
104 #define byte unsigned char
106 /* This structure contains data that the parents give their children */
107 struct container_info_struct
109 button_info **buttons; /* Required fields */
110 int allocated_buttons;
111 int num_buttons;
112 int num_columns;
113 int num_rows;
114 int xpos;
115 int ypos;
116 int width;
117 int height;
119 flags_type flags; /* Which data is set in this container? */
120 byte justify; /* b_Justify */
121 byte justify_mask; /* b_Justify */
122 unsigned int swallow; /* b_Swallow */
123 unsigned int swallow_mask; /* b_Swallow */
124 byte xpad, ypad; /* b_Padding */
125 signed char framew; /* b_Frame */
126 FlocaleFont *Ffont; /* b_Font */
127 char *font_string; /* b_Font */
128 char *back; /* b_Back && !b_IconBack */
129 char *back_file; /* b_Back && b_IconBack */
130 char *fore; /* b_Fore */
131 int colorset; /* b_Colorset */
132 int activeColorset; /* b_ActiveColorset */
133 int pressColorset; /* b_PressColorset */
134 Pixel fc; /* b_Fore */
135 Pixel bc, hc, sc; /* b_Back && !b_IconBack */
136 FvwmPicture *backicon; /* b_Back && b_IconBack */
137 ushort minx, miny; /* b_Size */
140 typedef struct
142 unsigned smooth : 1;
143 unsigned ignore_lrborder : 1;
144 unsigned ignore_tbborder : 1;
145 unsigned buttons_lrborder : 1;
146 unsigned buttons_tbborder : 1;
147 unsigned relative_x_pixel : 1;
148 unsigned relative_y_pixel : 1;
149 unsigned panel_indicator : 1; /* b_Panel */
150 } panel_flags_type;
152 struct button_info_struct
154 /* required fields */
155 flags_type flags;
156 int BPosX,BPosY; /* position in button units from top left */
157 unsigned int BWidth,BHeight; /* width and height in button units */
158 button_info *parent;
159 int n; /* number in parent */
161 /* conditional fields */ /* applicable if these flags are set */
162 char *id; /* b_Id */
163 FlocaleFont *Ffont; /* b_Font */
164 char *font_string; /* b_Font */
165 char *back; /* b_Back */
166 char *fore; /* b_Fore */
167 int colorset; /* b_Colorset */
168 byte xpad, ypad; /* b_Padding */
169 signed char framew; /* b_Frame */
170 byte justify; /* b_Justify */
171 byte justify_mask; /* b_Justify */
172 container_info *c; /* b_Container */
173 char *title; /* b_Title */
174 char *activeTitle; /* b_ActiveTitle */
175 char *pressTitle; /* b_PressTitle */
176 char **action; /* b_Action */
177 char *icon_file; /* b_Icon */
178 char *active_icon_file; /* b_ActiveIcon */
179 char *press_icon_file; /* b_PressIcon */
180 char *hangon; /* b_Hangon || b_Swallow */
181 Pixel fc; /* b_Fore */
182 Pixel bc, hc, sc; /* b_Back && !b_IconBack */
183 ushort minx, miny; /* b_Size */
184 FvwmPicture *icon; /* b_Icon */
185 FvwmPicture *backicon; /* b_Back && b_IconBack */
186 FvwmPicture *activeicon; /* b_ActiveIcon */
187 FvwmPicture *pressicon; /* b_PressIcon */
188 int activeColorset; /* b_ActiveColorset */
189 int pressColorset; /* b_PressColorset */
190 Window IconWin; /* b_Swallow */
191 Window PanelWin; /* b_Panel */
192 Window BackIconWin; /* b_Back && b_IconBack */
194 unsigned int swallow; /* b_Swallow */
195 unsigned int swallow_mask; /* b_Swallow */
196 int icon_w, icon_h; /* b_Swallow */
197 Window IconWinParent; /* b_Swallow */
198 XSizeHints *hints; /* b_Swallow && !b_NoHints */
199 char *spawn; /* b_Swallow */
200 int x, y; /* b_Swallow */
201 ushort w, h, bw; /* b_Swallow */
203 /* The newflags struct can probably be merged in with flags_type struct. */
204 struct
206 unsigned is_panel : 1; /* b_Panel */
207 unsigned panel_mapped : 1; /* b_Panel */
208 unsigned panel_iconified : 1; /* b_Panel */
209 unsigned panel_shaded : 1; /* b_Panel */
210 unsigned do_swallow_new : 1;
211 } newflags;
213 #define SLIDE_UP 'u'
214 #define SLIDE_DOWN 'd'
215 #define SLIDE_LEFT 'l'
216 #define SLIDE_RIGHT 'r'
217 #define SLIDE_GEOMETRY 'g'
218 char slide_direction; /* b_Panel */
219 #define SLIDE_POSITION_CENTER 'c'
220 #define SLIDE_POSITION_LEFT_TOP 'l'
221 #define SLIDE_POSITION_RIGHT_BOTTOM 'r'
222 char slide_position; /* b_Panel */
223 #define SLIDE_CONTEXT_PB 'b'
224 #define SLIDE_CONTEXT_MODULE 'm'
225 #define SLIDE_CONTEXT_ROOT 'r'
226 char slide_context; /* b_Panel */
227 int relative_x; /* b_Panel */
228 int relative_y; /* b_Panel */
229 int slide_steps; /* b_Panel */
230 int slide_delay_ms; /* b_Panel */
231 int indicator_size; /* b_Panel */
232 panel_flags_type panel_flags;
235 #include "button.h"
237 /* -------------------------------- prototypes ----------------------------- */
238 void AddButtonAction(button_info*, int, char*);
239 void MakeContainer(button_info*);
240 void change_swallowed_window_colorset(button_info *b, Bool do_clear);
241 #ifdef DEBUG
242 char *mymalloc(int);
243 #else
244 #define mymalloc(a) safemalloc(a)
245 #endif
246 void handle_xinerama_string(char *args);
247 int LoadIconFile(const char *s, FvwmPicture **p, int cset);
248 void SetTransparentBackground(button_info *ub, int w, int h);
249 void exec_swallow(char *action, button_info *b);
251 char *GetButtonAction(button_info*,int);
252 void ButtonPressProcess(button_info *b, char **act);
254 /* ----------------------------- global variables -------------------------- */
256 extern Display *Dpy;
257 extern Window Root;
258 extern Window MyWindow;
259 extern char *MyName;
260 extern button_info *UberButton, *CurrentButton, *ActiveButton;
261 extern Bool is_pointer_in_current_button;
263 extern char *imagePath;
264 extern int fd[];
266 extern int new_desk;
267 extern GC NormalGC;
268 extern GC ShadowGC;
269 extern FlocaleWinString *FwinString;
271 /* ---------------------------------- misc --------------------------------- */