From db2845963408dd0d66a3587469c6f26bfa4d9e1f Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 19 Sep 2018 21:54:27 +1000 Subject: Introduce create_output command (for developer use) Should help with testing hotplugging. --- sway/commands/create_output.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sway/commands/create_output.c (limited to 'sway/commands') diff --git a/sway/commands/create_output.c b/sway/commands/create_output.c new file mode 100644 index 00000000..a852c2a0 --- /dev/null +++ b/sway/commands/create_output.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include "sway/commands.h" +#include "sway/server.h" +#include "log.h" + +static void create_output(struct wlr_backend *backend, void *data) { + bool *done = data; + if (*done) { + return; + } + + if (wlr_backend_is_wl(backend)) { + wlr_wl_output_create(backend); + *done = true; + } else if (wlr_backend_is_x11(backend)) { + wlr_x11_output_create(backend); + *done = true; + } +} + +/** + * This command is intended for developer use only. + */ +struct cmd_results *cmd_create_output(int argc, char **argv) { + sway_assert(wlr_backend_is_multi(server.backend), + "Expected a multi backend"); + + bool done = false; + wlr_multi_for_each_backend(server.backend, create_output, &done); + + if (!done) { + return cmd_results_new(CMD_INVALID, "create_output", + "Can only create outputs for Wayland or X11 backends"); + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} -- cgit v1.2.3