aboutsummaryrefslogtreecommitdiff
path: root/sway/layout.c
diff options
context:
space:
mode:
authorD.B <thejan.2009@gmail.com>2016-10-23 13:19:02 +0200
committerDrew DeVault <sir@cmpwn.com>2016-12-04 08:31:34 -0500
commit4762bcb3b9a1b9043ce78c7765d4513b0c5da635 (patch)
tree3935a7c4e8c4f8c3fb920b0503aa0562d79636af /sway/layout.c
parent6fb4b6737a793672129bb621d48652cc5e42059e (diff)
wrap some views under workspaces
If workspace layout is set to tabbed or stacked, its C_VIEW children should get wrapped in a container. Alongside that, move_container was modified to retain previous functionality.
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sway/layout.c b/sway/layout.c
index b37b82da..ea4a680d 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -66,6 +66,9 @@ void add_child(swayc_t *parent, swayc_t *child) {
if (!parent->focused) {
parent->focused = child;
}
+ if (parent->type == C_WORKSPACE && child->type == C_VIEW && (parent->workspace_layout == L_TABBED || parent->workspace_layout == L_STACKED)) {
+ child = new_container(child, parent->workspace_layout);
+ }
}
void insert_child(swayc_t *parent, swayc_t *child, int index) {
@@ -80,6 +83,10 @@ void insert_child(swayc_t *parent, swayc_t *child, int index) {
if (!parent->focused) {
parent->focused = child;
}
+ if (parent->type == C_WORKSPACE && child->type == C_VIEW && (parent->workspace_layout == L_TABBED || parent->workspace_layout == L_STACKED)) {
+ child = new_container(child, parent->workspace_layout);
+ }
+
}
void add_floating(swayc_t *ws, swayc_t *child) {
@@ -255,6 +262,19 @@ void move_container(swayc_t *container, enum movement_direction dir) {
swayc_t *parent = container->parent;
swayc_t *child = container;
bool ascended = false;
+
+ // View is wrapped in intermediate container which is needed for displaying
+ // the titlebar. Moving only the view outside of its parent container would just
+ // wrap it again under worspace. There would effectively be no movement,
+ // just a change of wrapping container.
+ if (child->type == C_VIEW &&
+ parent->type == C_CONTAINER &&
+ parent->children->length == 1 &&
+ parent->parent->type == C_WORKSPACE) {
+ child = parent;
+ parent = parent->parent;
+ }
+
while (true) {
sway_log(L_DEBUG, "container:%p, parent:%p, child %p,",
container,parent,child);
@@ -348,6 +368,9 @@ void move_container(swayc_t *container, enum movement_direction dir) {
}
// Create container around workspace to insert child into
parent = new_container(parent, layout);
+ // Previous line set the resulting container's layout to
+ // workspace_layout. It should have been just layout.
+ parent->layout = parent->parent->layout;
}
ascended = true;
child = parent;