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/desktop | |
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/desktop')
-rw-r--r-- | sway/desktop/launcher.c | 13 |
1 files changed, 12 insertions, 1 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 | } |