From ec652866060a178796d6dbb32bf7f0e2101e56c9 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 19 Jul 2018 01:39:58 -0400 Subject: [PATCH 1/2] Fix deferred command handling --- include/sway/server.h | 1 + sway/config.c | 4 ++-- sway/main.c | 9 ++++++++- sway/server.c | 12 +++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/sway/server.h b/include/sway/server.h index a017d1c4e..70bde6d47 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -56,6 +56,7 @@ struct sway_server server; bool server_privileged_prepare(struct sway_server *server); bool server_init(struct sway_server *server); void server_fini(struct sway_server *server); +bool server_start_backend(struct sway_server *server); void server_run(struct sway_server *server); void handle_new_output(struct wl_listener *listener, void *data); diff --git a/sway/config.c b/sway/config.c index c620e4c75..005008120 100644 --- a/sway/config.c +++ b/sway/config.c @@ -649,7 +649,6 @@ bool read_config(FILE *file, struct sway_config *config) { } else { res = config_command(expanded); } - free(expanded); switch(res->status) { case CMD_FAILURE: case CMD_INVALID: @@ -660,7 +659,7 @@ bool read_config(FILE *file, struct sway_config *config) { case CMD_DEFER: wlr_log(WLR_DEBUG, "Deferring command `%s'", line); - list_add(config->cmd_queue, strdup(line)); + list_add(config->cmd_queue, strdup(expanded)); break; case CMD_BLOCK_COMMANDS: @@ -693,6 +692,7 @@ bool read_config(FILE *file, struct sway_config *config) { sizeof(config->handler_context)); default:; } + free(expanded); free(line); free_cmd_results(res); } diff --git a/sway/main.c b/sway/main.c index 1a55b519c..a20f1dacb 100644 --- a/sway/main.c +++ b/sway/main.c @@ -429,9 +429,16 @@ int main(int argc, char **argv) { security_sanity_check(); - config->active = true; setenv("WAYLAND_DISPLAY", server.socket, true); + if (!terminate_request) { + if (!server_start_backend(&server)) { + sway_terminate(EXIT_FAILURE); + } + } + + config->active = true; // Execute commands until there are none left + wlr_log(WLR_DEBUG, "Running deferred commands"); while (config->cmd_queue->length) { char *line = config->cmd_queue->items[0]; struct cmd_results *res = execute_command(line, NULL); diff --git a/sway/server.c b/sway/server.c index f904b1774..ee71d5385 100644 --- a/sway/server.c +++ b/sway/server.c @@ -137,13 +137,19 @@ void server_fini(struct sway_server *server) { list_free(server->transactions); } -void server_run(struct sway_server *server) { - wlr_log(WLR_INFO, "Running compositor on wayland display '%s'", +bool server_start_backend(struct sway_server *server) { + wlr_log(WLR_INFO, "Starting backend on wayland display '%s'", server->socket); if (!wlr_backend_start(server->backend)) { wlr_log(WLR_ERROR, "Failed to start backend"); wlr_backend_destroy(server->backend); - return; + return false; } + return true; +} + +void server_run(struct sway_server *server) { + wlr_log(WLR_INFO, "Running compositor on wayland display '%s'", + server->socket); wl_display_run(server->wl_display); } From 54b00d351e50e82cb664c57b2a416b7a37963759 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 19 Jul 2018 22:30:19 +1000 Subject: [PATCH 2/2] Implement assign to output Eg. assign [class="Firefox"] output foo --- sway/tree/view.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sway/tree/view.c b/sway/tree/view.c index fc31699c1..7881e6d7f 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -564,7 +564,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { } focus = seat_get_focus_inactive(seat, workspace); } else { - // TODO: CT_ASSIGN_OUTPUT + // CT_ASSIGN_OUTPUT + struct sway_container *output = output_by_name(criteria->target); + if (output) { + focus = seat_get_focus_inactive(seat, output); + } } } // If we're about to launch the view into the floating container, then