aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/launcher.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/launcher.c')
-rw-r--r--sway/desktop/launcher.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sway/desktop/launcher.c b/sway/desktop/launcher.c
index 00a7e38a..2362e1ba 100644
--- a/sway/desktop/launcher.c
+++ b/sway/desktop/launcher.c
@@ -1,10 +1,10 @@
1#define _POSIX_C_SOURCE 200809L
2#include <stdlib.h> 1#include <stdlib.h>
3#include <string.h> 2#include <string.h>
4#include <wlr/types/wlr_xdg_activation_v1.h> 3#include <wlr/types/wlr_xdg_activation_v1.h>
5#include "sway/input/seat.h" 4#include "sway/input/seat.h"
6#include "sway/output.h" 5#include "sway/output.h"
7#include "sway/desktop/launcher.h" 6#include "sway/desktop/launcher.h"
7#include "sway/server.h"
8#include "sway/tree/node.h" 8#include "sway/tree/node.h"
9#include "sway/tree/container.h" 9#include "sway/tree/container.h"
10#include "sway/tree/workspace.h" 10#include "sway/tree/workspace.h"
@@ -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);
@@ -213,6 +216,8 @@ struct launcher_ctx *launcher_ctx_create(struct wlr_xdg_activation_token_v1 *tok
213 ctx->fallback_name = strdup(fallback_name); 216 ctx->fallback_name = strdup(fallback_name);
214 ctx->token = token; 217 ctx->token = token;
215 ctx->node = node; 218 ctx->node = node;
219 // Having surface set means that the focus check in wlroots has passed
220 ctx->had_focused_surface = token->surface != NULL;
216 221
217 ctx->node_destroy.notify = ctx_handle_node_destroy; 222 ctx->node_destroy.notify = ctx_handle_node_destroy;
218 wl_signal_add(&ctx->node->events.destroy, &ctx->node_destroy); 223 wl_signal_add(&ctx->node->events.destroy, &ctx->node_destroy);
@@ -227,6 +232,12 @@ struct launcher_ctx *launcher_ctx_create(struct wlr_xdg_activation_token_v1 *tok
227 return ctx; 232 return ctx;
228} 233}
229 234
235static void launch_ctx_handle_seat_destroy(struct wl_listener *listener, void *data) {
236 struct launcher_ctx *ctx = wl_container_of(listener, ctx, seat_destroy);
237 ctx->seat = NULL;
238 wl_list_remove(&ctx->seat_destroy.link);
239}
240
230// Creates a context with a new token for the internal launcher 241// Creates a context with a new token for the internal launcher
231struct launcher_ctx *launcher_ctx_create_internal(void) { 242struct launcher_ctx *launcher_ctx_create_internal(void) {
232 struct sway_seat *seat = input_manager_current_seat(); 243 struct sway_seat *seat = input_manager_current_seat();
@@ -238,13 +249,15 @@ struct launcher_ctx *launcher_ctx_create_internal(void) {
238 249
239 struct wlr_xdg_activation_token_v1 *token = 250 struct wlr_xdg_activation_token_v1 *token =
240 wlr_xdg_activation_token_v1_create(server.xdg_activation_v1); 251 wlr_xdg_activation_token_v1_create(server.xdg_activation_v1);
241 token->seat = seat->wlr_seat;
242 252
243 struct launcher_ctx *ctx = launcher_ctx_create(token, &ws->node); 253 struct launcher_ctx *ctx = launcher_ctx_create(token, &ws->node);
244 if (!ctx) { 254 if (!ctx) {
245 wlr_xdg_activation_token_v1_destroy(token); 255 wlr_xdg_activation_token_v1_destroy(token);
246 return NULL; 256 return NULL;
247 } 257 }
258 ctx->seat = seat;
259 ctx->seat_destroy.notify = launch_ctx_handle_seat_destroy;
260 wl_signal_add(&seat->wlr_seat->events.destroy, &ctx->seat_destroy);
248 261
249 return ctx; 262 return ctx;
250} 263}