diff options
-rw-r--r-- | include/sway/input/seat.h | 4 | ||||
-rw-r--r-- | include/sway/server.h | 1 | ||||
-rw-r--r-- | sway/input/seat.c | 9 | ||||
-rw-r--r-- | sway/lock.c | 30 |
4 files changed, 30 insertions, 14 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index c2041742..e3a46872 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -201,10 +201,6 @@ struct sway_workspace *seat_get_last_known_workspace(struct sway_seat *seat); | |||
201 | 201 | ||
202 | struct sway_container *seat_get_focused_container(struct sway_seat *seat); | 202 | struct sway_container *seat_get_focused_container(struct sway_seat *seat); |
203 | 203 | ||
204 | // Force focus to a particular surface that is not part of the workspace | ||
205 | // hierarchy (used for lockscreen) | ||
206 | void sway_force_focus(struct wlr_surface *surface); | ||
207 | |||
208 | /** | 204 | /** |
209 | * Return the last container to be focused for the seat (or the most recently | 205 | * Return the last container to be focused for the seat (or the most recently |
210 | * opened if no container has received focused) that is a child of the given | 206 | * opened if no container has received focused) that is a child of the given |
diff --git a/include/sway/server.h b/include/sway/server.h index 055c067d..6a5a60c8 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -96,6 +96,7 @@ struct sway_server { | |||
96 | struct wlr_session_lock_manager_v1 *manager; | 96 | struct wlr_session_lock_manager_v1 *manager; |
97 | 97 | ||
98 | struct wlr_session_lock_v1 *lock; | 98 | struct wlr_session_lock_v1 *lock; |
99 | struct wlr_surface *focused; | ||
99 | struct wl_listener lock_new_surface; | 100 | struct wl_listener lock_new_surface; |
100 | struct wl_listener lock_unlock; | 101 | struct wl_listener lock_unlock; |
101 | struct wl_listener lock_destroy; | 102 | struct wl_listener lock_destroy; |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 987e1c9f..a7408287 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -214,15 +214,6 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) { | |||
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | void sway_force_focus(struct wlr_surface *surface) { | ||
218 | struct sway_seat *seat; | ||
219 | wl_list_for_each(seat, &server.input->seats, link) { | ||
220 | seat_keyboard_notify_enter(seat, surface); | ||
221 | seat_tablet_pads_notify_enter(seat, surface); | ||
222 | sway_input_method_relay_set_focus(&seat->im_relay, surface); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | void seat_for_each_node(struct sway_seat *seat, | 217 | void seat_for_each_node(struct sway_seat *seat, |
227 | void (*f)(struct sway_node *node, void *data), void *data) { | 218 | void (*f)(struct sway_node *node, void *data), void *data) { |
228 | struct sway_seat_node *current = NULL; | 219 | struct sway_seat_node *current = NULL; |
diff --git a/sway/lock.c b/sway/lock.c index 04f80079..3c7c06cf 100644 --- a/sway/lock.c +++ b/sway/lock.c | |||
@@ -17,9 +17,20 @@ struct sway_session_lock_surface { | |||
17 | struct wl_listener output_commit; | 17 | struct wl_listener output_commit; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | static void set_lock_focused_surface(struct wlr_surface *focused) { | ||
21 | server.session_lock.focused = focused; | ||
22 | |||
23 | struct sway_seat *seat; | ||
24 | wl_list_for_each(seat, &server.input->seats, link) { | ||
25 | seat_set_focus_surface(seat, focused, false); | ||
26 | } | ||
27 | } | ||
28 | |||
20 | static void handle_surface_map(struct wl_listener *listener, void *data) { | 29 | static void handle_surface_map(struct wl_listener *listener, void *data) { |
21 | struct sway_session_lock_surface *surf = wl_container_of(listener, surf, map); | 30 | struct sway_session_lock_surface *surf = wl_container_of(listener, surf, map); |
22 | sway_force_focus(surf->surface); | 31 | if (server.session_lock.focused == NULL) { |
32 | set_lock_focused_surface(surf->surface); | ||
33 | } | ||
23 | output_damage_whole(surf->output); | 34 | output_damage_whole(surf->output); |
24 | } | 35 | } |
25 | 36 | ||
@@ -48,6 +59,21 @@ static void handle_output_commit(struct wl_listener *listener, void *data) { | |||
48 | 59 | ||
49 | static void handle_surface_destroy(struct wl_listener *listener, void *data) { | 60 | static void handle_surface_destroy(struct wl_listener *listener, void *data) { |
50 | struct sway_session_lock_surface *surf = wl_container_of(listener, surf, destroy); | 61 | struct sway_session_lock_surface *surf = wl_container_of(listener, surf, destroy); |
62 | |||
63 | // Move the seat focus to another surface if one is available | ||
64 | if (server.session_lock.focused == surf->surface) { | ||
65 | struct wlr_surface *next_focus = NULL; | ||
66 | |||
67 | struct wlr_session_lock_surface_v1 *other; | ||
68 | wl_list_for_each(other, &server.session_lock.lock->surfaces, link) { | ||
69 | if (other != surf->lock_surface && other->mapped) { | ||
70 | next_focus = other->surface; | ||
71 | break; | ||
72 | } | ||
73 | } | ||
74 | set_lock_focused_surface(next_focus); | ||
75 | } | ||
76 | |||
51 | wl_list_remove(&surf->map.link); | 77 | wl_list_remove(&surf->map.link); |
52 | wl_list_remove(&surf->destroy.link); | 78 | wl_list_remove(&surf->destroy.link); |
53 | wl_list_remove(&surf->surface_commit.link); | 79 | wl_list_remove(&surf->surface_commit.link); |
@@ -88,6 +114,7 @@ static void handle_unlock(struct wl_listener *listener, void *data) { | |||
88 | sway_log(SWAY_DEBUG, "session unlocked"); | 114 | sway_log(SWAY_DEBUG, "session unlocked"); |
89 | server.session_lock.locked = false; | 115 | server.session_lock.locked = false; |
90 | server.session_lock.lock = NULL; | 116 | server.session_lock.lock = NULL; |
117 | server.session_lock.focused = NULL; | ||
91 | 118 | ||
92 | wl_list_remove(&server.session_lock.lock_new_surface.link); | 119 | wl_list_remove(&server.session_lock.lock_new_surface.link); |
93 | wl_list_remove(&server.session_lock.lock_unlock.link); | 120 | wl_list_remove(&server.session_lock.lock_unlock.link); |
@@ -115,6 +142,7 @@ static void handle_unlock(struct wl_listener *listener, void *data) { | |||
115 | static void handle_abandon(struct wl_listener *listener, void *data) { | 142 | static void handle_abandon(struct wl_listener *listener, void *data) { |
116 | sway_log(SWAY_INFO, "session lock abandoned"); | 143 | sway_log(SWAY_INFO, "session lock abandoned"); |
117 | server.session_lock.lock = NULL; | 144 | server.session_lock.lock = NULL; |
145 | server.session_lock.focused = NULL; | ||
118 | 146 | ||
119 | wl_list_remove(&server.session_lock.lock_new_surface.link); | 147 | wl_list_remove(&server.session_lock.lock_new_surface.link); |
120 | wl_list_remove(&server.session_lock.lock_unlock.link); | 148 | wl_list_remove(&server.session_lock.lock_unlock.link); |