clean up container_get_default_layout

master
Tony Crisci 7 years ago
parent 065887bb7b
commit 9b567fc37e

@ -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);

@ -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) {

@ -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);

@ -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;

Loading…
Cancel
Save