1 /* -*-c-*- */
2 /* This module is based on Twm, but has been siginificantly modified
3  * by Rob Nation */
4 /*
5  *       Copyright 1988 by Evans & Sutherland Computer Corporation,
6  *                          Salt Lake City, Utah
7  *  Portions Copyright 1989 by the Massachusetts Institute of Technology
8  *                        Cambridge, Massachusetts
9  *
10  *                           All Rights Reserved
11  *
12  *    Permission to use, copy, modify, and distribute this software and
13  *    its documentation  for  any  purpose  and  without  fee is hereby
14  *    granted, provided that the above copyright notice appear  in  all
15  *    copies and that both  that  copyright  notice  and  this  permis-
16  *    sion  notice appear in supporting  documentation,  and  that  the
17  *    names of Evans & Sutherland and M.I.T. not be used in advertising
18  *    in publicity pertaining to distribution of the  software  without
19  *    specific, written prior permission.
20  *
21  *    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD
22  *    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-
23  *    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR
24  *    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-
25  *    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA
26  *    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27  *    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE
28  *    OR PERFORMANCE OF THIS SOFTWARE.
29  */
30 
31 #ifndef FVWM_H
32 #define FVWM_H
33 
34 /* ---------------------------- included header files ---------------------- */
35 
36 #include "libs/fvwm_x11.h"
37 #include "libs/PictureBase.h"
38 #include "libs/FRender.h"
39 #include "libs/Flocale.h"
40 #include "libs/fvwmrect.h"
41 #include "libs/FScreen.h"
42 #include "window_flags.h"
43 #include "condrc.h"
44 
45 /* ---------------------------- global definitions ------------------------- */
46 
47 #ifndef WithdrawnState
48 #define WithdrawnState 0
49 #endif
50 
51 /* ---------------------------- global macros ------------------------------ */
52 
53 /*
54  * Fvwm trivia: There were 97 commands in the fvwm command table
55  * when the F_CMD_ARGS macro was written.
56  * dje 12/19/98.
57  */
58 
59 /* Macro for args passed to fvwm commands... */
60 #define F_CMD_ARGS \
61 	cond_rc_t *cond_rc, const exec_context_t *exc, char *action
62 #define F_PASS_ARGS cond_rc, exc, action
63 #define FUNC_FLAGS_TYPE unsigned char
64 
65 /* access macros */
66 #define FW_W_FRAME(fw)        ((fw)->wins.frame)
67 #define FW_W_PARENT(fw)       ((fw)->wins.parent)
68 #define FW_W_CLIENT(fw)       ((fw)->wins.client)
69 #define FW_W(fw)              FW_W_CLIENT(fw)
70 #define FW_W_TITLE(fw)        ((fw)->wins.title)
71 #define FW_W_BUTTON(fw,i)     ((fw)->wins.button_w[(i)])
72 #define FW_W_SIDE(fw,i)       ((fw)->wins.sides[(i)])
73 #define FW_W_CORNER(fw,i)     ((fw)->wins.corners[(i)])
74 #define FW_W_ICON_TITLE(fw)   ((fw)->wins.icon_title_w)
75 #define FW_W_ICON_PIXMAP(fw)  ((fw)->wins.icon_pixmap_w)
76 #define FW_W_TRANSIENTFOR(fw) ((fw)->wins.transientfor)
77 
78 /* ---------------------------- forward declarations ----------------------- */
79 
80 /* definition in screen.h */
81 struct FvwmDecor;
82 
83 /* ---------------------------- type definitions --------------------------- */
84 
85 /* This structure carries information about the initial window state and
86  * placement.  This information is gathered at various places: the (re)capture
87  * code, AddToWindow(), HandleMapRequestRaised(), ewmh_events.c and others.
88  *
89  * initial_state
90  *   The initial window state.  By default it carries the value DontCareState.
91  *   Other states can be set if
92  *    - an icon is recaptured or restarted with session management
93  *    - the StartIconic style is set
94  *    - GNOME, EWMH, foobar hints demand that the icon starts iconic
95  *   The final value is calculated in HandleMapRequestRaised().
96  *
97  * do_override_ppos
98  *   This flag is used in PlaceWindow().  If it is set, the position requested
99  *   by the program is ignored unconditionally.  This is used during the
100  *   initial capture and later recapture operations.
101  *
102  * is_iconified_by_parent
103  *   Preserves the information if the window is a transient window that was
104  *   iconified along with its transientfor window.  Set when the window is
105  *   recaptured and used in HandleMapRequestRaised() to set the according
106  *   window state flag.  Deleted afterwards.
107  *
108  * is_menu
109  *   Set in menus.c or in the recapture code if the new window is a tear off
110  *   menu.  Such windows get special treatment in AddWindow() and events.c.
111  *
112  * is_recapture
113  *   Set for the initial capture and later recaptures.
114  *
115  * default_icon_x/y
116  *   The icon position that was requested by the application in the icon
117  *   position hint.  May be overridden by a style (0/0 then).  Set in
118  *   HandleMapRequestRaised() and used in the icon placement code.
119  *
120  * initial_icon_x/y
121  *   The icon position that is forced during a restart with SM.  If set it
122  *   overrides all other methods of icon placement.  Set by session.c and used
123  *   in the icon placement code.
124  *
125  * use_initial_icon_xy
126  *   If set, the initial_icon_x/y values are used.  Other wise they are
127  *   ignored.
128  */
129 typedef struct
130 {
131 	long initial_state;
132 	struct
133 	{
134 		unsigned do_override_ppos : 1;
135 		unsigned is_iconified_by_parent : 1;
136 		unsigned is_menu : 1;
137 		unsigned is_recapture : 1;
138 		unsigned use_initial_icon_xy : 1;
139 	} flags;
140 	int initial_icon_x;
141 	int initial_icon_y;
142 	int default_icon_x;
143 	int default_icon_y;
144 } initial_window_options_t;
145 
146 /*
147   For 1 style statement, there can be any number of IconBoxes.
148   The name list points at the first one in the chain.
149 */
150 typedef struct icon_boxes_struct
151 {
152 	struct icon_boxes_struct *next;       /* next icon_boxes or zero */
153 	unsigned int use_count;
154 	int IconBox[4];                       /* x/y x/y for iconbox */
155 	char	*IconScreen;                       /* Xinerama screen */
156 	short IconGrid[2];                    /* x incr, y incr */
157 	char IconSign[4];                     /* because of -0, need to save */
158 	unsigned is_orphan : 1;
159 	unsigned IconFlags : 3;               /* some bits */
160 	/* IconFill only takes 3 bits.  Defaults are top, left, vert co-ord
161 	 * first eg: t l = 0,0,0; l t = 0,0,1; b r = 1,1,0 */
162 #define ICONFILLBOT (1<<0)
163 #define ICONFILLRGT (1<<1)
164 #define ICONFILLHRZ (1<<2)
165 } icon_boxes;
166 
167 typedef struct
168 {
169 	Pixel fore;
170 	Pixel back;
171 } ColorPair;
172 
173 typedef struct
174 {
175 	Pixel fore;
176 	Pixel back;
177 	Pixel hilight;
178 	Pixel shadow;
179 } color_quad;
180 
181 typedef struct
182 {
183 	int left;
184 	int right;
185 	int top;
186 	int bottom;
187 } ewmh_strut;
188 
189 typedef struct
190 {
191 	/* common flags (former flags in bits 0-12) */
192 	unsigned is_sticky_across_pages : 1;
193 	unsigned is_sticky_across_desks : 1;
194 	unsigned has_icon_font : 1;
195 	unsigned has_no_border : 1;
196 	unsigned has_window_font : 1;
197 	unsigned title_dir : 2;
198 	unsigned user_states : 32;
199 	/* static flags that do not change dynamically after the window has
200 	 * been created */
201 	struct
202 	{
203 		unsigned do_circulate_skip : 1;
204 		unsigned do_circulate_skip_icon : 1;
205 		unsigned do_circulate_skip_shaded : 1;
206 		unsigned do_ewmh_donate_icon : 1;
207 		unsigned do_ewmh_donate_mini_icon : 1;
208 		unsigned do_ewmh_ignore_state_hints : 1;
209 		unsigned do_ewmh_ignore_strut_hints : 1;
210 		unsigned do_ewmh_mini_icon_override : 1;
211 		unsigned do_ewmh_use_stacking_hints : 1;
212 		unsigned do_ewmh_ignore_window_type : 1;
213 		unsigned do_iconify_window_groups : 1;
214 		unsigned do_ignore_icon_boxes : 1;
215 		unsigned do_ignore_restack : 1;
216 		unsigned do_use_window_group_hint : 1;
217 		unsigned do_lower_transient : 1;
218 		unsigned do_not_show_on_map : 1;
219 		unsigned do_raise_transient : 1;
220 		unsigned do_resize_opaque : 1;
221 		unsigned do_shrink_windowshade : 1;
222 		unsigned do_stack_transient_parent : 1;
223 		unsigned do_window_list_skip : 1;
224 		unsigned ewmh_maximize_mode : 2; /* see ewmh.h */
225 		unsigned has_depressable_border : 1;
226 		unsigned has_mwm_border : 1;
227 		unsigned has_mwm_buttons : 1;
228 		unsigned has_mwm_override : 1;
229 		unsigned has_no_icon_title : 1;
230 		unsigned has_override_size : 1;
231 		unsigned has_stippled_title : 1;
232 		unsigned has_stippled_icon_title : 1;
233 		/* default has to be 0, therefore no_, not in macros */
234 		unsigned has_no_sticky_stippled_title : 1;
235 		unsigned has_no_sticky_stippled_icon_title : 1;
236 		unsigned icon_override : 2;
237 #define NO_ACTIVE_ICON_OVERRIDE 0
238 #define ICON_OVERRIDE           1
239 #define NO_ICON_OVERRIDE        2
240 #define ICON_OVERRIDE_MASK    0x3
241 		unsigned is_bottom_title_rotated : 1;
242 		unsigned is_fixed : 1;
243 		unsigned is_fixed_ppos : 1;
244 		unsigned is_uniconifiable : 1;
245 		unsigned is_unmaximizable : 1;
246 		unsigned is_unclosable : 1;
247 		unsigned is_maximize_fixed_size_disallowed : 1;
248 		unsigned is_icon_sticky_across_pages : 1;
249 		unsigned is_icon_sticky_across_desks : 1;
250 		unsigned is_icon_suppressed : 1;
251 		unsigned is_left_title_rotated_cw : 1; /* cw = clock wise */
252 		unsigned is_lenient : 1;
253 		unsigned is_size_fixed : 1;
254 		unsigned is_psize_fixed : 1;
255 		unsigned is_right_title_rotated_cw : 1;
256 		unsigned is_top_title_rotated : 1;
257 		unsigned use_icon_position_hint : 1;
258 		unsigned use_indexed_window_name : 1;
259 		unsigned use_indexed_icon_name : 1;
260 #define WINDOWSHADE_LAZY          0
261 #define WINDOWSHADE_ALWAYS_LAZY   1
262 #define WINDOWSHADE_BUSY          2
263 #define WINDOWSHADE_LAZY_MASK   0x3
264 		unsigned windowshade_laziness : 2;
265 		unsigned use_title_decor_rotation : 1;
266 		focus_policy_t focus_policy;
267 	} s;
268 } common_flags_t;
269 
270 typedef struct
271 {
272 	common_flags_t common;
273 #define CR_MOTION_METHOD_AUTO        0
274 #define CR_MOTION_METHOD_USE_GRAV    1
275 #define CR_MOTION_METHOD_STATIC_GRAV 2
276 #define CR_MOTION_METHOD_MASK      0x3
277 	unsigned cr_motion_method : 2;
278 	unsigned was_cr_motion_method_detected : 1;
279 	unsigned does_wm_delete_window : 1;
280 	unsigned does_wm_take_focus : 1;
281 	unsigned do_force_next_cr : 1;
282 	unsigned do_force_next_pn : 1;
283 	unsigned do_iconify_after_map : 1;
284 	unsigned do_disable_constrain_size_fullscreen : 1;
285 	/* Reuse this struct, don't free it, when destroying/recapturing
286 	 * window. */
287 	unsigned do_reuse_destroyed : 1;
288 	/* Does it have resize handles? */
289 	unsigned has_handles : 1;
290 	/* Icon change is pending */
291 	unsigned has_icon_changed : 1;
292 	/* Is this decorated with title */
293 	unsigned has_title : 1;
294 	/* wm_normal_hints update is pending? */
295 	unsigned has_new_wm_normal_hints : 1;
296 	/* ChangeDecor was used for window */
297 	unsigned is_decor_changed : 1;
298 	/* Sent an XUnmapWindow for iconifying, but didn't receive an
299 	 * UnmapNotify yet.*/
300 	unsigned is_iconify_pending : 1;
301 	/* window had the focus when the desk was switched. set if the window
302 	 * was mapped and got focused but the focus change was not announced
303 	 * to the modules yet. */
304 	unsigned is_focused_on_other_desk : 1;
305 	unsigned is_focus_change_broadcast_pending : 1;
306 	/* is the window fully visible */
307 	unsigned is_fully_visible : 1;
308 	/* is it an icon now? */
309 	unsigned is_iconified : 1;
310 	/* To prevent iconified transients in a parent icon from counting for
311 	 * Next */
312 	unsigned is_iconified_by_parent : 1;
313 	/* is the pointer over the icon? */
314 	unsigned is_icon_entered : 1;
315 	unsigned is_icon_font_loaded : 1;
316 	/* has the icon been moved by the user? */
317 	unsigned is_icon_moved : 1;
318 	/* is the icon window supplied by the app? */
319 	unsigned is_icon_ours : 1;
320 	/* is the icon shaped? */
321 	unsigned is_icon_shaped : 1;
322 	/* was the icon unmapped, even though the window is still iconified
323 	 * (Transients) */
324 	unsigned is_icon_unmapped : 1;
325 	/* temporary flag used in stack.c */
326 	unsigned is_in_transient_subtree : 1;
327 	/* is it mapped? */
328 	unsigned is_mapped : 1;
329 	/* Sent an XMapWindow, but didn't receive a MapNotify yet.*/
330 	unsigned is_map_pending : 1;
331 	/* is the window maximized? */
332 	unsigned is_maximized : 1;
333 	/* Set if the client changes its WM_NAME. The source of twm contains
334 	 * an explanation why we need this information. */
335 	unsigned is_name_changed : 1;
336 	/* is the window partially visible */
337 	unsigned is_partially_visible : 1;
338 	/* is the icon pixmap ours to free? */
339 	unsigned is_pixmap_ours : 1;
340 	/* fvwm places the window itself */
341 	unsigned is_placed_by_fvwm : 1;
342 	/* mark window to be destroyed after last complex func has finished. */
343 	unsigned is_scheduled_for_destroy : 1;
344 	/* mark window to be raised after function execution. */
345 	unsigned is_scheduled_for_raise : 1;
346 	unsigned is_size_inc_set : 1;
347 	unsigned is_style_deleted : 1;
348 	/* the window is a torn out fvwm menu */
349 	unsigned is_tear_off_menu : 1;
350 	/* is it a transient window? */
351 	unsigned is_transient : 1;
352 	unsigned is_window_drawn_once : 1;
353 	/* To prevent double move in MoveViewport.*/
354 	unsigned is_viewport_moved : 1;
355 	unsigned is_window_being_moved_opaque : 1;
356 	unsigned is_window_font_loaded : 1;
357 	unsigned is_window_shaded : 1;
358 	unsigned used_title_dir_for_shading : 1;
359 	unsigned shaded_dir : 3;
360 	unsigned using_default_icon_font : 1;
361 	unsigned using_default_window_font : 1;
362 #define ICON_HINT_NEVER    0
363 #define ICON_HINT_ONCE     1
364 #define ICON_HINT_MULTIPLE 2
365 	unsigned was_icon_hint_provided : 2;
366 	unsigned was_icon_name_provided : 1;
367 	unsigned was_never_drawn : 1;
368 	unsigned has_ewmh_wm_name : 1;
369 	unsigned has_ewmh_wm_icon_name : 1;
370 #define EWMH_NO_ICON     0 /* the application does not provide an ewmh icon */
371 #define EWMH_TRUE_ICON   1 /* the application does provide an ewmh icon */
372 #define EWMH_FVWM_ICON   2 /* the ewmh icon has been set by fvwm */
373 	unsigned has_ewmh_wm_icon_hint : 2;
374 	/* says if the app have an ewmh icon of acceptable size for a mini
375 	 * icon in its list of icons */
376 	unsigned has_ewmh_mini_icon : 1;
377 	unsigned has_ewmh_wm_pid : 1;
378 	/* the ewmh icon is used as icon pixmap */
379 	unsigned use_ewmh_icon : 1;
380 	unsigned is_ewmh_modal : 1;
381 	unsigned is_ewmh_fullscreen : 1;
382 #define EWMH_STATE_UNDEFINED_HINT 0
383 #define EWMH_STATE_NO_HINT        1
384 #define EWMH_STATE_HAS_HINT       2
385 	unsigned has_ewmh_init_fullscreen_state : 2;
386 	unsigned has_ewmh_init_hidden_state : 2;
387 	unsigned has_ewmh_init_maxhoriz_state : 2;
388 	unsigned has_ewmh_init_maxvert_state : 2;
389 	unsigned has_ewmh_init_modal_state : 2;
390 	unsigned has_ewmh_init_shaded_state : 2;
391 	unsigned has_ewmh_init_skip_pager_state : 2;
392 	unsigned has_ewmh_init_skip_taskbar_state : 2;
393 	unsigned has_ewmh_init_sticky_state : 2;
394 	unsigned has_ewmh_init_wm_desktop : 2;
395 } window_flags;
396 
397 
398 /* Actions allowed by modules. */
399 typedef struct action_flags
400 {
401 	unsigned is_movable : 1;
402 	unsigned is_deletable : 1;
403 	unsigned is_destroyable : 1;
404 	unsigned is_closable : 1;
405 	unsigned is_maximizable : 1;
406 	unsigned is_resizable : 1;
407 	unsigned is_iconifiable : 1;
408 } action_flags;
409 
410 
411 /* Window name data structure for window conditions: a list of lists
412    of names to match, the boolean operation on the matches being an
413    AND of ORs. */
414 struct namelist			/* matches to names in this list are ORed */
415 {
416 	char *name;
417 	struct namelist *next;
418 };
419 
420 struct name_condition		/* matches to namelists in this list are
421 				   ANDed, after possibly inverting each */
422 {
423 	Bool invert;
424 	struct namelist *namelist;
425 	struct name_condition *next;
426 };
427 
428 /* Window mask for Circulate and Direction functions */
429 typedef struct WindowConditionMask
430 {
431 	struct
432 	{
433 		unsigned do_accept_focus : 1;
434 		unsigned do_check_desk : 1;
435 		unsigned do_check_screen : 1;
436 		unsigned do_check_cond_desk : 1;
437 		unsigned do_check_desk_and_global_page : 1;
438 		unsigned do_check_desk_and_page : 1;
439 		unsigned do_check_global_page : 1;
440 		unsigned do_check_overlapped : 1;
441 		unsigned do_check_page : 1;
442 		unsigned do_not_check_screen : 1;
443 		unsigned needs_current_desk : 1;
444 		unsigned needs_current_desk_and_global_page : 1;
445 		unsigned needs_current_desk_and_page : 1;
446 		unsigned needs_current_global_page : 1;
447 		unsigned needs_current_page : 1;
448 #define NEEDS_ANY   0
449 #define NEEDS_TRUE  1
450 #define NEEDS_FALSE 2
451 		unsigned needs_focus : 2;
452 		unsigned needs_overlapped : 2;
453 		unsigned needs_pointer : 2;
454 		unsigned needs_same_layer : 1;
455 		unsigned use_circulate_hit : 1;
456 		unsigned use_circulate_hit_icon : 1;
457 		unsigned use_circulate_hit_shaded : 1;
458 		unsigned use_do_accept_focus : 1;
459 	} my_flags;
460 	window_flags flags;
461 	window_flags flag_mask;
462 	struct name_condition *name_condition;
463 	int layer;
464 	int desk;
465 	struct monitor *screen;
466 	int placed_by_button_mask;
467 	int placed_by_button_set_mask;
468 } WindowConditionMask;
469 
470 typedef struct pl_penalty_struct
471 {
472 	float normal;
473 	float ontop;
474 	float icon;
475 	float sticky;
476 	float below;
477 	float strut;
478 } pl_penalty_struct;
479 
480 typedef struct pl_percent_penalty_struct
481 {
482 	int p99;
483 	int p95;
484 	int p85;
485 	int p75;
486 } pl_percent_penalty_struct;
487 
488 /* only style.c and add_window.c are allowed to access this struct! */
489 typedef struct style_flags
490 {
491 	common_flags_t common;
492 	unsigned do_decorate_transient : 1;
493 	/* old placement flags */
494 #define PLACE_DUMB            0x0
495 #define PLACE_SMART           0x1
496 #define PLACE_CLEVER          0x2
497 #define PLACE_CLEVERNESS_MASK 0x3
498 #define PLACE_RANDOM          0x4
499 	/* new placements value, try to get a minimal backward compatibility
500 	 * with the old flags:
501 	 * Dumb+Active = Manual,
502 	 * Dumb+Random = Cascade,
503 	 * Smart+Random = TileCascade,
504 	 * Smart+Active = TileManual,
505 	 * Random+Smart+Clever = MINOVERLAP which is the original Clever
506 	 * placement code,
507 	 * Active+Smart+Clever = MINOVERLAPPERCENT which is the "new" Clever
508 	 * placement code and was the original Clever placement code. Now the
509 	 * original placement code said:
510 	 * Active/Random+Dumb+Clever = Active/Random+Dumb (with Dumb Clever is
511 	 * ignored); These represent the not use value: 0x2=Active+Dumb+Clever,
512 	 * 0x6=Random+Dumb+Clever */
513 #define PLACE_MANUAL            0x0
514 #define PLACE_TILEMANUAL        0x1
515 #define PLACE_MANUAL_B          0x2
516 #define PLACE_MINOVERLAPPERCENT 0x3
517 #define PLACE_CASCADE           0x4
518 #define PLACE_TILECASCADE       0x5
519 #define PLACE_CASCADE_B         0x6
520 #define PLACE_MINOVERLAP        0x7
521 #define PLACE_POSITION          0x8
522 #define PLACE_MASK              0xF
523 	unsigned placement_mode : 4;
524 	unsigned ewmh_placement_mode : 2; /* see ewmh.h */
525 #define WS_CR_MOTION_METHOD_AUTO CR_MOTION_METHOD_AUTO
526 #define WS_CR_MOTION_METHOD_USE_GRAV CR_MOTION_METHOD_USE_GRAV
527 #define WS_CR_MOTION_METHOD_STATIC_GRAV CR_MOTION_METHOD_STATIC_GRAV
528 #define WS_CR_MOTION_METHOD_MASK CR_MOTION_METHOD_MASK
529 	unsigned ws_cr_motion_method : 2;
530 	unsigned do_save_under : 1;
531 	unsigned do_start_iconic : 1;
532 	unsigned do_start_lowered : 1;
533  	unsigned do_start_shaded : 1;
534  	unsigned start_shaded_dir : 3;
535 	unsigned has_border_width : 1;
536 	unsigned has_color_back : 1;
537 	unsigned has_color_fore : 1;
538 	unsigned has_color_back_hi : 1;
539 	unsigned has_color_fore_hi : 1;
540 	unsigned has_decor : 1;
541 	unsigned has_edge_delay_ms_move : 1;
542 	unsigned has_edge_delay_ms_resize : 1;
543 	unsigned has_edge_resistance_move : 1;
544 	unsigned has_edge_resistance_xinerama_move : 1;
545 	unsigned has_handle_width : 1;
546 	unsigned has_icon : 1;
547 	unsigned has_icon_boxes : 1;
548 	unsigned has_icon_size_limits : 1;
549 	unsigned has_min_window_size : 1;
550 	unsigned has_max_window_size : 1;
551 	unsigned has_icon_background_padding : 1;
552 	unsigned has_icon_background_relief : 1;
553 	unsigned has_icon_title_relief : 1;
554 	unsigned has_window_shade_steps : 1;
555 	unsigned has_mini_icon : 1;
556 	unsigned has_mwm_decor : 1;
557 	unsigned has_mwm_functions : 1;
558 	unsigned has_no_handles : 1;
559 	unsigned has_no_title : 1;
560 	unsigned has_ol_decor : 1;
561 	unsigned has_snap_grid : 1;
562 	unsigned has_snap_attraction : 1;
563 #if 0
564 	unsigned has_condition_mask : 1;
565 #endif
566 	unsigned is_button_disabled : NUMBER_OF_TITLE_BUTTONS;
567 	unsigned is_unmanaged : 1;
568 #define BACKINGSTORE_DEFAULT 0
569 #define BACKINGSTORE_ON      1
570 #define BACKINGSTORE_OFF     2
571 #define BACKINGSTORE_MASK  0x3
572 	unsigned use_backing_store : 2;
573 	unsigned use_parent_relative : 1;
574 	unsigned use_colorset : 1;
575 	unsigned use_colorset_hi : 1;
576 	unsigned use_border_colorset : 1;
577 	unsigned use_border_colorset_hi : 1;
578 	unsigned use_icon_title_colorset : 1;
579 	unsigned use_icon_title_colorset_hi : 1;
580 	unsigned use_icon_background_colorset : 1;
581 	unsigned use_layer : 1;
582 	unsigned use_no_pposition : 1;
583 	unsigned use_no_usposition : 1;
584 	unsigned use_no_transient_pposition : 1;
585 	unsigned use_no_transient_usposition : 1;
586 	unsigned use_start_on_desk : 1;
587 	unsigned use_start_on_page_for_transient : 1;
588 	unsigned use_start_on_screen : 1;
589 	unsigned manual_placement_honors_starts_on_page : 1;
590 	unsigned um_placement_honors_starts_on_page : 1;
591 	unsigned capture_honors_starts_on_page : 1;
592 	unsigned recapture_honors_starts_on_page : 1;
593 	unsigned has_placement_penalty : 1;
594 	unsigned has_placement_percentage_penalty : 1;
595 	unsigned has_placement_position_string : 1;
596 	unsigned has_initial_map_command_string : 1;
597 	unsigned has_title_format_string : 1;
598 	unsigned has_icon_title_format_string : 1;
599 	unsigned initial_placement_done : 1;
600 } style_flags;
601 
602 typedef struct style_id_t
603 {
604 	char *name;
605 	XID window_id;
606 	struct
607 	{
608 		unsigned has_name:1;
609 		unsigned has_window_id:1;
610 	} flags;
611 } style_id_t;
612 
613 typedef struct snap_attraction_t
614 {
615 	/* attractiveness of window edges */
616 	int proximity;
617 	/* mode of snap attraction */
618 	int mode;
619 	/* mode flags to do bit manipulation */
620 	enum
621 	{
622 		SNAP_NONE = 0x00,
623 		SNAP_WINDOWS = 0x01,
624 		SNAP_ICONS = 0x02,
625 		SNAP_SAME = 0x04,
626 		SNAP_SCREEN = 0x08,
627 		SNAP_SCREEN_WINDOWS = 0x10,
628 		SNAP_SCREEN_ICONS = 0x20,
629 		SNAP_SCREEN_ALL = 0x40,
630 	} types;
631 } snap_attraction_t;
632 
633 /* only style.c and add_window.c are allowed to access this struct! */
634 typedef struct window_style
635 {
636 	struct window_style *next;
637 	struct window_style *prev;
638 	style_id_t id;
639 #if 0
640 	WindowConditionMask *condition_mask;
641 #endif
642 	char *icon_name;
643 	char *mini_icon_name;
644 	char *decor_name;
645 	unsigned char min_icon_width;
646 	unsigned char max_icon_width;
647 	unsigned char min_icon_height;
648 	unsigned char max_icon_height;
649 #define ICON_RESIZE_TYPE_NONE      0x0
650 #define ICON_RESIZE_TYPE_STRETCHED 0x1
651 #define ICON_RESIZE_TYPE_ADJUSTED  0x2
652 #define ICON_RESIZE_TYPE_SHRUNK    0x3
653 #define ICON_RESIZE_TYPE_MASK      0x3
654 	unsigned icon_resize_type : 2;
655 	unsigned char icon_background_padding;
656 	signed char icon_background_relief;
657 	signed char icon_title_relief;
658 	char *icon_font;
659 	char *window_font;
660 	char *fore_color_name;
661 	char *back_color_name;
662 	char *fore_color_name_hi;
663 	char *back_color_name_hi;
664 	int colorset;
665 	int colorset_hi;
666 	int border_colorset;
667 	int border_colorset_hi;
668 	int icon_title_colorset;
669 	int icon_title_colorset_hi;
670 	int icon_background_colorset;
671 	short border_width;
672 	/* resize handle width */
673 	short handle_width;
674 	int layer;
675 	int start_desk;
676 	int start_page_x;
677 	int start_page_y;
678 	char *start_screen;
679 	int min_window_width;
680 	int min_window_height;
681 	int max_window_width;
682 	int max_window_height;
683 	/* sizes are in terms of client window size hints */
684 	bool min_window_width_is_c;
685 	bool min_window_height_is_c;
686 	bool max_window_width_is_c;
687 	bool max_window_height_is_c;
688 	int shade_anim_steps;
689 #if 1 /*!!!*/
690 	snap_attraction_t snap_attraction;
691 	/* snap grid size */
692 	int snap_grid_x;
693 	int snap_grid_y;
694 	int edge_delay_ms_move;
695 	int edge_delay_ms_resize;
696 	int edge_resistance_move;
697 	int edge_resistance_xinerama_move;
698 #endif
699 	icon_boxes *icon_boxes;
700 	float norm_placement_penalty;
701 	pl_penalty_struct pl_penalty;
702 	pl_percent_penalty_struct pl_percent_penalty;
703 	char *pl_position_string;
704 	char *initial_map_command_string;
705 	char *title_format_string;
706 	char *icon_title_format_string;
707 	style_flags flags;
708 	style_flags flag_default;
709 	style_flags flag_mask;
710 	style_flags change_mask;
711 	unsigned has_style_changed : 1;
712 	unsigned has_title_format_string : 1;
713 	unsigned has_icon_title_format_string : 1;
714 } window_style;
715 
716 typedef struct window_g
717 {
718 	rectangle frame;
719 	/* absolute geometry when not maximized */
720 	rectangle normal;
721 	/* maximized window geometry */
722 	rectangle max;
723 	/* defect between maximized geometry before and after
724 	 * constraining size. */
725 	size_rect max_defect;
726 	/* original delta between normalized and maximized window,
727 	 * used to keep unmaximized window at same screen position */
728 	position max_offset;
729 } window_g;
730 
731 /* for each window that is on the display, one of these structures
732  * is allocated and linked into a list
733  */
734 typedef struct FvwmWindow
735 {
736 	/* name of the window */
737 	FlocaleNameString name;
738 	/* name of the icon */
739 	FlocaleNameString icon_name;
740 	char *visible_name;
741 	char *visible_icon_name;
742 	/* if non-null: Use this instead of any other names for matching
743 	   styles */
744 	char *style_name;
745 	int name_count;
746 	int icon_name_count;
747 	/* next fvwm window */
748 	struct FvwmWindow *next;
749 	/* prev fvwm window */
750 	struct FvwmWindow *prev;
751 	/* next (lower) fvwm window in stacking order*/
752 	struct FvwmWindow *stack_next;
753 	/* prev (higher) fvwm window in stacking order */
754 	struct FvwmWindow *stack_prev;
755 	/* border width before reparenting */
756 	struct
757 	{
758 		/* the frame window */
759 		Window frame;
760 		/* It looks like you HAVE to reparent the app window into a
761 		 * window whose size = app window, or else you can't keep xv
762 		 * and matlab happy at the same time! */
763 		Window parent;
764 		/* the child window */
765 		Window client;
766 		/* the title bar window and button windows */
767 		Window title;
768 		Window button_w[NUMBER_OF_TITLE_BUTTONS];
769 		/* sides of the border */
770 		Window sides[4];
771 		/* corner pieces */
772 		Window corners[4];
773 		/* icon title window */
774 		Window icon_title_w;
775 		/* icon picture window */
776 		Window icon_pixmap_w;
777 		Window transientfor;
778 	} wins;
779 	window_flags flags;
780 	struct
781 	{
782 		unsigned buttons_drawn : NUMBER_OF_TITLE_BUTTONS;
783 		unsigned buttons_lit : NUMBER_OF_TITLE_BUTTONS;
784 		unsigned buttons_inverted : NUMBER_OF_TITLE_BUTTONS;
785 		unsigned buttons_toggled : NUMBER_OF_TITLE_BUTTONS;
786 		unsigned parts_drawn : 12;
787 		unsigned parts_lit : 12;
788 		unsigned parts_inverted : 12;
789 	} decor_state;
790 	int nr_left_buttons;
791 	int nr_right_buttons;
792 #define BUTTON_INDEX(b) \
793 	(((b) == 0) ? (NUMBER_OF_TITLE_BUTTONS - 1) : ((b) - 1))
794 	struct FvwmDecor *decor;
795 	/* is this a shaped window */
796 	int wShaped;
797 	Pixmap title_background_pixmap;
798 
799 	/* Note: if the type of this variable is changed, do update the
800 	 * CONFIGARGSNEW macro in module_interface.c, libs/vpacket.h too! */
801 	short boundary_width;
802 	short unshaped_boundary_width;
803 	short corner_width;
804 	short visual_corner_width;
805 
806 	/* title font */
807 	FlocaleFont *title_font;
808 	/* /Y coordinate to draw the title name */
809 	short title_text_offset;
810 	short title_length;
811 	/* Note: if the type of this variable is changed, do update the
812 	 * CONFIGARGSNEW macro in module_interface.c, libs/vpacket.h and too!
813 	 */
814 	short title_thickness;
815 	rotation_t title_text_rotation;
816 	struct
817 	{
818 		/* geometry of the icon picture window */
819 		rectangle picture_w_g;
820 		/* geometry of the icon title window */
821 		rectangle title_w_g;
822 		/* width of the text in the icon title */
823 		int title_text_width;
824 	} icon_g;
825 	short icon_border_width;
826 
827 	/* Drawable depth for the icon */
828 	int iconDepth;
829 	/* pixmap for the icon */
830 	Pixmap iconPixmap;
831 	/* pixmap for the icon mask */
832 	Pixmap icon_maskPixmap;
833 	Pixmap icon_alphaPixmap;
834 	int icon_nalloc_pixels;
835 	Pixel *icon_alloc_pixels;
836 	int icon_no_limit;
837 	FlocaleFont *icon_font;
838 
839 	/* some parts of the window attributes */
840 	struct
841 	{
842 		int backing_store;
843 		int border_width;
844 		int depth;
845 		int bit_gravity;
846 		unsigned is_bit_gravity_stored : 1;
847 		Visual *visual;
848 		Colormap colormap;
849 	} attr_backup;
850 	/* normal hints */
851 	XSizeHints hints;
852 	struct
853 	{
854 		int width_inc;
855 		int height_inc;
856 	} orig_hints;
857 	/* WM hints */
858 	XWMHints *wmhints;
859 	XClassHint class;
860 	/* Tells which desktop this window is on */
861 	/* Note: if the type of this variable is changed, do update the
862 	 * CONFIGARGSNEW macro in module_interface.c, libs/vpacket.h and too!
863 	 */
864 	int Desk;
865 	/* Where (if at all) was it focused */
866 	int FocusDesk;
867 	/* Desk to deiconify to, for StubbornIcons */
868 	int DeIconifyDesk;
869 
870 	char *mini_pixmap_file;
871 	FvwmPicture *mini_icon;
872 	char *icon_bitmap_file;
873 
874 	struct window_g g;
875 	long *mwm_hints;
876 	int ol_hints;
877 	int functions;
878 	/* Colormap windows property */
879 	Window *cmap_windows;
880 	/* Should generally be 0 */
881 	int number_cmap_windows;
882 	color_quad colors;
883 	color_quad hicolors;
884 	color_quad border_colors;
885 	color_quad border_hicolors;
886 
887 	int cs;
888 	int cs_hi;
889 	int border_cs;
890 	int border_cs_hi;
891 	int icon_title_cs;
892 	int icon_title_cs_hi;
893 	int icon_background_cs;
894 
895 	unsigned long buttons;
896 	/* zero or more iconboxes */
897 	icon_boxes *IconBoxes;
898 
899 	int default_layer;
900 	/* Note: if the type of this variable is changed, do update the
901 	 * CONFIGARGSNEW macro in module_interface.c, libs/vpacket.h and too!
902 	 */
903 	int layer;
904 
905 	unsigned char min_icon_width;
906 	unsigned char max_icon_width;
907 	unsigned char min_icon_height;
908 	unsigned char max_icon_height;
909 	unsigned short icon_resize_type;
910 
911 	unsigned char icon_background_padding;
912 	char icon_background_relief;
913 	char icon_title_relief;
914 
915 	int min_window_width;
916 	int min_window_height;
917 	int max_window_width;
918 	int max_window_height;
919 	int shade_anim_steps;
920 	unsigned char grabbed_buttons;
921 #if 1 /*!!!*/
922 	snap_attraction_t snap_attraction;
923 	/* snap grid size */
924 	int snap_grid_x;
925 	int snap_grid_y;
926 	int edge_delay_ms_move;
927 	int edge_delay_ms_resize;
928 	int edge_resistance_move;
929 	int edge_resistance_xinerama_move;
930 #endif
931 
932 #define FM_NO_INPUT        0
933 #define FM_PASSIVE         1
934 #define FM_LOCALLY_ACTIVE  2
935 #define FM_GLOBALLY_ACTIVE 3
936 	unsigned char focus_model;
937 
938 	pl_penalty_struct pl_penalty;
939 	pl_percent_penalty_struct pl_percent_penalty;
940 
941 	unsigned char placed_by_button;
942 
943 #define EWMH_WINDOW_TYPE_NONE_ID      0
944 #define EWMH_WINDOW_TYPE_DESKTOP_ID   1
945 #define EWMH_WINDOW_TYPE_DIALOG_ID    2
946 #define EWMH_WINDOW_TYPE_DOCK_ID      3
947 #define EWMH_WINDOW_TYPE_MENU_ID      4
948 #define EWMH_WINDOW_TYPE_NORMAL_ID    5
949 #define EWMH_WINDOW_TYPE_TOOLBAR_ID   6
950 #define EWMH_WINDOW_TYPE_NOTIFICATION_ID 7
951 	/* Note: if the type of this variable is changed, do update the
952 	 * CONFIGARGSNEW macro in module_interface.c, libs/vpacket.h and too!
953 	 */
954 	int ewmh_window_type;
955 	/* icon geometry */
956 	rectangle ewmh_icon_geometry;
957 	/* for computing the working area */
958 	ewmh_strut strut;
959 	/* for the dynamic working area */
960 	ewmh_strut dyn_strut;
961 	/* memories for the icons we set on the */
962 	int ewmh_icon_height;
963 	/* _NET_WM_ICON */
964 	int ewmh_icon_width;
965 	int ewmh_mini_icon_height;
966 	int ewmh_mini_icon_width;
967 	/* memory for the initial _NET_WM_STATE */
968 	/* Note: if the type of this variable is changed, do update the
969 	 * CONFIGARGSNEW macro in module_interface.c, libs/vpacket.h and too!
970 	 */
971 	int ewmh_hint_layer;
972 	int ewmh_normal_layer; /* for restoring non ewmh layer */
973 	/* memory for the initial _NET_WM_STATE */
974 	unsigned long ewmh_hint_desktop;
975 
976 	/* For the purposes of restoring attributes before/after a window goes
977 	 * into fullscreen.
978 	 */
979 	struct
980 	{
981 		struct window_g g;
982 		int is_iconified;
983 		int is_shaded;
984 		int was_maximized;
985 	} fullscreen;
986 
987 	/* multi purpose scratch structure */
988 	struct
989 	{
990 		void *p;
991 		int i;
992 	} scratch;
993 
994 	struct monitor *m;
995 	struct monitor *m_prev;
996 } FvwmWindow;
997 
998 /* ---------------------------- exported variables (globals) --------------- */
999 
1000 /* ---------------------------- interface functions ------------------------ */
1001 
1002 void SetMWM_INFO(Window window);
1003 void fvmm_deinstall_signals(void);
1004 
1005 #endif /* FVWM_H */
1006