diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-30 10:43:55 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-30 10:43:55 -0400 |
commit | 69eb021767d8cf57b08699c7e330fe8c52ca2764 (patch) | |
tree | c4160dfb51ece94ea4858fd86a097b881405f4b9 /sway | |
parent | 2d460502812093b47f43295cf21636198e44edbb (diff) |
Add default_orientation command
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/default_orientation.c | 21 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/tree/layout.c | 5 |
4 files changed, 25 insertions, 3 deletions
diff --git a/sway/commands.c b/sway/commands.c index bcc777ed..eee7f254 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -149,6 +149,7 @@ static struct cmd_handler bar_colors_handlers[] = { /* Config-time only commands. Keep alphabetized */ static struct cmd_handler config_handlers[] = { + { "default_orientation", cmd_default_orientation }, { "set", cmd_set }, { "swaybg_command", cmd_swaybg_command }, }; diff --git a/sway/commands/default_orientation.c b/sway/commands/default_orientation.c new file mode 100644 index 00000000..a5347ce2 --- /dev/null +++ b/sway/commands/default_orientation.c @@ -0,0 +1,21 @@ +#include <string.h> +#include <strings.h> +#include "sway/commands.h" + +struct cmd_results *cmd_default_orientation(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "default_orientation", EXPECTED_EQUAL_TO, 1))) { + return error; + } + if (strcasecmp(argv[0], "horizontal") == 0) { + config->default_orientation = L_HORIZ; + } else if (strcasecmp(argv[0], "vertical") == 0) { + config->default_orientation = L_VERT; + } else if (strcasecmp(argv[0], "auto") == 0) { + // Do nothing + } else { + return cmd_results_new(CMD_INVALID, "default_orientation", + "Expected 'orientation <horizontal|vertical|auto>'"); + } + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/meson.build b/sway/meson.build index 1e7ee7ae..9c5e4a00 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -8,6 +8,7 @@ sway_sources = files( 'input/keyboard.c', 'commands/bar.c', 'commands/bind.c', + 'commands/default_orientation.c', 'commands/exit.c', 'commands/exec.c', 'commands/exec_always.c', diff --git a/sway/tree/layout.c b/sway/tree/layout.c index dc0ee5b4..c7cf16e6 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -123,12 +123,11 @@ struct sway_container *container_remove_child(struct sway_container *child) { enum sway_container_layout container_get_default_layout( struct sway_container *output) { - /* TODO WLR if (config->default_layout != L_NONE) { - //return config->default_layout; + return config->default_layout; } else if (config->default_orientation != L_NONE) { return config->default_orientation; - } else */if (output->width >= output->height) { + } else if (output->width >= output->height) { return L_HORIZ; } else { return L_VERT; |