mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 09:51:29 +00:00
Add default_orientation command
This commit is contained in:
parent
2d46050281
commit
69eb021767
|
@ -95,6 +95,7 @@ sway_cmd cmd_commands;
|
|||
sway_cmd cmd_debuglog;
|
||||
sway_cmd cmd_default_border;
|
||||
sway_cmd cmd_default_floating_border;
|
||||
sway_cmd cmd_default_orientation;
|
||||
sway_cmd cmd_exec;
|
||||
sway_cmd cmd_exec_always;
|
||||
sway_cmd cmd_exit;
|
||||
|
@ -125,7 +126,6 @@ sway_cmd cmd_move;
|
|||
sway_cmd cmd_new_float;
|
||||
sway_cmd cmd_new_window;
|
||||
sway_cmd cmd_no_focus;
|
||||
sway_cmd cmd_orientation;
|
||||
sway_cmd cmd_output;
|
||||
sway_cmd cmd_permit;
|
||||
sway_cmd cmd_reject;
|
||||
|
|
|
@ -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 },
|
||||
};
|
||||
|
|
21
sway/commands/default_orientation.c
Normal file
21
sway/commands/default_orientation.c
Normal file
|
@ -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);
|
||||
}
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue