diff --git a/include/layout.h b/include/layout.h index b7731031..84552754 100644 --- a/include/layout.h +++ b/include/layout.h @@ -67,4 +67,9 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed void layout_log(const swayc_t *c, int depth); void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4))); +/** + * Get default layout. + */ +enum swayc_layouts default_layout(swayc_t *output); + #endif diff --git a/sway/commands.c b/sway/commands.c index 12d60854..ce1fe8a3 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1760,9 +1760,8 @@ static struct cmd_results *cmd_layout(int argc, char **argv) { } if (strcasecmp(argv[0], "default") == 0) { - // TODO: determine default from default_orientation and - // cmd_workspace_layout - parent->layout = L_HORIZ; + swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT); + parent->layout = default_layout(output); } else if (strcasecmp(argv[0], "tabbed") == 0) { if (parent->type != C_CONTAINER) { parent = new_container(parent, L_TABBED); diff --git a/sway/config.c b/sway/config.c index c11ccf53..ebcee95b 100644 --- a/sway/config.c +++ b/sway/config.c @@ -160,7 +160,7 @@ static void config_defaults(struct sway_config *config) { config->dragging_key = M_LEFT_CLICK; config->resizing_key = M_RIGHT_CLICK; config->floating_scroll = FSB_GAPS_INNER; - config->default_layout = L_HORIZ; + config->default_layout = L_NONE; config->default_orientation = L_NONE; config->font = strdup("monospace 10"); config->font_height = get_font_text_height(config->font); diff --git a/sway/container.c b/sway/container.c index 2b100f40..5579fddb 100644 --- a/sway/container.c +++ b/sway/container.c @@ -163,16 +163,8 @@ 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); - // 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->layout = default_layout(output); + workspace->x = output->x; workspace->y = output->y; workspace->width = output->width; diff --git a/sway/layout.c b/sway/layout.c index 527579d9..261e2138 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -993,3 +993,15 @@ void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge ed } } } + +enum swayc_layouts default_layout(swayc_t *output) { + if (config->default_layout != L_NONE) { + return config->default_layout; + } else if (config->default_orientation != L_NONE) { + return config->default_orientation; + } else if (output->width >= output->height) { + return L_HORIZ; + } else { + return L_VERT; + } +}