2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* Note: focus_policy.[ch] is meant to manage structures of type focus_policy_t
18 * only. No code dealing with *any* external data types belongs in here! Put
19 * it in focus.[ch] instead. */
21 /* ---------------------------- included header files ---------------------- */
26 #include "focus_policy.h"
28 /* ---------------------------- local definitions -------------------------- */
30 /* ---------------------------- local macros ------------------------------- */
32 /* ---------------------------- imports ------------------------------------ */
34 /* ---------------------------- included code files ------------------------ */
36 /* ---------------------------- local types -------------------------------- */
38 /* ---------------------------- forward declarations ----------------------- */
40 /* ---------------------------- local variables ---------------------------- */
42 /* ---------------------------- exported variables (globals) --------------- */
44 /* ---------------------------- local functions ---------------------------- */
46 /* ---------------------------- interface functions ------------------------ */
48 /* Initialise focus policy to the system defaults */
49 void fpol_init_default_fp(focus_policy_t
*fp
)
51 memset(fp
, 0, sizeof(focus_policy_t
));
52 FPS_FOCUS_ENTER(*fp
, DEF_FP_FOCUS_ENTER
);
53 FPS_UNFOCUS_LEAVE(*fp
, DEF_FP_UNFOCUS_LEAVE
);
54 FPS_FOCUS_CLICK_CLIENT(*fp
, DEF_FP_FOCUS_CLICK_CLIENT
);
55 FPS_FOCUS_CLICK_DECOR(*fp
, DEF_FP_FOCUS_CLICK_DECOR
);
56 FPS_FOCUS_BY_PROGRAM(*fp
, DEF_FP_FOCUS_BY_PROGRAM
);
57 FPS_FOCUS_BY_FUNCTION(*fp
, DEF_FP_FOCUS_BY_FUNCTION
);
58 FPS_WARP_POINTER_ON_FOCUS_FUNC(*fp
, DEF_FP_WARP_POINTER_ON_FOCUS_FUNC
);
59 FPS_LENIENT(*fp
, DEF_FP_LENIENT
);
60 FPS_RAISE_FOCUSED_CLIENT_CLICK(*fp
, DEF_FP_RAISE_FOCUSED_CLIENT_CLICK
);
61 FPS_RAISE_UNFOCUSED_CLIENT_CLICK(
62 *fp
, DEF_FP_RAISE_UNFOCUSED_CLIENT_CLICK
);
63 FPS_RAISE_FOCUSED_DECOR_CLICK(
64 *fp
, DEF_FP_RAISE_FOCUSED_DECOR_CLICK
);
65 FPS_RAISE_UNFOCUSED_DECOR_CLICK(
66 *fp
, DEF_FP_RAISE_UNFOCUSED_DECOR_CLICK
);
67 FPS_RAISE_FOCUSED_ICON_CLICK(
68 *fp
, DEF_FP_RAISE_FOCUSED_ICON_CLICK
);
69 FPS_RAISE_UNFOCUSED_ICON_CLICK(
70 *fp
, DEF_FP_RAISE_UNFOCUSED_ICON_CLICK
);
71 FPS_MOUSE_BUTTONS(*fp
, DEF_FP_MOUSE_BUTTONS
);
72 FPS_MODIFIERS(*fp
, DEF_FP_MODIFIERS
);
73 FPS_PASS_FOCUS_CLICK(*fp
, DEF_FP_PASS_FOCUS_CLICK
);
74 FPS_PASS_RAISE_CLICK(*fp
, DEF_FP_PASS_RAISE_CLICK
);
75 FPS_IGNORE_FOCUS_CLICK_MOTION(*fp
, DEF_FP_IGNORE_FOCUS_CLICK_MOTION
);
76 FPS_IGNORE_RAISE_CLICK_MOTION(*fp
, DEF_FP_IGNORE_RAISE_CLICK_MOTION
);
77 FPS_ALLOW_FUNC_FOCUS_CLICK(*fp
, DEF_FP_ALLOW_FUNC_FOCUS_CLICK
);
78 FPS_ALLOW_FUNC_RAISE_CLICK(*fp
, DEF_FP_ALLOW_FUNC_RAISE_CLICK
);
79 FPS_GRAB_FOCUS(*fp
, DEF_FP_GRAB_FOCUS
);
80 FPS_GRAB_FOCUS_TRANSIENT(*fp
, DEF_FP_GRAB_FOCUS_TRANSIENT
);
81 FPS_OVERRIDE_GRAB_FOCUS(*fp
, DEF_FP_OVERRIDE_GRAB_FOCUS
);
82 FPS_RELEASE_FOCUS(*fp
, DEF_FP_RELEASE_FOCUS
);
83 FPS_RELEASE_FOCUS_TRANSIENT(*fp
, DEF_FP_RELEASE_FOCUS_TRANSIENT
);
84 FPS_OVERRIDE_RELEASE_FOCUS(*fp
, DEF_FP_OVERRIDE_RELEASE_FOCUS
);
85 FPS_SORT_WINDOWLIST_BY(*fp
, DEF_FP_SORT_WINDOWLIST_BY
);
90 int fpol_query_allow_set_focus(
91 focus_policy_t
*fpol
, fpol_set_focus_by_t set_by_mode
)
95 case FOCUS_SET_BY_ENTER
:
96 return FP_DO_FOCUS_ENTER(*fpol
);
97 case FOCUS_SET_BY_CLICK_CLIENT
:
98 return FP_DO_FOCUS_CLICK_CLIENT(*fpol
);
99 case FOCUS_SET_BY_CLICK_DECOR
:
100 return FP_DO_FOCUS_CLICK_DECOR(*fpol
);
101 case FOCUS_SET_BY_CLICK_ICON
:
102 return FP_DO_FOCUS_CLICK_ICON(*fpol
);
103 case FOCUS_SET_BY_PROGRAM
:
104 return FP_DO_FOCUS_BY_PROGRAM(*fpol
);
105 case FOCUS_SET_BY_FUNCTION
:
106 return FP_DO_FOCUS_BY_FUNCTION(*fpol
);
107 case FOCUS_SET_FORCE
:
114 int fpol_query_allow_user_focus(
115 focus_policy_t
*fpol
)
119 flag
|= FP_DO_FOCUS_ENTER(*fpol
);
120 flag
|= FP_DO_FOCUS_CLICK_CLIENT(*fpol
);
121 flag
|= FP_DO_FOCUS_CLICK_DECOR(*fpol
);
122 flag
|= FP_DO_FOCUS_BY_FUNCTION(*fpol
);
127 int fpol_is_policy_changed(
128 focus_policy_t
*fpol
)
130 if (FP_DO_FOCUS_ENTER(*fpol
))
134 if (FP_DO_UNFOCUS_LEAVE(*fpol
))
138 if (FP_DO_FOCUS_CLICK_CLIENT(*fpol
))
142 if (FP_DO_FOCUS_CLICK_DECOR(*fpol
))
146 if (FP_DO_FOCUS_BY_PROGRAM(*fpol
))
150 if (FP_DO_FOCUS_BY_FUNCTION(*fpol
))
154 if (FP_IS_LENIENT(*fpol
))
158 if (FP_DO_RAISE_FOCUSED_CLIENT_CLICK(*fpol
))
162 if (FP_DO_RAISE_UNFOCUSED_CLIENT_CLICK(*fpol
))
166 if (FP_DO_RAISE_FOCUSED_DECOR_CLICK(*fpol
))
170 if (FP_DO_RAISE_UNFOCUSED_DECOR_CLICK(*fpol
))
174 if (FP_USE_MOUSE_BUTTONS(*fpol
))
178 if (FP_USE_MODIFIERS(*fpol
))