mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 16:06:37 +01:00
Merge pull request #744 from thejan2009/tabbed-stacked-layout-fixes
Fix tabbed/stacked corner case #742
This commit is contained in:
commit
0374154749
4 changed files with 22 additions and 3 deletions
|
@ -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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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 (parent->type != C_CONTAINER) {
|
||||
if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)){
|
||||
parent = new_container(parent, L_TABBED);
|
||||
}
|
||||
|
||||
parent->layout = L_TABBED;
|
||||
} 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -740,6 +740,10 @@ bool swayc_is_child_of(swayc_t *child, swayc_t *parent) {
|
|||
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) {
|
||||
if (container->type == C_VIEW || container->type == C_CONTAINER) {
|
||||
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)) {
|
||||
return NULL;
|
||||
}
|
||||
while (view->type != C_WORKSPACE && view->parent) {
|
||||
while (view->type != C_WORKSPACE && view->parent && view->parent->type != C_WORKSPACE) {
|
||||
view = view->parent;
|
||||
if (view->layout == L_TABBED || view->layout == L_STACKED) {
|
||||
parent = view;
|
||||
|
|
|
@ -318,6 +318,16 @@ static bool handle_view_created(wlc_handle handle) {
|
|||
if (workspace && 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 {
|
||||
swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
|
||||
wlc_handle *h = malloc(sizeof(wlc_handle));
|
||||
|
|
Loading…
Reference in a new issue