blob: 79283fd1175a95fb6aba4a6c7d86635740158ed7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <wlr/config.h>
#include <wlr/backend/headless.h>
#include <wlr/backend/multi.h>
#include <wlr/backend/wayland.h>
#if WLR_HAS_X11_BACKEND
#include <wlr/backend/x11.h>
#endif
#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_headless(backend)) {
wlr_headless_add_output(backend, 1920, 1080);
*done = true;
}
#if WLR_HAS_X11_BACKEND
else if (wlr_backend_is_x11(backend)) {
wlr_x11_output_create(backend);
*done = true;
}
#endif
}
/**
* 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,
"Can only create outputs for Wayland, X11 or headless backends");
}
return cmd_results_new(CMD_SUCCESS, NULL);
}
|