From 0cd8efe0bb669e71e9cdc30d96ae466cb583e605 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Mon, 4 Oct 2021 10:04:46 -0400 Subject: sway: replace noop_output by fallback_output wlroots removed the support for the noop backend. Instead we rely on the headless backend to provide the fallback output. --- include/sway/server.h | 1 - include/sway/tree/root.h | 2 +- sway/commands/output.c | 6 +++--- sway/config/output.c | 6 +++--- sway/desktop/layer_shell.c | 2 +- sway/desktop/output.c | 6 +++++- sway/ipc-server.c | 2 +- sway/server.c | 11 +++++------ sway/tree/output.c | 6 +++--- sway/tree/root.c | 8 ++++---- sway/tree/workspace.c | 4 ++-- 11 files changed, 28 insertions(+), 26 deletions(-) diff --git a/include/sway/server.h b/include/sway/server.h index 109097d7..7ac2af26 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -33,7 +33,6 @@ struct sway_server { const char *socket; struct wlr_backend *backend; - struct wlr_backend *noop_backend; // secondary headless backend used for creating virtual outputs on-the-fly struct wlr_backend *headless_backend; struct wlr_renderer *renderer; diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index e8f4d573..5d4a2f2d 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h @@ -31,7 +31,7 @@ struct sway_root { list_t *scratchpad; // struct sway_container // For when there's no connected outputs - struct sway_output *noop_output; + struct sway_output *fallback_output; struct sway_container *fullscreen_global; diff --git a/sway/commands/output.c b/sway/commands/output.c index 42230bd7..125df5a7 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -34,9 +34,9 @@ struct cmd_results *cmd_output(int argc, char **argv) { return error; } - // The NOOP-1 output is a dummy output used when there's no outputs + // The HEADLESS-1 output is a dummy output used when there's no outputs // connected. It should never be configured. - if (strcasecmp(argv[0], root->noop_output->wlr_output->name) == 0) { + if (strcasecmp(argv[0], root->fallback_output->wlr_output->name) == 0) { return cmd_results_new(CMD_FAILURE, "Refusing to configure the no op output"); } @@ -53,7 +53,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { if (!sway_output) { return cmd_results_new(CMD_FAILURE, "Unknown output"); } - if (sway_output == root->noop_output) { + if (sway_output == root->fallback_output) { return cmd_results_new(CMD_FAILURE, "Refusing to configure the no op output"); } diff --git a/sway/config/output.c b/sway/config/output.c index 63c81382..fa509252 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -375,7 +375,7 @@ static const uint32_t *bit_depth_preferences[] = { static void queue_output_config(struct output_config *oc, struct sway_output *output) { - if (output == root->noop_output) { + if (output == root->fallback_output) { return; } @@ -478,7 +478,7 @@ static void queue_output_config(struct output_config *oc, } bool apply_output_config(struct output_config *oc, struct sway_output *output) { - if (output == root->noop_output) { + if (output == root->fallback_output) { return false; } @@ -573,7 +573,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) { } bool test_output_config(struct output_config *oc, struct sway_output *output) { - if (output == root->noop_output) { + if (output == root->fallback_output) { return false; } diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 7f5a337b..db78b59f 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -624,7 +624,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { output = ws->output; } } - if (!output || output == root->noop_output) { + if (!output || output == root->fallback_output) { if (!root->outputs->length) { sway_log(SWAY_ERROR, "no output to auto-assign layer surface '%s' to", diff --git a/sway/desktop/output.c b/sway/desktop/output.c index cd9fd3a6..ed6bc064 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -733,7 +733,7 @@ static void update_output_manager_config(struct sway_server *server) { struct sway_output *output; wl_list_for_each(output, &root->all_outputs, link) { - if (output == root->noop_output) { + if (output == root->fallback_output) { continue; } struct wlr_output_configuration_head_v1 *config_head = @@ -838,6 +838,10 @@ static void handle_present(struct wl_listener *listener, void *data) { void handle_new_output(struct wl_listener *listener, void *data) { struct sway_server *server = wl_container_of(listener, server, new_output); struct wlr_output *wlr_output = data; + if (wlr_output == root->fallback_output->wlr_output) { + return; + } + sway_log(SWAY_DEBUG, "New output %p: %s (non-desktop: %d)", wlr_output, wlr_output->name, wlr_output->non_desktop); diff --git a/sway/ipc-server.c b/sway/ipc-server.c index aad9a7b5..1bf5a05f 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -687,7 +687,7 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt } struct sway_output *output; wl_list_for_each(output, &root->all_outputs, link) { - if (!output->enabled && output != root->noop_output) { + if (!output->enabled && output != root->fallback_output) { json_object_array_add(outputs, ipc_json_describe_disabled_output(output)); } diff --git a/sway/server.c b/sway/server.c index 246f9c4f..ff269c79 100644 --- a/sway/server.c +++ b/sway/server.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -217,11 +216,6 @@ bool server_init(struct sway_server *server) { return false; } - server->noop_backend = wlr_noop_backend_create(server->wl_display); - - struct wlr_output *wlr_output = wlr_noop_add_output(server->noop_backend); - root->noop_output = output_create(wlr_output); - server->headless_backend = wlr_headless_backend_create(server->wl_display); if (!server->headless_backend) { sway_log(SWAY_ERROR, "Failed to create secondary headless backend"); @@ -231,6 +225,10 @@ bool server_init(struct sway_server *server) { wlr_multi_backend_add(server->backend, server->headless_backend); } + struct wlr_output *wlr_output = + wlr_headless_add_output(server->headless_backend, 800, 600); + root->fallback_output = output_create(wlr_output); + // This may have been set already via -Dtxn-timeout if (!server->txn_timeout_ms) { server->txn_timeout_ms = 200; @@ -287,6 +285,7 @@ bool server_start(struct sway_server *server) { wlr_backend_destroy(server->backend); return false; } + return true; } diff --git a/sway/tree/output.c b/sway/tree/output.c index c095dce0..242e6fac 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -56,8 +56,8 @@ static void restore_workspaces(struct sway_output *output) { } // Saved workspaces - while (root->noop_output->workspaces->length) { - struct sway_workspace *ws = root->noop_output->workspaces->items[0]; + while (root->fallback_output->workspaces->length) { + struct sway_workspace *ws = root->fallback_output->workspaces->items[0]; workspace_detach(ws); output_add_workspace(output, ws); @@ -192,7 +192,7 @@ static void output_evacuate(struct sway_output *output) { new_output = fallback_output; } if (!new_output) { - new_output = root->noop_output; + new_output = root->fallback_output; } struct sway_workspace *new_output_ws = diff --git a/sway/tree/root.c b/sway/tree/root.c index dd4d8e33..73f3993c 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -374,8 +374,8 @@ void root_for_each_container(void (*f)(struct sway_container *con, void *data), } // Saved workspaces - for (int i = 0; i < root->noop_output->workspaces->length; ++i) { - struct sway_workspace *ws = root->noop_output->workspaces->items[i]; + for (int i = 0; i < root->fallback_output->workspaces->length; ++i) { + struct sway_workspace *ws = root->fallback_output->workspaces->items[i]; workspace_for_each_container(ws, f, data); } } @@ -427,8 +427,8 @@ struct sway_container *root_find_container( } // Saved workspaces - for (int i = 0; i < root->noop_output->workspaces->length; ++i) { - struct sway_workspace *ws = root->noop_output->workspaces->items[i]; + for (int i = 0; i < root->fallback_output->workspaces->length; ++i) { + struct sway_workspace *ws = root->fallback_output->workspaces->items[i]; if ((result = workspace_find_container(ws, test, data))) { return result; } diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index e3ff1513..c84320bd 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -50,8 +50,8 @@ struct sway_output *workspace_get_initial_output(const char *name) { } else if (focus && focus->type == N_CONTAINER) { return focus->sway_container->pending.workspace->output; } - // Fallback to the first output or noop output for headless - return root->outputs->length ? root->outputs->items[0] : root->noop_output; + // Fallback to the first output or the headless output + return root->outputs->length ? root->outputs->items[0] : root->fallback_output; } struct sway_workspace *workspace_create(struct sway_output *output, -- cgit v1.2.3-54-g00ecf