From ef08ec6ca8e5346c5dafde8ba9af62a11570cbc6 Mon Sep 17 00:00:00 2001 From: "D.B" Date: Thu, 17 Nov 2016 06:49:12 +0100 Subject: [PATCH] fix layout switching (was broken because of workspace_layout) For workspace containers, swayc_change_layout also changes ->layout alongside ->workspace_layout when it's a sensible thing to do. There is an additional test for 'layout toggle' command which ensures that containers will be tiled horizontally after toggling from tabbed or stacked. --- include/sway/container.h | 2 +- sway/commands/layout.c | 2 +- sway/container.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/sway/container.h b/include/sway/container.h index 90825a49..2bedd136 100644 --- a/include/sway/container.h +++ b/include/sway/container.h @@ -324,7 +324,7 @@ void close_views(swayc_t *container); /** * Assign layout to a container. Needed due to workspace container specifics. - * Workspace always needs L_HORIZ layout. + * Workspace should always have either L_VERT or L_HORIZ layout. */ swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout); diff --git a/sway/commands/layout.c b/sway/commands/layout.c index bef06cb2..08336150 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -49,7 +49,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { } else if (strcasecmp(argv[0], "splitv") == 0) { swayc_change_layout(parent, L_VERT); } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { - if (parent->layout == L_HORIZ) { + if (parent->layout == L_HORIZ && (parent->workspace_layout == L_NONE || parent->workspace_layout == L_HORIZ)) { swayc_change_layout(parent, L_VERT); } else { swayc_change_layout(parent, L_HORIZ); diff --git a/sway/container.c b/sway/container.c index c588f3db..e5284200 100644 --- a/sway/container.c +++ b/sway/container.c @@ -950,6 +950,9 @@ swayc_t *swayc_tabbed_stacked_parent(swayc_t *con) { swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) { if (container->type == C_WORKSPACE) { container->workspace_layout = layout; + if (layout == L_HORIZ || layout == L_VERT) { + container->layout = layout; + } } else { container->layout = layout; }