Propagate Layer changes via Style command on-the-fly.
[fvwm.git] / modules / FvwmIconMan / FvwmIconMan.h
blob3406a4bc88bd6d6cd76363d9e3ce694781fd99dc
1 /* -*-c-*- */
2 #ifndef IN_FVWMICONMAN_H
3 #define IN_FVWMICONMAN_H
5 #include <assert.h>
6 #include <stdio.h>
8 #include "libs/ftime.h"
10 #include <X11/Xlib.h>
11 #include <X11/Intrinsic.h>
13 #include "libs/fvwmlib.h"
14 #include "libs/Flocale.h"
15 #include "libs/Picture.h"
16 #include "libs/Colorset.h"
17 #include "libs/Bindings.h"
18 #include "libs/charmap.h"
19 #include "libs/modifiers.h"
21 #include "debug.h"
22 #include "fvwm/fvwm.h"
23 #include "libs/vpacket.h"
24 #include "libs/FTips.h"
26 #ifndef DEFAULT_ACTION
27 #define DEFAULT_ACTION "Iconify"
28 #endif
30 #define MAX_ARGS 3
32 #ifdef TRACE_MEMUSE
34 #define MALLOC_MAGIC 0xdeadbeaf
36 #define SET_BIT(field,bit) ((field) |= (bit))
37 #define CLEAR_BIT(field,bit) ((field) &= ~(bit))
39 #define SET_BIT_TO_VAL(field,bit,val) ((val) ? SET_BIT (field,bit) : CLEAR_BIT (field, bit))
41 extern long MemUsed;
43 struct malloc_header {
44 unsigned long magic, len;
47 #endif
49 #ifdef HAVE_DMALLOC_H
50 #include <dmalloc.h>
51 #endif
53 extern void PrintMemuse(void);
55 typedef unsigned long Ulong;
56 typedef unsigned char Uchar;
58 typedef signed char Schar;
60 typedef enum {
61 SHOW_GLOBAL,
62 SHOW_DESKTOP,
63 SHOW_PAGE,
64 SHOW_SCREEN,
65 NO_SHOW_DESKTOP, /* "!desk" Show windows not on the current desk */
66 NO_SHOW_PAGE, /* "!page" Show windows not on the current page */
67 NO_SHOW_SCREEN, /* "!screen" Show windows not on the current screen */
68 } Resolution;
70 typedef enum {
71 REVERSE_NONE,
72 REVERSE_ICON,
73 REVERSE_NORMAL,
74 } Reverse;
76 typedef enum {
77 BUTTON_FLAT,
78 BUTTON_UP,
79 BUTTON_DOWN,
80 BUTTON_EDGEUP,
81 BUTTON_EDGEDOWN,
82 } ButtonState;
84 /* The clicks must be the first three elements in this type, X callbacks
85 depend on it! */
86 typedef enum {
87 SELECT,
88 MOUSE,
89 KEYPRESS,
90 NUM_ACTIONS
91 } Action;
94 typedef enum {
95 DEFAULT = 0,
96 FOCUS_CONTEXT = 1,
97 SELECT_CONTEXT = 2,
98 /* had better be FOCUS_CONTEXT | SELECT_CONTEXT */
99 FOCUS_SELECT_CONTEXT = 3,
100 PLAIN_CONTEXT = 4,
101 TITLE_CONTEXT = 5,
102 ICON_CONTEXT = 6,
103 NUM_CONTEXTS
104 } Contexts;
106 typedef enum {
107 NO_NAME = 0,
108 TITLE_NAME = 1,
109 ICON_NAME = 2,
110 RESOURCE_NAME = 4,
111 CLASS_NAME = 8,
112 ALL_NAME = 15
113 } NameType;
115 typedef struct win_list {
116 int n;
117 struct win_data *head, *tail;
118 } WinList;
120 typedef struct string_list {
121 NameType type;
122 char *string;
123 struct string_list *next;
124 } StringEl;
126 typedef struct {
127 Uchar mask;
128 StringEl *list;
129 } StringList;
131 typedef enum {
132 NoArg,
133 IntArg,
134 StringArg,
135 ButtonArg,
136 WindowArg,
137 ManagerArg,
138 JmpArg
139 } BuiltinArgType;
141 typedef enum {
142 NoButton,
143 SelectButton,
144 FocusButton,
145 AbsoluteButton,
146 UpButton,
147 DownButton,
148 LeftButton,
149 RightButton,
150 NextButton,
151 PrevButton,
152 } ButtonType; /* doubles for manager too */
154 typedef struct {
155 int offset;
156 ButtonType base;
157 } ButtonValue;
159 typedef struct builtin_arg {
160 BuiltinArgType type;
161 union {
162 char *string_value;
163 ButtonValue button_value;
164 int int_value;
165 } value;
166 } BuiltinArg;
168 typedef struct Function {
169 int (*func)(int numargs, BuiltinArg *args);
170 int numargs;
171 BuiltinArg args[MAX_ARGS];
172 struct Function *next;
173 struct Function *prev;
174 } Function;
176 typedef struct win_data {
177 struct button *button;
178 /* stuff shadowed in the Button structure */
179 FvwmPicture pic;
180 FvwmPicture old_pic;
181 Uchar iconified, state;
183 Ulong desknum;
184 long x, y, width, height;
185 rectangle icon_g;
186 rectangle real_g; /* geometry of the client possibliy shaded */
187 Ulong app_id;
188 /* Ulong fvwm_flags; */
189 window_flags flags;
190 struct win_data *win_prev, *win_next;
191 struct win_manager *manager;
192 int app_id_set : 1;
193 int geometry_set : 1;
194 Uchar complete;
196 /* this data must be freed */
197 char *display_string; /* what gets shown in the manager window */
198 char *resname;
199 char *classname;
200 char *titlename;
201 char *iconname;
202 char *visible_name;
203 char *visible_icon_name;
204 } WinData;
206 typedef struct button {
207 int index; /* index into button array */
208 int x, y, w, h; /* current coords of button */
209 struct {
210 int dirty_flags;
211 FvwmPicture pic;
212 WinData *win;
213 char *display_string;
214 int x, y, w, h;
215 Uchar iconified, state;
216 int ex, ey, ew, eh; /* expose damage relatively the main win */
217 } drawn_state;
218 } Button;
220 typedef struct button_array {
221 int dirty_flags;
222 int num_buttons, drawn_num_buttons; /* size of buttons array */
223 int num_windows, drawn_num_windows; /* number of windows with buttons */
224 Button **buttons;
225 } ButtonArray;
227 typedef enum {
228 GROW_HORIZ = 1,
229 GROW_VERT = 2,
230 GROW_UP = 4,
231 GROW_DOWN = 8,
232 GROW_LEFT = 16,
233 GROW_RIGHT = 32,
234 GROW_FIXED = 64,
235 } GrowDirection;
237 typedef struct {
238 /* Things which we can change go in here.
239 * Things like border width go in WinManager */
240 int x, y, width, height;
241 int gravity_x, gravity_y; /* anchor point for window's gravity */
242 unsigned int rows, cols;
243 int boxheight, boxwidth;
244 GrowDirection dir;
245 } ManGeometry;
247 typedef struct {
248 int num_rects;
249 XRectangle rects[2];
250 } ShapeState;
252 typedef enum {
253 SortNone, /* no sorting */
254 SortId, /* sort by window id */
255 SortName, /* case insensitive name sorting */
256 SortNameCase, /* case sensitive name sorting */
257 SortWeighted, /* custom sort order */
258 } SortType;
260 typedef struct {
261 char *resname;
262 char *classname;
263 char *titlename;
264 char *iconname;
265 int weight;
266 } WeightedSort;
268 typedef struct win_manager {
269 unsigned int magic;
270 int index;
272 /* .fvwm2rc options or things set as a result of options */
273 Resolution res;
274 Reverse rev;
275 Pixel backcolor[NUM_CONTEXTS], forecolor[NUM_CONTEXTS];
276 Pixel hicolor[NUM_CONTEXTS], shadowcolor[NUM_CONTEXTS];
277 GC hiContext[NUM_CONTEXTS], backContext[NUM_CONTEXTS],
278 reliefContext[NUM_CONTEXTS];
279 GC shadowContext[NUM_CONTEXTS], flatContext[NUM_CONTEXTS];
280 FlocaleFont *FButtonFont;
281 int draw_icons;
282 int shaped;
283 StringList show;
284 StringList dontshow;
285 Binding *bindings[NUM_ACTIONS];
286 char *fontname;
287 int colorsets[NUM_CONTEXTS];
288 Pixmap pixmap[NUM_CONTEXTS];
289 char *backColorName[NUM_CONTEXTS];
290 char *foreColorName[NUM_CONTEXTS];
291 ButtonState buttonState[NUM_CONTEXTS];
292 char *geometry_str, *button_geometry_str;
293 int max_button_width;
294 int max_button_width_columns;
295 char *titlename, *iconname;
296 char *formatstring;
297 NameType format_depend;
298 Uchar followFocus;
299 Uchar usewinlist;
300 SortType sort;
301 WeightedSort *weighted_sorts;
302 int weighted_sorts_len, weighted_sorts_size;
303 char *AnimCommand;
304 Uchar showonlyiconic;
305 Uchar showonlyfocused;
306 Uchar shownoiconic;
307 Uchar showtransient;
308 rectangle managed_g; /* dimensions of managed screen portion */
309 int relief_thickness; /* relief thickness for each non-flat button */
310 #define TIPS_NEVER 0
311 #define TIPS_ALWAYS 1
312 #define TIPS_NEEDED 2
313 int tips;
314 char *tips_fontname;
315 char *tips_formatstring;
316 ftips_config *tips_conf;
318 /* X11 state */
319 Window theWindow, theFrame;
320 long sizehints_flags;
321 int gravity;
322 int fontheight, fontwidth;
323 int win_title, win_border;
324 int off_x, off_y;
325 Uchar cursor_in_window;
326 Uchar window_up;
327 Uchar can_draw; /* = 0 until we get our first ConfigureNotify */
329 /* button state */
330 int dirty_flags;
331 ManGeometry geometry, drawn_geometry;
332 Button *select_button, *focus_button, *tipped_button;
333 Uchar window_mapped, drawn_mapping;
334 ShapeState shape, drawn_shape;
335 ButtonArray buttons;
337 /* fvwm state */
338 int we_are_drawing, configures_expected;
339 Bool swallowed;
340 Window swallower_win;
341 struct
343 unsigned is_shaded : 1;
344 unsigned needs_resize_after_unshade : 1;
345 } flags;
346 } WinManager;
348 #define MANAGER_EMPTY(man) ((man)->buttons.num_windows == 0)
350 typedef struct {
351 Ulong desknum;
352 Ulong x, y; /* of the view window */
353 WinManager *managers;
354 int num_managers;
355 int transient;
356 WinData *focus_win;
357 WinData *select_win;
358 int got_window_list;
359 } GlobalData;
361 typedef struct {
362 char *name;
363 ButtonState state;
364 char *forecolor[2]; /* 0 is mono, 1 is color */
365 char *backcolor[2]; /* 0 is mono, 1 is color */
366 } ContextDefaults;
369 extern char *contextNames[NUM_CONTEXTS];
371 extern GlobalData globals;
372 extern int fvwm_fd[2];
373 extern int x_fd;
374 extern Display *theDisplay;
375 extern char *MyName;
376 extern char *Module;
377 extern int ModuleLen;
378 extern ContextDefaults contextDefaults[];
379 extern int mods_unused;
381 extern void ReadFvwmPipe(void);
382 extern void Free (void *p);
383 extern void ShutMeDown (int flag) __attribute__ ((__noreturn__));
384 extern RETSIGTYPE DeadPipe (int nothing);
385 extern char *copy_string (char **target, const char *src);
387 extern void init_globals (void);
388 extern int allocate_managers (int num);
389 extern int expand_weighted_sorts (void);
391 extern WinData *new_windata (void);
392 extern void free_windata (WinData *p);
393 extern int check_win_complete (WinData *p);
394 int check_resolution(WinManager *man, WinData *win);
395 extern WinManager *figure_win_manager (WinData *win, Uchar mask);
396 extern void init_winlists (void);
397 extern void delete_win_hashtab (WinData *win);
398 extern void insert_win_hashtab (WinData *win);
399 extern WinData *find_win_hashtab (Ulong id);
400 extern void walk_hashtab (void (*func)(void *));
401 extern int accumulate_walk_hashtab (int (*func)(void *));
402 extern void print_stringlist (StringList *list);
403 extern void add_to_stringlist (StringList *list, char *s);
404 extern void update_window_stuff (WinManager *man);
405 extern void print_managers (void);
407 extern WinManager *find_windows_manager (Window win);
408 extern int win_in_viewport (WinData *win);
409 extern WinData *id_to_win(Ulong id);
411 #endif /* IN_FVWMICONMAN_H */