-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2669 from RyanDwyer/create-output-command
Introduce create_output command (for developer use)
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters