diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 14 | ||||
-rw-r--r-- | sway/config.c | 2 | ||||
-rw-r--r-- | sway/container.c | 11 | ||||
-rw-r--r-- | sway/handlers.c | 7 |
4 files changed, 33 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index df48724a..1d88e724 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -388,6 +388,19 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) { return true; } +static bool cmd_orientation(struct sway_config *config, int argc, char **argv) { + 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 false; + } + return true; +} + static bool cmd_output(struct sway_config *config, int argc, char **argv) { if (!checkarg(argc, "output", EXPECTED_AT_LEAST, 1)) { return false; @@ -713,6 +726,7 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) { /* Keep alphabetized */ static struct cmd_handler handlers[] = { { "bindsym", cmd_bindsym }, + { "default_orientation", cmd_orientation }, { "exec", cmd_exec }, { "exec_always", cmd_exec_always }, { "exit", cmd_exit }, diff --git a/sway/config.c b/sway/config.c index 53fc860a..08b14f84 100644 --- a/sway/config.c +++ b/sway/config.c @@ -27,6 +27,8 @@ void config_defaults(struct sway_config *config) { config->current_mode->name = NULL; config->current_mode->bindings = create_list(); list_add(config->modes, config->current_mode); + config->default_layout = L_NONE; + config->default_orientation = L_NONE; // Flags config->focus_follows_mouse = true; config->mouse_warping = true; diff --git a/sway/container.c b/sway/container.c index 05bb6abb..abbd5504 100644 --- a/sway/container.c +++ b/sway/container.c @@ -146,7 +146,16 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle); swayc_t *workspace = new_swayc(C_WORKSPACE); - workspace->layout = L_HORIZ; // TODO: default layout + // TODO: default_layout + if (config->default_layout != L_NONE) { + workspace->layout = config->default_layout; + } else if (config->default_orientation != L_NONE) { + workspace->layout = config->default_orientation; + } else if (output->width >= output->height) { + workspace->layout = L_HORIZ; + } else { + workspace->layout = L_VERT; + } workspace->x = output->x; workspace->y = output->y; workspace->width = output->width; diff --git a/sway/handlers.c b/sway/handlers.c index 2223a98c..aa336e8d 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -130,6 +130,13 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_ if (!c) return; c->width = to->w; c->height = to->h; + if (config->default_layout == L_NONE && config->default_orientation == L_NONE) { + if (c->width >= c->height) { + ((swayc_t*)c->children->items[0])->layout = L_HORIZ; + } else { + ((swayc_t*)c->children->items[0])->layout = L_VERT; + } + } arrange_windows(&root_container, -1, -1); } |