diff options
-rw-r--r-- | include/container.h | 5 | ||||
-rw-r--r-- | sway/commands.c | 4 | ||||
-rw-r--r-- | sway/container.c | 6 | ||||
-rw-r--r-- | sway/handlers.c | 10 |
4 files changed, 22 insertions, 3 deletions
diff --git a/include/container.h b/include/container.h index 50ca2bf5..6562a752 100644 --- a/include/container.h +++ b/include/container.h | |||
@@ -254,6 +254,11 @@ bool swayc_is_parent_of(swayc_t *parent, swayc_t *child); | |||
254 | bool swayc_is_child_of(swayc_t *child, swayc_t *parent); | 254 | bool swayc_is_child_of(swayc_t *child, swayc_t *parent); |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * Returns true if this container is an empty workspace. | ||
258 | */ | ||
259 | bool swayc_is_empty_workspace(swayc_t *container); | ||
260 | |||
261 | /** | ||
257 | * Returns the top most tabbed or stacked parent container. Returns NULL if | 262 | * Returns the top most tabbed or stacked parent container. Returns NULL if |
258 | * view is not in a tabbed/stacked layout. | 263 | * view is not in a tabbed/stacked layout. |
259 | */ | 264 | */ |
diff --git a/sway/commands.c b/sway/commands.c index 2248e1c7..871b3078 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1950,13 +1950,13 @@ static struct cmd_results *cmd_layout(int argc, char **argv) { | |||
1950 | } | 1950 | } |
1951 | 1951 | ||
1952 | if (strcasecmp(argv[0], "tabbed") == 0) { | 1952 | if (strcasecmp(argv[0], "tabbed") == 0) { |
1953 | if (parent->type != C_CONTAINER) { | 1953 | if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)){ |
1954 | parent = new_container(parent, L_TABBED); | 1954 | parent = new_container(parent, L_TABBED); |
1955 | } | 1955 | } |
1956 | 1956 | ||
1957 | parent->layout = L_TABBED; | 1957 | parent->layout = L_TABBED; |
1958 | } else if (strcasecmp(argv[0], "stacking") == 0) { | 1958 | } else if (strcasecmp(argv[0], "stacking") == 0) { |
1959 | if (parent->type != C_CONTAINER) { | 1959 | if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)) { |
1960 | parent = new_container(parent, L_STACKED); | 1960 | parent = new_container(parent, L_STACKED); |
1961 | } | 1961 | } |
1962 | 1962 | ||
diff --git a/sway/container.c b/sway/container.c index a7e46571..ae70a8ee 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -740,6 +740,10 @@ bool swayc_is_child_of(swayc_t *child, swayc_t *parent) { | |||
740 | return swayc_is_parent_of(parent, child); | 740 | return swayc_is_parent_of(parent, child); |
741 | } | 741 | } |
742 | 742 | ||
743 | bool swayc_is_empty_workspace(swayc_t *container) { | ||
744 | return container->type == C_WORKSPACE && container->children->length == 0; | ||
745 | } | ||
746 | |||
743 | int swayc_gap(swayc_t *container) { | 747 | int swayc_gap(swayc_t *container) { |
744 | if (container->type == C_VIEW || container->type == C_CONTAINER) { | 748 | if (container->type == C_VIEW || container->type == C_CONTAINER) { |
745 | return container->gaps >= 0 ? container->gaps : config->gaps_inner; | 749 | return container->gaps >= 0 ? container->gaps : config->gaps_inner; |
@@ -879,7 +883,7 @@ swayc_t *swayc_tabbed_stacked_parent(swayc_t *view) { | |||
879 | if (!ASSERT_NONNULL(view)) { | 883 | if (!ASSERT_NONNULL(view)) { |
880 | return NULL; | 884 | return NULL; |
881 | } | 885 | } |
882 | while (view->type != C_WORKSPACE && view->parent) { | 886 | while (view->type != C_WORKSPACE && view->parent && view->parent->type != C_WORKSPACE) { |
883 | view = view->parent; | 887 | view = view->parent; |
884 | if (view->layout == L_TABBED || view->layout == L_STACKED) { | 888 | if (view->layout == L_TABBED || view->layout == L_STACKED) { |
885 | parent = view; | 889 | parent = view; |
diff --git a/sway/handlers.c b/sway/handlers.c index 8f2f8a21..647f9771 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -318,6 +318,16 @@ static bool handle_view_created(wlc_handle handle) { | |||
318 | if (workspace && workspace->fullscreen) { | 318 | if (workspace && workspace->fullscreen) { |
319 | set_focused_container(workspace->fullscreen); | 319 | set_focused_container(workspace->fullscreen); |
320 | } | 320 | } |
321 | |||
322 | // if parent container is a workspace, newview its only child and | ||
323 | // layout is tabbed/stacked, add a container around newview | ||
324 | swayc_t *parent_container = newview->parent; | ||
325 | if (parent_container->type == C_WORKSPACE && parent_container->children->length == 1 && | ||
326 | (parent_container->layout == L_TABBED || parent_container->layout == L_STACKED)) { | ||
327 | swayc_t *container = new_container(newview, parent_container->layout); | ||
328 | set_focused_container(newview); | ||
329 | arrange_windows(container, -1, -1); | ||
330 | } | ||
321 | } else { | 331 | } else { |
322 | swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); | 332 | swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); |
323 | wlc_handle *h = malloc(sizeof(wlc_handle)); | 333 | wlc_handle *h = malloc(sizeof(wlc_handle)); |