diff options
author | Ronan Pigott <ronan@rjp.ie> | 2022-11-16 15:50:34 -0700 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-11-26 09:48:58 +0100 |
commit | 66568508c06267445489d655c91c94a34d6d9ffe (patch) | |
tree | 90b6abe3eefb6c95c89afa554281c0fd67749db3 /sway/desktop/launcher.c | |
parent | view: associate launch contexts with views (diff) | |
download | sway-66568508c06267445489d655c91c94a34d6d9ffe.tar.gz sway-66568508c06267445489d655c91c94a34d6d9ffe.tar.zst sway-66568508c06267445489d655c91c94a34d6d9ffe.zip |
launcher: initialize launcher_ctxs once on startup
Diffstat (limited to 'sway/desktop/launcher.c')
-rw-r--r-- | sway/desktop/launcher.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/sway/desktop/launcher.c b/sway/desktop/launcher.c index 810a04ef..89a93384 100644 --- a/sway/desktop/launcher.c +++ b/sway/desktop/launcher.c | |||
@@ -11,8 +11,6 @@ | |||
11 | #include "sway/tree/root.h" | 11 | #include "sway/tree/root.h" |
12 | #include "log.h" | 12 | #include "log.h" |
13 | 13 | ||
14 | static struct wl_list launcher_ctxs; | ||
15 | |||
16 | /** | 14 | /** |
17 | * Get the pid of a parent process given the pid of a child process. | 15 | * Get the pid of a parent process given the pid of a child process. |
18 | * | 16 | * |
@@ -73,8 +71,7 @@ void launcher_ctx_destroy(struct launcher_ctx *ctx) { | |||
73 | } | 71 | } |
74 | 72 | ||
75 | struct launcher_ctx *launcher_ctx_find_pid(pid_t pid) { | 73 | struct launcher_ctx *launcher_ctx_find_pid(pid_t pid) { |
76 | if (!launcher_ctxs.prev && !launcher_ctxs.next) { | 74 | if (wl_list_empty(&server.pending_launcher_ctxs)) { |
77 | wl_list_init(&launcher_ctxs); | ||
78 | return NULL; | 75 | return NULL; |
79 | } | 76 | } |
80 | 77 | ||
@@ -83,7 +80,7 @@ struct launcher_ctx *launcher_ctx_find_pid(pid_t pid) { | |||
83 | 80 | ||
84 | do { | 81 | do { |
85 | struct launcher_ctx *_ctx = NULL; | 82 | struct launcher_ctx *_ctx = NULL; |
86 | wl_list_for_each(_ctx, &launcher_ctxs, link) { | 83 | wl_list_for_each(_ctx, &server.pending_launcher_ctxs, link) { |
87 | if (pid == _ctx->pid) { | 84 | if (pid == _ctx->pid) { |
88 | ctx = _ctx; | 85 | ctx = _ctx; |
89 | sway_log(SWAY_DEBUG, | 86 | sway_log(SWAY_DEBUG, |
@@ -178,17 +175,14 @@ static void token_handle_destroy(struct wl_listener *listener, void *data) { | |||
178 | launcher_ctx_destroy(ctx); | 175 | launcher_ctx_destroy(ctx); |
179 | } | 176 | } |
180 | 177 | ||
181 | void launcher_ctx_create(pid_t pid) { | 178 | struct launcher_ctx *launcher_ctx_create(pid_t pid) { |
182 | sway_log(SWAY_DEBUG, "Recording workspace for process %d", pid); | 179 | sway_log(SWAY_DEBUG, "Recording workspace for process %d", pid); |
183 | if (!launcher_ctxs.prev && !launcher_ctxs.next) { | ||
184 | wl_list_init(&launcher_ctxs); | ||
185 | } | ||
186 | 180 | ||
187 | struct sway_seat *seat = input_manager_current_seat(); | 181 | struct sway_seat *seat = input_manager_current_seat(); |
188 | struct sway_workspace *ws = seat_get_focused_workspace(seat); | 182 | struct sway_workspace *ws = seat_get_focused_workspace(seat); |
189 | if (!ws) { | 183 | if (!ws) { |
190 | sway_log(SWAY_DEBUG, "Bailing out, no workspace"); | 184 | sway_log(SWAY_DEBUG, "Bailing out, no workspace"); |
191 | return; | 185 | return NULL; |
192 | } | 186 | } |
193 | 187 | ||
194 | struct launcher_ctx *ctx = calloc(1, sizeof(struct launcher_ctx)); | 188 | struct launcher_ctx *ctx = calloc(1, sizeof(struct launcher_ctx)); |
@@ -206,5 +200,7 @@ void launcher_ctx_create(pid_t pid) { | |||
206 | ctx->token_destroy.notify = token_handle_destroy; | 200 | ctx->token_destroy.notify = token_handle_destroy; |
207 | wl_signal_add(&token->events.destroy, &ctx->token_destroy); | 201 | wl_signal_add(&token->events.destroy, &ctx->token_destroy); |
208 | 202 | ||
209 | wl_list_insert(&launcher_ctxs, &ctx->link); | 203 | wl_list_init(&ctx->link); |
204 | wl_list_insert(&server.pending_launcher_ctxs, &ctx->link); | ||
205 | return ctx; | ||
210 | } | 206 | } |