3 /* local subsystem functions */
4 static Eina_Bool _e_focus_raise_timer(void *data);
6 /* local subsystem globals */
8 /* externally accessible functions */
16 e_focus_shutdown(void)
22 e_focus_idler_before(void)
28 e_focus_event_mouse_in(E_Border *bd)
30 if ((e_config->focus_policy == E_FOCUS_MOUSE) ||
31 (e_config->focus_policy == E_FOCUS_SLOPPY))
33 e_border_focus_set(bd, 1, 1);
35 if (bd->raise_timer) ecore_timer_del(bd->raise_timer);
36 bd->raise_timer = NULL;
37 if (e_config->use_auto_raise)
39 if (e_config->auto_raise_delay == 0.0)
41 if (!bd->lock_user_stacking)
43 if (e_config->border_raise_on_focus)
48 bd->raise_timer = ecore_timer_add(e_config->auto_raise_delay, _e_focus_raise_timer, bd);
53 e_focus_event_mouse_out(E_Border *bd)
55 if (e_config->focus_policy == E_FOCUS_MOUSE)
57 /* FIXME: this is such a hack. its a big hack around x's async events
58 * as we dont know always exactly what action causes what event
59 * so by waiting more than 0.2 secs before reverting focus to nothing
60 * since we entered root, we are ignoring mouse in's on the root
61 * container for a bit after the mosue may have entered it
63 if ((ecore_loop_time_get() - e_grabinput_last_focus_time_get()) > 0.2)
65 if (!bd->lock_focus_in)
68 e_border_focus_set(bd, 0, 1);
74 ecore_timer_del(bd->raise_timer);
75 bd->raise_timer = NULL;
80 e_focus_event_mouse_down(E_Border *bd)
82 if (e_config->focus_policy == E_FOCUS_CLICK)
84 e_border_focus_set(bd, 1, 1);
86 if (!bd->lock_user_stacking)
88 if (e_config->border_raise_on_focus)
92 else if (e_config->always_click_to_raise)
94 if (!bd->lock_user_stacking)
96 if (e_config->border_raise_on_focus)
100 else if (e_config->always_click_to_focus)
102 e_border_focus_set(bd, 1, 1);
107 e_focus_event_mouse_up(E_Border *bd __UNUSED__)
112 e_focus_event_focus_in(E_Border *bd)
114 if ((e_config->focus_policy == E_FOCUS_CLICK) &&
115 (!e_config->always_click_to_raise) &&
116 (!e_config->always_click_to_focus))
118 if (!bd->button_grabbed) return;
119 e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
120 e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
121 ecore_x_window_button_ungrab(bd->win, 1, 0, 1);
122 ecore_x_window_button_ungrab(bd->win, 2, 0, 1);
123 ecore_x_window_button_ungrab(bd->win, 3, 0, 1);
124 e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
125 e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
126 bd->button_grabbed = 0;
131 e_focus_event_focus_out(E_Border *bd)
133 if ((e_config->focus_policy == E_FOCUS_CLICK) &&
134 (!e_config->always_click_to_raise) &&
135 (!e_config->always_click_to_focus))
137 if (bd->button_grabbed) return;
138 ecore_x_window_button_grab(bd->win, 1,
139 ECORE_X_EVENT_MASK_MOUSE_DOWN |
140 ECORE_X_EVENT_MASK_MOUSE_UP |
141 ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
142 ecore_x_window_button_grab(bd->win, 2,
143 ECORE_X_EVENT_MASK_MOUSE_DOWN |
144 ECORE_X_EVENT_MASK_MOUSE_UP |
145 ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
146 ecore_x_window_button_grab(bd->win, 3,
147 ECORE_X_EVENT_MASK_MOUSE_DOWN |
148 ECORE_X_EVENT_MASK_MOUSE_UP |
149 ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
150 bd->button_grabbed = 1;
155 e_focus_setup(E_Border *bd)
157 if ((e_config->focus_policy == E_FOCUS_CLICK) ||
158 (e_config->always_click_to_raise) ||
159 (e_config->always_click_to_focus))
161 if (bd->button_grabbed) return;
162 ecore_x_window_button_grab(bd->win, 1,
163 ECORE_X_EVENT_MASK_MOUSE_DOWN |
164 ECORE_X_EVENT_MASK_MOUSE_UP |
165 ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
166 ecore_x_window_button_grab(bd->win, 2,
167 ECORE_X_EVENT_MASK_MOUSE_DOWN |
168 ECORE_X_EVENT_MASK_MOUSE_UP |
169 ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
170 ecore_x_window_button_grab(bd->win, 3,
171 ECORE_X_EVENT_MASK_MOUSE_DOWN |
172 ECORE_X_EVENT_MASK_MOUSE_UP |
173 ECORE_X_EVENT_MASK_MOUSE_MOVE, 0, 1);
174 bd->button_grabbed = 1;
179 e_focus_setdown(E_Border *bd)
181 if (!bd->button_grabbed) return;
182 e_bindings_mouse_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
183 e_bindings_wheel_ungrab(E_BINDING_CONTEXT_WINDOW, bd->win);
184 ecore_x_window_button_ungrab(bd->win, 1, 0, 1);
185 ecore_x_window_button_ungrab(bd->win, 2, 0, 1);
186 ecore_x_window_button_ungrab(bd->win, 3, 0, 1);
187 e_bindings_mouse_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
188 e_bindings_wheel_grab(E_BINDING_CONTEXT_WINDOW, bd->win);
189 bd->button_grabbed = 0;
192 /* local subsystem functions */
194 _e_focus_raise_timer(void *data)
199 if (!bd->lock_user_stacking) e_border_raise(bd);
200 bd->raise_timer = NULL;
201 return ECORE_CALLBACK_CANCEL;