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 | bdeb9f95651f6c99cc2f4cfb59020ddee202cf36 (patch) | |
tree | a3c27179887ff4a8b88e08b65e55e8fd838f46f7 /sway | |
parent | 66568508c06267445489d655c91c94a34d6d9ffe (diff) | |
download | sway-bdeb9f95651f6c99cc2f4cfb59020ddee202cf36.tar.xz |
launcher: fudge the interface a bit
We want to create a context before knowing the pid it will match with.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/exec_always.c | 7 | ||||
-rw-r--r-- | sway/desktop/launcher.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 0d3254ae..13deb9e3 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -53,6 +53,7 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { } pid_t pid, child; + struct launcher_ctx *ctx = launcher_ctx_create(); // Fork process if ((pid = fork()) == 0) { // Fork child process again @@ -92,8 +93,12 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { waitpid(pid, NULL, 0); if (child > 0) { sway_log(SWAY_DEBUG, "Child process created with pid %d", child); - launcher_ctx_create(child); + if (ctx != NULL) { + sway_log(SWAY_DEBUG, "Recording workspace for process %d", child); + ctx->pid = child; + } } else { + launcher_ctx_destroy(ctx); return cmd_results_new(CMD_FAILURE, "Second fork() failed"); } diff --git a/sway/desktop/launcher.c b/sway/desktop/launcher.c index 89a93384..b983dcb0 100644 --- a/sway/desktop/launcher.c +++ b/sway/desktop/launcher.c @@ -175,13 +175,11 @@ static void token_handle_destroy(struct wl_listener *listener, void *data) { launcher_ctx_destroy(ctx); } -struct launcher_ctx *launcher_ctx_create(pid_t pid) { - sway_log(SWAY_DEBUG, "Recording workspace for process %d", pid); - +struct launcher_ctx *launcher_ctx_create() { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *ws = seat_get_focused_workspace(seat); if (!ws) { - sway_log(SWAY_DEBUG, "Bailing out, no workspace"); + sway_log(SWAY_DEBUG, "Failed to create launch context. No workspace."); return NULL; } @@ -192,7 +190,6 @@ struct launcher_ctx *launcher_ctx_create(pid_t pid) { ctx->name = strdup(ws->name); ctx->token = token; ctx->node = &ws->node; - ctx->pid = pid; ctx->node_destroy.notify = ctx_handle_node_destroy; wl_signal_add(&ctx->node->events.destroy, &ctx->node_destroy); |