diff options
-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, | |||
55 | void container_move(struct sway_container *container, | 55 | void container_move(struct sway_container *container, |
56 | enum movement_direction dir, int move_amt); | 56 | enum movement_direction dir, int move_amt); |
57 | 57 | ||
58 | // TODO move to output.c | ||
59 | enum sway_container_layout container_get_default_layout( | 58 | enum sway_container_layout container_get_default_layout( |
60 | struct sway_container *output); | 59 | struct sway_container *con); |
61 | 60 | ||
62 | // TODO move to output.c | 61 | // TODO move to output.c |
63 | void container_sort_workspaces(struct sway_container *output); | 62 | 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) { | |||
28 | if (strcasecmp(argv[0], "default") == 0) { | 28 | if (strcasecmp(argv[0], "default") == 0) { |
29 | container_set_layout(parent, parent->prev_layout); | 29 | container_set_layout(parent, parent->prev_layout); |
30 | if (parent->layout == L_NONE) { | 30 | if (parent->layout == L_NONE) { |
31 | struct sway_container *output = container_parent(parent, C_OUTPUT); | 31 | container_set_layout(parent, container_get_default_layout(parent)); |
32 | container_set_layout(parent, container_get_default_layout(output)); | ||
33 | } | 32 | } |
34 | } else { | 33 | } else { |
35 | if (parent->layout != L_TABBED && parent->layout != L_STACKED) { | 34 | 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, | |||
405 | workspace->name = !name ? NULL : strdup(name); | 405 | workspace->name = !name ? NULL : strdup(name); |
406 | workspace->prev_layout = L_NONE; | 406 | workspace->prev_layout = L_NONE; |
407 | workspace->layout = container_get_default_layout(output); | 407 | workspace->layout = container_get_default_layout(output); |
408 | workspace->workspace_layout = container_get_default_layout(output); | 408 | workspace->workspace_layout = workspace->layout; |
409 | 409 | ||
410 | container_add_child(output, workspace); | 410 | container_add_child(output, workspace); |
411 | container_sort_workspaces(output); | 411 | 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, | |||
168 | } | 168 | } |
169 | 169 | ||
170 | enum sway_container_layout container_get_default_layout( | 170 | enum sway_container_layout container_get_default_layout( |
171 | struct sway_container *output) { | 171 | struct sway_container *con) { |
172 | if (con->type != C_OUTPUT) { | ||
173 | con = container_parent(con, C_OUTPUT); | ||
174 | } | ||
175 | |||
176 | if (!sway_assert(con != NULL, | ||
177 | "container_get_default_layout must be called on an attached " | ||
178 | " container below the root container")) { | ||
179 | return 0; | ||
180 | } | ||
181 | |||
172 | if (config->default_layout != L_NONE) { | 182 | if (config->default_layout != L_NONE) { |
173 | return config->default_layout; | 183 | return config->default_layout; |
174 | } else if (config->default_orientation != L_NONE) { | 184 | } else if (config->default_orientation != L_NONE) { |
175 | return config->default_orientation; | 185 | return config->default_orientation; |
176 | } else if (output->width >= output->height) { | 186 | } else if (con->width >= con->height) { |
177 | return L_HORIZ; | 187 | return L_HORIZ; |
178 | } else { | 188 | } else { |
179 | return L_VERT; | 189 | return L_VERT; |