Fix move command parsing.
[fvwm.git] / fvwm / focus_policy.h
blob4092e08b1c4005ae2075fa041a80f0d4929d3901
1 /* -*-c-*- */
3 #ifndef FOCUS_POLICY_H
4 #define FOCUS_POLICY_H
6 /* Note: focus_policy.[ch] is meant to manage structures of type focus_policy_t
7 * only. No code dealing with *any* external data types belongs in here! Put
8 * it in focus.[ch] instead. */
10 /* ---------------------------- included header files ---------------------- */
12 /* ---------------------------- global definitions ------------------------- */
14 #define FPOL_ANY_MODIFIER 0xff
16 /* ---------------------------- access macros ------------------------------ */
18 #define FP_DO_RAISE_FOCUSED_CLICK(fp) \
19 ((fp).do_raise_focused_click)
20 #define FP_DO_RAISE_UNFOCUSED_CLICK(fp) \
21 ((fp).do_raise_unfocused_click)
22 #define FP_DO_FOCUS_CLICK(fp) \
23 ((fp).do_focus_click)
24 #define FP_DO_RAISE_FOCUSED_CLIENT_CLICK(fp) \
25 ((fp).do_raise_focused_click.client)
26 #define FPS_RAISE_FOCUSED_CLIENT_CLICK(fp,x) \
27 ((fp).do_raise_focused_click.client = !!(x))
28 #define FP_DO_RAISE_UNFOCUSED_CLIENT_CLICK(fp) \
29 ((fp).do_raise_unfocused_click.client)
30 #define FPS_RAISE_UNFOCUSED_CLIENT_CLICK(fp,x) \
31 ((fp).do_raise_unfocused_click.client = !!(x))
32 #define FP_DO_RAISE_FOCUSED_DECOR_CLICK(fp) \
33 ((fp).do_raise_focused_click.decor)
34 #define FPS_RAISE_FOCUSED_DECOR_CLICK(fp,x) \
35 ((fp).do_raise_focused_click.decor = !!(x))
36 #define FP_DO_RAISE_UNFOCUSED_DECOR_CLICK(fp) \
37 ((fp).do_raise_unfocused_click.decor)
38 #define FPS_RAISE_UNFOCUSED_DECOR_CLICK(fp,x) \
39 ((fp).do_raise_unfocused_click.decor = !!(x))
40 #define FP_DO_RAISE_FOCUSED_ICON_CLICK(fp) \
41 ((fp).do_raise_focused_click.icon)
42 #define FPS_RAISE_FOCUSED_ICON_CLICK(fp,x) \
43 ((fp).do_raise_focused_click.icon = !!(x))
44 #define FP_DO_RAISE_UNFOCUSED_ICON_CLICK(fp) \
45 ((fp).do_raise_unfocused_click.icon)
46 #define FPS_RAISE_UNFOCUSED_ICON_CLICK(fp,x) \
47 ((fp).do_raise_unfocused_click.icon = !!(x))
48 #define FP_DO_FOCUS_ENTER(fp) \
49 ((fp).do_focus_enter)
50 #define FPS_FOCUS_ENTER(fp,x) \
51 ((fp).do_focus_enter = !!(x))
52 #define FP_DO_UNFOCUS_LEAVE(fp) \
53 ((fp).do_unfocus_leave)
54 #define FPS_UNFOCUS_LEAVE(fp,x) \
55 ((fp).do_unfocus_leave = !!(x))
56 #define FP_DO_FOCUS_CLICK_CLIENT(fp) \
57 ((fp).do_focus_click.client)
58 #define FPS_FOCUS_CLICK_CLIENT(fp,x) \
59 ((fp).do_focus_click.client = !!(x))
60 #define FP_DO_FOCUS_CLICK_DECOR(fp) \
61 ((fp).do_focus_click.decor)
62 #define FPS_FOCUS_CLICK_DECOR(fp,x) \
63 ((fp).do_focus_click.decor = !!(x))
64 #define FP_DO_FOCUS_CLICK_ICON(fp) \
65 ((fp).do_focus_click.icon)
66 #define FPS_FOCUS_CLICK_ICON(fp,x) \
67 ((fp).do_focus_click.icon = !!(x))
68 #define FP_DO_FOCUS_BY_PROGRAM(fp) \
69 ((fp).do_focus_by_program)
70 #define FPS_FOCUS_BY_PROGRAM(fp,x) \
71 ((fp).do_focus_by_program = !!(x))
72 #define FP_DO_FOCUS_BY_FUNCTION(fp) \
73 ((fp).do_focus_by_function)
74 #define FPS_FOCUS_BY_FUNCTION(fp,x) \
75 ((fp).do_focus_by_function = !!(x))
76 #define FP_DO_WARP_POINTER_ON_FOCUS_FUNC(fp) \
77 ((fp).do_warp_pointer_on_focus_func)
78 #define FPS_WARP_POINTER_ON_FOCUS_FUNC(fp,x) \
79 ((fp).do_warp_pointer_on_focus_func = !!(x))
80 #define FP_IS_LENIENT(fp) \
81 ((fp).is_lenient)
82 #define FPS_LENIENT(fp,x) \
83 ((fp).is_lenient = !!(x))
84 #define FP_USE_MOUSE_BUTTONS(fp) \
85 ((fp).use_mouse_buttons)
86 #define FPS_MOUSE_BUTTONS(fp,x) \
87 ((fp).use_mouse_buttons = (x))
88 #define FP_USE_MODIFIERS(fp) \
89 ((fp).use_modifiers)
90 #define FPS_MODIFIERS(fp,x) \
91 ((fp).use_modifiers = (x))
92 #define FP_DO_PASS_FOCUS_CLICK(fp) \
93 ((fp).do_pass_focus_click)
94 #define FPS_PASS_FOCUS_CLICK(fp,x) \
95 ((fp).do_pass_focus_click = !!(x))
96 #define FP_DO_PASS_RAISE_CLICK(fp) \
97 ((fp).do_pass_raise_click)
98 #define FPS_PASS_RAISE_CLICK(fp,x) \
99 ((fp).do_pass_raise_click = !!(x))
100 #define FP_DO_IGNORE_FOCUS_CLICK_MOTION(fp) \
101 ((fp).do_ignore_focus_click_motion)
102 #define FPS_IGNORE_FOCUS_CLICK_MOTION(fp,x) \
103 ((fp).do_ignore_focus_click_motion = !!(x))
104 #define FP_DO_IGNORE_RAISE_CLICK_MOTION(fp) \
105 ((fp).do_ignore_raise_click_motion)
106 #define FPS_IGNORE_RAISE_CLICK_MOTION(fp,x) \
107 ((fp).do_ignore_raise_click_motion = !!(x))
108 #define FP_DO_ALLOW_FUNC_FOCUS_CLICK(fp) \
109 ((fp).do_allow_func_focus_click)
110 #define FPS_ALLOW_FUNC_FOCUS_CLICK(fp,x) \
111 ((fp).do_allow_func_focus_click = !!(x))
112 #define FP_DO_ALLOW_FUNC_RAISE_CLICK(fp) \
113 ((fp).do_allow_func_raise_click)
114 #define FPS_ALLOW_FUNC_RAISE_CLICK(fp,x) \
115 ((fp).do_allow_func_raise_click = !!(x))
116 #define FP_DO_GRAB_FOCUS(fp) \
117 ((fp).do_open_grabs_focus)
118 #define FPS_GRAB_FOCUS(fp,x) \
119 ((fp).do_open_grabs_focus = !!(x))
120 #define FP_DO_GRAB_FOCUS_TRANSIENT(fp) \
121 ((fp).do_open_grabs_focus_transient)
122 #define FPS_GRAB_FOCUS_TRANSIENT(fp,x) \
123 ((fp).do_open_grabs_focus_transient = !!(x))
124 #define FP_DO_OVERRIDE_GRAB_FOCUS(fp) \
125 ((fp).do_override_grab_focus)
126 #define FPS_OVERRIDE_GRAB_FOCUS(fp,x) \
127 ((fp).do_override_grab_focus = !!(x))
128 #define FP_DO_RELEASE_FOCUS(fp) \
129 ((fp).do_close_releases_focus)
130 #define FPS_RELEASE_FOCUS(fp,x) \
131 ((fp).do_close_releases_focus = !!(x))
132 #define FP_DO_RELEASE_FOCUS_TRANSIENT(fp) \
133 ((fp).do_close_releases_focus_transient)
134 #define FPS_RELEASE_FOCUS_TRANSIENT(fp,x) \
135 ((fp).do_close_releases_focus_transient = !!(x))
136 #define FP_DO_OVERRIDE_RELEASE_FOCUS(fp) \
137 ((fp).do_override_release_focus)
138 #define FPS_OVERRIDE_RELEASE_FOCUS(fp,x) \
139 ((fp).do_override_release_focus = !!(x))
140 #define FP_DO_SORT_WINDOWLIST_BY(fp) \
141 ((fp).do_sort_windowlist_by)
142 #define FPS_SORT_WINDOWLIST_BY(fp,x) \
143 ((fp).do_sort_windowlist_by = !!(x))
145 /* ---------------------------- type definitions --------------------------- */
147 typedef enum
149 FPOL_SORT_WL_BY_FOCUS = 0,
150 FPOL_SORT_WL_BY_OPEN = 1
151 } fpol_sort_windowlist_t;
153 typedef enum
155 FOCUS_SET_BY_CLICK_CLIENT,
156 FOCUS_SET_BY_CLICK_DECOR,
157 FOCUS_SET_BY_CLICK_ICON,
158 FOCUS_SET_BY_ENTER,
159 FOCUS_SET_BY_PROGRAM,
160 FOCUS_SET_BY_FUNCTION,
161 /* used internally to restore the focus after certain actions */
162 FOCUS_SET_FORCE
163 } fpol_set_focus_by_t;
165 typedef struct
167 unsigned client : 1;
168 unsigned decor : 1;
169 unsigned icon : 1;
170 } fpol_context_t;
172 typedef struct
174 /* raising the window */
175 fpol_context_t do_raise_focused_click;
176 fpol_context_t do_raise_unfocused_click;
177 /* focus transition */
178 fpol_context_t do_focus_click;
179 unsigned do_focus_enter : 1;
180 unsigned do_unfocus_leave : 1;
181 unsigned do_focus_by_program : 1;
182 unsigned do_focus_by_function : 1;
183 unsigned do_warp_pointer_on_focus_func : 1;
184 /* application focus model */
185 unsigned is_lenient : 1;
186 /* click configuration */
187 unsigned use_mouse_buttons : NUMBER_OF_EXTENDED_MOUSE_BUTTONS;
188 unsigned use_modifiers : 8;
189 /* recycling of focus and raise clicks */
190 unsigned do_pass_focus_click : 1;
191 unsigned do_pass_raise_click : 1;
192 unsigned do_ignore_focus_click_motion : 1;
193 unsigned do_ignore_raise_click_motion : 1;
194 unsigned do_allow_func_focus_click : 1;
195 unsigned do_allow_func_raise_click : 1;
196 /* keeping track of the focus */
197 unsigned do_open_grabs_focus : 1;
198 unsigned do_open_grabs_focus_transient : 1;
199 unsigned do_override_grab_focus : 1;
200 unsigned do_close_releases_focus : 1;
201 unsigned do_close_releases_focus_transient : 1;
202 unsigned do_override_release_focus : 1;
203 unsigned do_sort_windowlist_by : 1;
204 } focus_policy_t;
206 /* ---------------------------- forward declarations ----------------------- */
208 /* ---------------------------- exported variables (globals) --------------- */
210 /* ---------------------------- interface functions ------------------------ */
212 void fpol_init_default_fp(
213 focus_policy_t *fp);
214 int fpol_query_allow_set_focus(
215 focus_policy_t *fpol, fpol_set_focus_by_t set_by_mode);
216 int fpol_query_allow_user_focus(
217 focus_policy_t *fpol);
218 int fpol_is_policy_changed(
219 focus_policy_t *fpol);
221 #endif /* FOCUS_POLICY_H */