diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index b02cd988..98d4831f 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -28,15 +28,19 @@ static bool pointer_test(swayc_t *view, void *_origin) { | |||
28 | return false; | 28 | return false; |
29 | } | 29 | } |
30 | 30 | ||
31 | void focus_pointer(void) { | 31 | swayc_t *focus_pointer(void) { |
32 | swayc_t *focused = find_container(&root_container, pointer_test, &mouse_origin); | 32 | swayc_t *focused = get_focused_container(&root_container); |
33 | if (focused) { | 33 | if (!(wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) { |
34 | sway_log(L_DEBUG, "Switching focus to %p", focused); | 34 | swayc_t *pointer = find_container(&root_container, pointer_test, &mouse_origin); |
35 | unfocus_all(&root_container); | 35 | if (pointer && focused != pointer) { |
36 | focus_view(focused); | 36 | unfocus_all(&root_container); |
37 | } else { | 37 | focus_view(pointer); |
38 | focus_view(active_workspace); | 38 | } else if (!focused){ |
39 | focus_view(active_workspace); | ||
40 | } | ||
41 | focused = pointer; | ||
39 | } | 42 | } |
43 | return focused; | ||
40 | } | 44 | } |
41 | 45 | ||
42 | static bool handle_output_created(wlc_handle output) { | 46 | static bool handle_output_created(wlc_handle output) { |
@@ -194,31 +198,16 @@ static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct w | |||
194 | if (!config->focus_follows_mouse) { | 198 | if (!config->focus_follows_mouse) { |
195 | return true; | 199 | return true; |
196 | } | 200 | } |
197 | swayc_t *focused = get_focused_container(&root_container); | 201 | focus_pointer(); |
198 | if (!(wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) { | ||
199 | swayc_t *c = find_container(&root_container, pointer_test, (void *)origin); | ||
200 | if (c && c != focused) { | ||
201 | sway_log(L_DEBUG, "Switching focus to %p", c); | ||
202 | unfocus_all(&root_container); | ||
203 | focus_view(c); | ||
204 | } | ||
205 | } | ||
206 | return true; | 202 | return true; |
207 | } | 203 | } |
208 | 204 | ||
209 | static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, | 205 | static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, |
210 | uint32_t button, enum wlc_button_state state) { | 206 | uint32_t button, enum wlc_button_state state) { |
211 | swayc_t *focused = get_focused_container(&root_container); | 207 | swayc_t *focused = get_focused_container(&root_container); |
212 | if (state == WLC_BUTTON_STATE_PRESSED | 208 | if (state == WLC_BUTTON_STATE_PRESSED) { |
213 | && !(wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) { | 209 | swayc_t *pointer = focus_pointer(); |
214 | swayc_t *c = find_container(&root_container, pointer_test, &mouse_origin); | 210 | return !(pointer && pointer != focused); |
215 | if (c && c != focused) { | ||
216 | sway_log(L_DEBUG, "Switching focus to %p", c); | ||
217 | unfocus_all(&root_container); | ||
218 | focus_view(c); | ||
219 | return false; | ||
220 | } | ||
221 | return true; | ||
222 | } | 211 | } |
223 | return true; | 212 | return true; |
224 | } | 213 | } |