diff options
-rw-r--r-- | include/sway/desktop/launcher.h | 2 | ||||
-rw-r--r-- | include/sway/server.h | 2 | ||||
-rw-r--r-- | sway/commands/exec_always.c | 1 | ||||
-rw-r--r-- | sway/desktop/launcher.c | 18 | ||||
-rw-r--r-- | sway/server.c | 2 |
5 files changed, 13 insertions, 12 deletions
diff --git a/include/sway/desktop/launcher.h b/include/sway/desktop/launcher.h index 927d7a37..09b27eb9 100644 --- a/include/sway/desktop/launcher.h +++ b/include/sway/desktop/launcher.h | |||
@@ -23,6 +23,6 @@ void launcher_ctx_consume(struct launcher_ctx *ctx); | |||
23 | 23 | ||
24 | void launcher_ctx_destroy(struct launcher_ctx *ctx); | 24 | void launcher_ctx_destroy(struct launcher_ctx *ctx); |
25 | 25 | ||
26 | void launcher_ctx_create(pid_t pid); | 26 | struct launcher_ctx *launcher_ctx_create(pid_t pid); |
27 | 27 | ||
28 | #endif | 28 | #endif |
diff --git a/include/sway/server.h b/include/sway/server.h index 6a5a60c8..8a3cd2f2 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -114,6 +114,8 @@ struct sway_server { | |||
114 | struct wlr_xdg_activation_v1 *xdg_activation_v1; | 114 | struct wlr_xdg_activation_v1 *xdg_activation_v1; |
115 | struct wl_listener xdg_activation_v1_request_activate; | 115 | struct wl_listener xdg_activation_v1_request_activate; |
116 | 116 | ||
117 | struct wl_list pending_launcher_ctxs; // launcher_ctx::link | ||
118 | |||
117 | // The timeout for transactions, after which a transaction is applied | 119 | // The timeout for transactions, after which a transaction is applied |
118 | // regardless of readiness. | 120 | // regardless of readiness. |
119 | size_t txn_timeout_ms; | 121 | size_t txn_timeout_ms; |
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index d67e416f..0d3254ae 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "sway/config.h" | 9 | #include "sway/config.h" |
10 | #include "sway/server.h" | 10 | #include "sway/server.h" |
11 | #include "sway/desktop/launcher.h" | 11 | #include "sway/desktop/launcher.h" |
12 | #include "sway/server.h" | ||
12 | #include "sway/tree/container.h" | 13 | #include "sway/tree/container.h" |
13 | #include "sway/tree/root.h" | 14 | #include "sway/tree/root.h" |
14 | #include "sway/tree/workspace.h" | 15 | #include "sway/tree/workspace.h" |
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 | } |
diff --git a/sway/server.c b/sway/server.c index f6720755..554ceb86 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -215,6 +215,8 @@ bool server_init(struct sway_server *server) { | |||
215 | wl_signal_add(&server->xdg_activation_v1->events.request_activate, | 215 | wl_signal_add(&server->xdg_activation_v1->events.request_activate, |
216 | &server->xdg_activation_v1_request_activate); | 216 | &server->xdg_activation_v1_request_activate); |
217 | 217 | ||
218 | wl_list_init(&server->pending_launcher_ctxs); | ||
219 | |||
218 | // Avoid using "wayland-0" as display socket | 220 | // Avoid using "wayland-0" as display socket |
219 | char name_candidate[16]; | 221 | char name_candidate[16]; |
220 | for (unsigned int i = 1; i <= 32; ++i) { | 222 | for (unsigned int i = 1; i <= 32; ++i) { |