Fix tabbed/stacked corner case #742
Tabbed/stacked containers are now created only if a view is present on the workspace. If a view is created on previously empty tabbed/stacked workspace, it gets wrapped in a container.
This commit is contained in:
parent
378149b59c
commit
ee67cd0ba1
|
@ -253,6 +253,11 @@ bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
|
||||||
*/
|
*/
|
||||||
bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
|
bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this container is an empty workspace.
|
||||||
|
*/
|
||||||
|
bool swayc_is_empty_workspace(swayc_t *container);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the top most tabbed or stacked parent container. Returns NULL if
|
* Returns the top most tabbed or stacked parent container. Returns NULL if
|
||||||
* view is not in a tabbed/stacked layout.
|
* view is not in a tabbed/stacked layout.
|
||||||
|
|
|
@ -1950,13 +1950,13 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp(argv[0], "tabbed") == 0) {
|
if (strcasecmp(argv[0], "tabbed") == 0) {
|
||||||
if (parent->type != C_CONTAINER) {
|
if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)){
|
||||||
parent = new_container(parent, L_TABBED);
|
parent = new_container(parent, L_TABBED);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent->layout = L_TABBED;
|
parent->layout = L_TABBED;
|
||||||
} else if (strcasecmp(argv[0], "stacking") == 0) {
|
} else if (strcasecmp(argv[0], "stacking") == 0) {
|
||||||
if (parent->type != C_CONTAINER) {
|
if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)) {
|
||||||
parent = new_container(parent, L_STACKED);
|
parent = new_container(parent, L_STACKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -740,6 +740,10 @@ bool swayc_is_child_of(swayc_t *child, swayc_t *parent) {
|
||||||
return swayc_is_parent_of(parent, child);
|
return swayc_is_parent_of(parent, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool swayc_is_empty_workspace(swayc_t *container) {
|
||||||
|
return container->type == C_WORKSPACE && container->children->length == 0;
|
||||||
|
}
|
||||||
|
|
||||||
int swayc_gap(swayc_t *container) {
|
int swayc_gap(swayc_t *container) {
|
||||||
if (container->type == C_VIEW || container->type == C_CONTAINER) {
|
if (container->type == C_VIEW || container->type == C_CONTAINER) {
|
||||||
return container->gaps >= 0 ? container->gaps : config->gaps_inner;
|
return container->gaps >= 0 ? container->gaps : config->gaps_inner;
|
||||||
|
@ -879,7 +883,7 @@ swayc_t *swayc_tabbed_stacked_parent(swayc_t *view) {
|
||||||
if (!ASSERT_NONNULL(view)) {
|
if (!ASSERT_NONNULL(view)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while (view->type != C_WORKSPACE && view->parent) {
|
while (view->type != C_WORKSPACE && view->parent && view->parent->type != C_WORKSPACE) {
|
||||||
view = view->parent;
|
view = view->parent;
|
||||||
if (view->layout == L_TABBED || view->layout == L_STACKED) {
|
if (view->layout == L_TABBED || view->layout == L_STACKED) {
|
||||||
parent = view;
|
parent = view;
|
||||||
|
|
|
@ -318,6 +318,16 @@ static bool handle_view_created(wlc_handle handle) {
|
||||||
if (workspace && workspace->fullscreen) {
|
if (workspace && workspace->fullscreen) {
|
||||||
set_focused_container(workspace->fullscreen);
|
set_focused_container(workspace->fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if parent container is a workspace, newview its only child and
|
||||||
|
// layout is tabbed/stacked, add a container around newview
|
||||||
|
swayc_t *parent_container = newview->parent;
|
||||||
|
if (parent_container->type == C_WORKSPACE && parent_container->children->length == 1 &&
|
||||||
|
(parent_container->layout == L_TABBED || parent_container->layout == L_STACKED)) {
|
||||||
|
swayc_t *container = new_container(newview, parent_container->layout);
|
||||||
|
set_focused_container(newview);
|
||||||
|
arrange_windows(container, -1, -1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
|
swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
|
||||||
wlc_handle *h = malloc(sizeof(wlc_handle));
|
wlc_handle *h = malloc(sizeof(wlc_handle));
|
||||||
|
|
Loading…
Reference in a new issue