Fix CursorMove command to correctly honour EdgeScroll settings.
[fvwm.git] / modules / FvwmIconMan / FvwmIconMan.h
blobe636b43a95000dc5249910bede7c88d2b8c804d8
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 #define WINDATA_ICONIFIED(win) ((win)->iconified)
208 typedef struct button {
209 int index; /* index into button array */
210 int x, y, w, h; /* current coords of button */
211 struct {
212 int dirty_flags;
213 FvwmPicture pic;
214 WinData *win;
215 char *display_string;
216 int x, y, w, h;
217 Uchar iconified, state;
218 int ex, ey, ew, eh; /* expose damage relatively the main win */
219 } drawn_state;
220 } Button;
222 typedef struct button_array {
223 int dirty_flags;
224 int num_buttons, drawn_num_buttons; /* size of buttons array */
225 int num_windows, drawn_num_windows; /* number of windows with buttons */
226 Button **buttons;
227 } ButtonArray;
229 typedef enum {
230 GROW_HORIZ = 1,
231 GROW_VERT = 2,
232 GROW_UP = 4,
233 GROW_DOWN = 8,
234 GROW_LEFT = 16,
235 GROW_RIGHT = 32,
236 GROW_FIXED = 64,
237 } GrowDirection;
239 typedef struct {
240 /* Things which we can change go in here.
241 * Things like border width go in WinManager */
242 int x, y, width, height;
243 int gravity_x, gravity_y; /* anchor point for window's gravity */
244 unsigned int rows, cols;
245 int boxheight, boxwidth;
246 GrowDirection dir;
247 } ManGeometry;
249 typedef struct {
250 int num_rects;
251 XRectangle rects[2];
252 } ShapeState;
254 typedef enum {
255 SortNone, /* no sorting */
256 SortId, /* sort by window id */
257 SortName, /* case insensitive name sorting */
258 SortNameCase, /* case sensitive name sorting */
259 SortWeighted, /* custom sort order */
260 } SortType;
262 typedef struct {
263 char *resname;
264 char *classname;
265 char *titlename;
266 char *iconname;
267 int weight;
268 } WeightedSort;
270 typedef struct win_manager {
271 unsigned int magic;
272 int index;
274 /* .fvwm2rc options or things set as a result of options */
275 Resolution res;
276 Reverse rev;
277 Pixel backcolor[NUM_CONTEXTS], forecolor[NUM_CONTEXTS];
278 Pixel hicolor[NUM_CONTEXTS], shadowcolor[NUM_CONTEXTS];
279 GC hiContext[NUM_CONTEXTS], backContext[NUM_CONTEXTS],
280 reliefContext[NUM_CONTEXTS];
281 GC shadowContext[NUM_CONTEXTS], flatContext[NUM_CONTEXTS];
282 FlocaleFont *FButtonFont;
283 int draw_icons;
284 int shaped;
285 StringList show;
286 StringList dontshow;
287 Binding *bindings[NUM_ACTIONS];
288 char *fontname;
289 int colorsets[NUM_CONTEXTS];
290 Pixmap pixmap[NUM_CONTEXTS];
291 char *backColorName[NUM_CONTEXTS];
292 char *foreColorName[NUM_CONTEXTS];
293 ButtonState buttonState[NUM_CONTEXTS];
294 char *geometry_str, *button_geometry_str;
295 int max_button_width;
296 int max_button_width_columns;
297 char *titlename, *iconname;
298 char *formatstring;
299 NameType format_depend;
300 Uchar followFocus;
301 Uchar usewinlist;
302 SortType sort;
303 WeightedSort *weighted_sorts;
304 int weighted_sorts_len, weighted_sorts_size;
305 char *AnimCommand;
306 Uchar showonlyiconic;
307 Uchar showonlyfocused;
308 Uchar shownoiconic;
309 Uchar showtransient;
310 rectangle managed_g; /* dimensions of managed screen portion */
311 int relief_thickness; /* relief thickness for each non-flat button */
312 #define TIPS_NEVER 0
313 #define TIPS_ALWAYS 1
314 #define TIPS_NEEDED 2
315 int tips;
316 char *tips_fontname;
317 char *tips_formatstring;
318 ftips_config *tips_conf;
320 /* X11 state */
321 Window theWindow, theFrame;
322 long sizehints_flags;
323 int gravity;
324 int fontheight, fontwidth;
325 int win_title, win_border;
326 int off_x, off_y;
327 Uchar cursor_in_window;
328 Uchar window_up;
329 Uchar can_draw; /* = 0 until we get our first ConfigureNotify */
331 /* button state */
332 int dirty_flags;
333 ManGeometry geometry, drawn_geometry;
334 Button *select_button, *focus_button, *tipped_button;
335 Uchar window_mapped, drawn_mapping;
336 ShapeState shape, drawn_shape;
337 ButtonArray buttons;
339 /* fvwm state */
340 int we_are_drawing, configures_expected;
341 Bool swallowed;
342 Window swallower_win;
343 struct
345 unsigned is_shaded : 1;
346 unsigned needs_resize_after_unshade : 1;
347 } flags;
348 } WinManager;
350 #define MANAGER_EMPTY(man) ((man)->buttons.num_windows == 0)
352 typedef struct {
353 Ulong desknum;
354 Ulong x, y; /* of the view window */
355 WinManager *managers;
356 int num_managers;
357 int transient;
358 WinData *focus_win;
359 WinData *select_win;
360 int got_window_list;
361 } GlobalData;
363 typedef struct {
364 char *name;
365 ButtonState state;
366 char *forecolor[2]; /* 0 is mono, 1 is color */
367 char *backcolor[2]; /* 0 is mono, 1 is color */
368 } ContextDefaults;
371 extern char *contextNames[NUM_CONTEXTS];
373 extern GlobalData globals;
374 extern int fvwm_fd[2];
375 extern int x_fd;
376 extern Display *theDisplay;
377 extern char *MyName;
378 extern char *Module;
379 extern int ModuleLen;
380 extern ContextDefaults contextDefaults[];
381 extern int mods_unused;
383 extern void ReadFvwmPipe(void);
384 extern void Free (void *p);
385 extern void ShutMeDown (int flag) __attribute__ ((__noreturn__));
386 extern RETSIGTYPE DeadPipe (int nothing);
387 extern char *copy_string (char **target, const char *src);
389 extern void init_globals (void);
390 extern int allocate_managers (int num);
391 extern int expand_weighted_sorts (void);
393 extern WinData *new_windata (void);
394 extern void free_windata (WinData *p);
395 extern int check_win_complete (WinData *p);
396 int check_resolution(WinManager *man, WinData *win);
397 extern WinManager *figure_win_manager (WinData *win, Uchar mask);
398 extern void init_winlists (void);
399 extern void delete_win_hashtab (WinData *win);
400 extern void insert_win_hashtab (WinData *win);
401 extern WinData *find_win_hashtab (Ulong id);
402 extern void walk_hashtab (void (*func)(void *));
403 extern int accumulate_walk_hashtab (int (*func)(void *));
404 extern void print_stringlist (StringList *list);
405 extern void add_to_stringlist (StringList *list, char *s);
406 extern void update_window_stuff (WinManager *man);
407 extern void print_managers (void);
409 extern WinManager *find_windows_manager (Window win);
410 extern int win_in_viewport (WinData *win);
411 extern WinData *id_to_win(Ulong id);
413 #endif /* IN_FVWMICONMAN_H */