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.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/sway/desktop/launcher.c b/sway/desktop/launcher.c
index 337ca975..810a04ef 100644
--- a/sway/desktop/launcher.c
+++ b/sway/desktop/launcher.c
@@ -13,18 +13,6 @@
13 13
14static struct wl_list launcher_ctxs; 14static struct wl_list launcher_ctxs;
15 15
16struct launcher_ctx {
17 pid_t pid;
18 char *name;
19 struct wlr_xdg_activation_token_v1 *token;
20 struct wl_listener token_destroy;
21
22 struct sway_node *node;
23 struct wl_listener node_destroy;
24
25 struct wl_list link;
26};
27
28/** 16/**
29 * Get the pid of a parent process given the pid of a child process. 17 * Get the pid of a parent process given the pid of a child process.
30 * 18 *
@@ -59,7 +47,20 @@ static pid_t get_parent_pid(pid_t child) {
59 return -1; 47 return -1;
60} 48}
61 49
62static void launcher_ctx_destroy(struct launcher_ctx *ctx) { 50void launcher_ctx_consume(struct launcher_ctx *ctx) {
51 // The view is now responsible for destroying this ctx
52 wl_list_remove(&ctx->token_destroy.link);
53 wl_list_init(&ctx->token_destroy.link);
54
55 wlr_xdg_activation_token_v1_destroy(ctx->token);
56 ctx->token = NULL;
57
58 // Prevent additional matches
59 wl_list_remove(&ctx->link);
60 wl_list_init(&ctx->link);
61}
62
63void launcher_ctx_destroy(struct launcher_ctx *ctx) {
63 if (ctx == NULL) { 64 if (ctx == NULL) {
64 return; 65 return;
65 } 66 }
@@ -71,7 +72,7 @@ static void launcher_ctx_destroy(struct launcher_ctx *ctx) {
71 free(ctx); 72 free(ctx);
72} 73}
73 74
74static struct launcher_ctx *launcher_ctx_find_pid(pid_t pid) { 75struct launcher_ctx *launcher_ctx_find_pid(pid_t pid) {
75 if (!launcher_ctxs.prev && !launcher_ctxs.next) { 76 if (!launcher_ctxs.prev && !launcher_ctxs.next) {
76 wl_list_init(&launcher_ctxs); 77 wl_list_init(&launcher_ctxs);
77 return NULL; 78 return NULL;
@@ -97,7 +98,7 @@ static struct launcher_ctx *launcher_ctx_find_pid(pid_t pid) {
97 return ctx; 98 return ctx;
98} 99}
99 100
100static struct sway_workspace *launcher_ctx_get_workspace( 101struct sway_workspace *launcher_ctx_get_workspace(
101 struct launcher_ctx *ctx) { 102 struct launcher_ctx *ctx) {
102 struct sway_workspace *ws = NULL; 103 struct sway_workspace *ws = NULL;
103 struct sway_output *output = NULL; 104 struct sway_output *output = NULL;
@@ -135,16 +136,6 @@ static struct sway_workspace *launcher_ctx_get_workspace(
135 return ws; 136 return ws;
136} 137}
137 138
138struct sway_workspace *workspace_for_pid(pid_t pid) {
139 struct launcher_ctx *ctx = launcher_ctx_find_pid(pid);
140 if (ctx == NULL) {
141 return NULL;
142 }
143 struct sway_workspace *ws = launcher_ctx_get_workspace(ctx);
144 launcher_ctx_destroy(ctx);
145 return ws;
146}
147
148static void ctx_handle_node_destroy(struct wl_listener *listener, void *data) { 139static void ctx_handle_node_destroy(struct wl_listener *listener, void *data) {
149 struct launcher_ctx *ctx = wl_container_of(listener, ctx, node_destroy); 140 struct launcher_ctx *ctx = wl_container_of(listener, ctx, node_destroy);
150 switch (ctx->node->type) { 141 switch (ctx->node->type) {
@@ -217,12 +208,3 @@ void launcher_ctx_create(pid_t pid) {
217 208
218 wl_list_insert(&launcher_ctxs, &ctx->link); 209 wl_list_insert(&launcher_ctxs, &ctx->link);
219} 210}
220
221void remove_workspace_pid(pid_t pid) {
222 if (!launcher_ctxs.prev || !launcher_ctxs.next) {
223 return;
224 }
225
226 struct launcher_ctx *ctx = launcher_ctx_find_pid(pid);
227 launcher_ctx_destroy(ctx);
228}