diff options
author | Ronan Pigott <ronan@rjp.ie> | 2024-02-07 16:13:25 -0700 |
---|---|---|
committer | Ronan Pigott <ronan@rjp.ie> | 2024-02-17 00:54:30 -0700 |
commit | f6d22f8e6886edfeca3ecbb695b02079e81ce360 (patch) | |
tree | 75cb3af1922edc274cd5d7a35d68810dbe86ffe4 /sway | |
parent | Drop unnecessary includes from sway/server.h (diff) | |
download | sway-f6d22f8e6886edfeca3ecbb695b02079e81ce360.tar.gz sway-f6d22f8e6886edfeca3ecbb695b02079e81ce360.tar.zst sway-f6d22f8e6886edfeca3ecbb695b02079e81ce360.zip |
launcher: track the seat in the launcher ctx
This is a more suitable place to track the requesting seat, since we are
able to respond appropriately to destroy notifications.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/launcher.c | 13 | ||||
-rw-r--r-- | sway/xdg_activation_v1.c | 21 |
2 files changed, 28 insertions, 6 deletions
diff --git a/sway/desktop/launcher.c b/sway/desktop/launcher.c index 00a7e38a..4a4255d7 100644 --- a/sway/desktop/launcher.c +++ b/sway/desktop/launcher.c | |||
@@ -67,6 +67,9 @@ void launcher_ctx_destroy(struct launcher_ctx *ctx) { | |||
67 | } | 67 | } |
68 | wl_list_remove(&ctx->node_destroy.link); | 68 | wl_list_remove(&ctx->node_destroy.link); |
69 | wl_list_remove(&ctx->token_destroy.link); | 69 | wl_list_remove(&ctx->token_destroy.link); |
70 | if (ctx->seat) { | ||
71 | wl_list_remove(&ctx->seat_destroy.link); | ||
72 | } | ||
70 | wl_list_remove(&ctx->link); | 73 | wl_list_remove(&ctx->link); |
71 | wlr_xdg_activation_token_v1_destroy(ctx->token); | 74 | wlr_xdg_activation_token_v1_destroy(ctx->token); |
72 | free(ctx->fallback_name); | 75 | free(ctx->fallback_name); |
@@ -227,6 +230,12 @@ struct launcher_ctx *launcher_ctx_create(struct wlr_xdg_activation_token_v1 *tok | |||
227 | return ctx; | 230 | return ctx; |
228 | } | 231 | } |
229 | 232 | ||
233 | static void launch_ctx_handle_seat_destroy(struct wl_listener *listener, void *data) { | ||
234 | struct launcher_ctx *ctx = wl_container_of(listener, ctx, seat_destroy); | ||
235 | ctx->seat = NULL; | ||
236 | wl_list_remove(&ctx->seat_destroy.link); | ||
237 | } | ||
238 | |||
230 | // Creates a context with a new token for the internal launcher | 239 | // Creates a context with a new token for the internal launcher |
231 | struct launcher_ctx *launcher_ctx_create_internal(void) { | 240 | struct launcher_ctx *launcher_ctx_create_internal(void) { |
232 | struct sway_seat *seat = input_manager_current_seat(); | 241 | struct sway_seat *seat = input_manager_current_seat(); |
@@ -238,13 +247,15 @@ struct launcher_ctx *launcher_ctx_create_internal(void) { | |||
238 | 247 | ||
239 | struct wlr_xdg_activation_token_v1 *token = | 248 | struct wlr_xdg_activation_token_v1 *token = |
240 | wlr_xdg_activation_token_v1_create(server.xdg_activation_v1); | 249 | wlr_xdg_activation_token_v1_create(server.xdg_activation_v1); |
241 | token->seat = seat->wlr_seat; | ||
242 | 250 | ||
243 | struct launcher_ctx *ctx = launcher_ctx_create(token, &ws->node); | 251 | struct launcher_ctx *ctx = launcher_ctx_create(token, &ws->node); |
244 | if (!ctx) { | 252 | if (!ctx) { |
245 | wlr_xdg_activation_token_v1_destroy(token); | 253 | wlr_xdg_activation_token_v1_destroy(token); |
246 | return NULL; | 254 | return NULL; |
247 | } | 255 | } |
256 | ctx->seat = seat; | ||
257 | ctx->seat_destroy.notify = launch_ctx_handle_seat_destroy; | ||
258 | wl_signal_add(&seat->wlr_seat->events.destroy, &ctx->seat_destroy); | ||
248 | 259 | ||
249 | return ctx; | 260 | return ctx; |
250 | } | 261 | } |
diff --git a/sway/xdg_activation_v1.c b/sway/xdg_activation_v1.c index 47270f73..72c7fa4c 100644 --- a/sway/xdg_activation_v1.c +++ b/sway/xdg_activation_v1.c | |||
@@ -18,11 +18,15 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | |||
18 | return; | 18 | return; |
19 | } | 19 | } |
20 | 20 | ||
21 | struct launcher_ctx *ctx = event->token->data; | ||
22 | if (ctx == NULL) { | ||
23 | return; | ||
24 | } | ||
25 | |||
21 | if (!xdg_surface->surface->mapped) { | 26 | if (!xdg_surface->surface->mapped) { |
22 | // This is a startup notification. If we are tracking it, the data | 27 | // This is a startup notification. If we are tracking it, the data |
23 | // field is a launcher_ctx. | 28 | // field is a launcher_ctx. |
24 | struct launcher_ctx *ctx = event->token->data; | 29 | if (ctx->activated) { |
25 | if (!ctx || ctx->activated) { | ||
26 | // This ctx has already been activated and cannot be used again | 30 | // This ctx has already been activated and cannot be used again |
27 | // for a startup notification. It will be destroyed | 31 | // for a startup notification. It will be destroyed |
28 | return; | 32 | return; |
@@ -33,9 +37,16 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | |||
33 | return; | 37 | return; |
34 | } | 38 | } |
35 | 39 | ||
36 | struct wlr_seat *wlr_seat = event->token->seat; | 40 | // This is an activation request. If this context is internal we have ctx->seat. |
37 | struct sway_seat *seat = wlr_seat ? wlr_seat->data : NULL; | 41 | struct sway_seat *seat = ctx->seat; |
38 | view_request_activate(view, seat); | 42 | if (!seat) { |
43 | // Otherwise, use the seat indicated by the launcher client in set_serial | ||
44 | seat = ctx->token->seat ? ctx->token->seat->data : NULL; | ||
45 | } | ||
46 | |||
47 | if (seat) { | ||
48 | view_request_activate(view, seat); | ||
49 | } | ||
39 | } | 50 | } |
40 | 51 | ||
41 | void xdg_activation_v1_handle_new_token(struct wl_listener *listener, void *data) { | 52 | void xdg_activation_v1_handle_new_token(struct wl_listener *listener, void *data) { |