aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/create_output.c
diff options
context:
space:
mode:
authorRyan Dwyer <RyanDwyer@users.noreply.github.com>2018-09-21 20:05:39 +1000
committerGitHub <noreply@github.com>2018-09-21 20:05:39 +1000
commit0798fadff2f2f74a7efd7c14c55737bac19de954 (patch)
tree86e1ab4983fec3586a8bbb0044216216e22cc1cb /sway/commands/create_output.c
parent4289343e17615509fba5fe389d855f2292ba09bc (diff)
parentfa4308c5abecaeef870aced574e9d05e24e62392 (diff)
Merge branch 'master' into render-output-segfault
Diffstat (limited to 'sway/commands/create_output.c')
-rw-r--r--sway/commands/create_output.c39
1 files changed, 39 insertions, 0 deletions
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 <wlr/backend/multi.h>
+#include <wlr/backend/wayland.h>
+#include <wlr/backend/x11.h>
+#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);
+}