2018-09-21 21:25:03 +10:00
|
|
|
#include <wlr/config.h>
|
2020-04-14 22:57:12 +10:00
|
|
|
#include <wlr/backend/headless.h>
|
2018-09-19 21:54:27 +10:00
|
|
|
#include <wlr/backend/multi.h>
|
|
|
|
#include <wlr/backend/wayland.h>
|
2018-11-13 08:23:06 +11:00
|
|
|
#if WLR_HAS_X11_BACKEND
|
2018-09-19 21:54:27 +10:00
|
|
|
#include <wlr/backend/x11.h>
|
2018-09-21 21:25:03 +10:00
|
|
|
#endif
|
2018-09-19 21:54:27 +10:00
|
|
|
#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;
|
2020-04-14 22:57:12 +10:00
|
|
|
} else if (wlr_backend_is_headless(backend)) {
|
|
|
|
wlr_headless_add_output(backend, 1920, 1080);
|
|
|
|
*done = true;
|
2018-09-21 21:25:03 +10:00
|
|
|
}
|
2018-11-13 08:23:06 +11:00
|
|
|
#if WLR_HAS_X11_BACKEND
|
2018-09-21 21:25:03 +10:00
|
|
|
else if (wlr_backend_is_x11(backend)) {
|
2018-09-19 21:54:27 +10:00
|
|
|
wlr_x11_output_create(backend);
|
|
|
|
*done = true;
|
|
|
|
}
|
2018-09-21 21:25:03 +10:00
|
|
|
#endif
|
2018-09-19 21:54:27 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2019-01-11 10:27:21 +11:00
|
|
|
return cmd_results_new(CMD_INVALID,
|
2020-04-14 22:57:12 +10:00
|
|
|
"Can only create outputs for Wayland, X11 or headless backends");
|
2018-09-19 21:54:27 +10:00
|
|
|
}
|
|
|
|
|
2019-01-11 10:27:21 +11:00
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
2018-09-19 21:54:27 +10:00
|
|
|
}
|