Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce create_output command (for developer use) #2669

Merged
merged 2 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sway/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ sway_cmd cmd_client_urgent;
sway_cmd cmd_client_placeholder;
sway_cmd cmd_client_background;
sway_cmd cmd_commands;
sway_cmd cmd_create_output;
sway_cmd cmd_debuglog;
sway_cmd cmd_default_border;
sway_cmd cmd_default_floating_border;
Expand Down
1 change: 1 addition & 0 deletions sway/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static struct cmd_handler config_handlers[] = {
/* Runtime-only commands. Keep alphabetized */
static struct cmd_handler command_handlers[] = {
{ "border", cmd_border },
{ "create_output", cmd_create_output },
{ "exit", cmd_exit },
{ "floating", cmd_floating },
{ "fullscreen", cmd_fullscreen },
Expand Down
39 changes: 39 additions & 0 deletions sway/commands/create_output.c
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);
}
1 change: 1 addition & 0 deletions sway/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ sway_sources = files(
'commands/bind.c',
'commands/border.c',
'commands/client.c',
'commands/create_output.c',
'commands/default_border.c',
'commands/default_floating_border.c',
'commands/default_orientation.c',
Expand Down