diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-04-03 13:23:34 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-04-03 13:23:34 -0400 |
commit | 9b567fc37e83ed9f0cbb028fd801a2f2609c79dc (patch) | |
tree | a1ebdea49233f10c016664159bb9e8c9738e407c | |
parent | 065887bb7b25c1cf7d39459c79387a24e600085f (diff) |
clean up container_get_default_layout
-rw-r--r-- | include/sway/tree/layout.h | 3 | ||||
-rw-r--r-- | sway/commands/layout.c | 3 | ||||
-rw-r--r-- | sway/tree/container.c | 2 | ||||
-rw-r--r-- | sway/tree/layout.c | 14 |
4 files changed, 15 insertions, 7 deletions
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index 725422c6..12689375 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h @@ -55,9 +55,8 @@ void container_move_to(struct sway_container* container, void container_move(struct sway_container *container, enum movement_direction dir, int move_amt); -// TODO move to output.c enum sway_container_layout container_get_default_layout( - struct sway_container *output); + struct sway_container *con); // TODO move to output.c void container_sort_workspaces(struct sway_container *output); diff --git a/sway/commands/layout.c b/sway/commands/layout.c index ebab2a48..4c49a627 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -28,8 +28,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { if (strcasecmp(argv[0], "default") == 0) { container_set_layout(parent, parent->prev_layout); if (parent->layout == L_NONE) { - struct sway_container *output = container_parent(parent, C_OUTPUT); - container_set_layout(parent, container_get_default_layout(output)); + container_set_layout(parent, container_get_default_layout(parent)); } } else { if (parent->layout != L_TABBED && parent->layout != L_STACKED) { diff --git a/sway/tree/container.c b/sway/tree/container.c index a79bc22c..64b51db6 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -405,7 +405,7 @@ struct sway_container *container_workspace_create(struct sway_container *output, workspace->name = !name ? NULL : strdup(name); workspace->prev_layout = L_NONE; workspace->layout = container_get_default_layout(output); - workspace->workspace_layout = container_get_default_layout(output); + workspace->workspace_layout = workspace->layout; container_add_child(output, workspace); container_sort_workspaces(output); diff --git a/sway/tree/layout.c b/sway/tree/layout.c index dfcdbb9c..c3cdaae0 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -168,12 +168,22 @@ void container_move(struct sway_container *container, } enum sway_container_layout container_get_default_layout( - struct sway_container *output) { + struct sway_container *con) { + if (con->type != C_OUTPUT) { + con = container_parent(con, C_OUTPUT); + } + + if (!sway_assert(con != NULL, + "container_get_default_layout must be called on an attached " + " container below the root container")) { + return 0; + } + 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) { + } else if (con->width >= con->height) { return L_HORIZ; } else { return L_VERT; |