summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar D.B <thejan.2009@gmail.com>2016-10-23 13:19:02 +0200
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-12-04 08:31:34 -0500
commit4762bcb3b9a1b9043ce78c7765d4513b0c5da635 (patch)
tree3935a7c4e8c4f8c3fb920b0503aa0562d79636af
parentadd workspace_layout to container (diff)
downloadsway-4762bcb3b9a1b9043ce78c7765d4513b0c5da635.tar.gz
sway-4762bcb3b9a1b9043ce78c7765d4513b0c5da635.tar.zst
sway-4762bcb3b9a1b9043ce78c7765d4513b0c5da635.zip
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.
-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) {
66 if (!parent->focused) { 66 if (!parent->focused) {
67 parent->focused = child; 67 parent->focused = child;
68 } 68 }
69 if (parent->type == C_WORKSPACE && child->type == C_VIEW && (parent->workspace_layout == L_TABBED || parent->workspace_layout == L_STACKED)) {
70 child = new_container(child, parent->workspace_layout);
71 }
69} 72}
70 73
71void insert_child(swayc_t *parent, swayc_t *child, int index) { 74void 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) {
80 if (!parent->focused) { 83 if (!parent->focused) {
81 parent->focused = child; 84 parent->focused = child;
82 } 85 }
86 if (parent->type == C_WORKSPACE && child->type == C_VIEW && (parent->workspace_layout == L_TABBED || parent->workspace_layout == L_STACKED)) {
87 child = new_container(child, parent->workspace_layout);
88 }
89
83} 90}
84 91
85void add_floating(swayc_t *ws, swayc_t *child) { 92void add_floating(swayc_t *ws, swayc_t *child) {
@@ -255,6 +262,19 @@ void move_container(swayc_t *container, enum movement_direction dir) {
255 swayc_t *parent = container->parent; 262 swayc_t *parent = container->parent;
256 swayc_t *child = container; 263 swayc_t *child = container;
257 bool ascended = false; 264 bool ascended = false;
265
266 // View is wrapped in intermediate container which is needed for displaying
267 // the titlebar. Moving only the view outside of its parent container would just
268 // wrap it again under worspace. There would effectively be no movement,
269 // just a change of wrapping container.
270 if (child->type == C_VIEW &&
271 parent->type == C_CONTAINER &&
272 parent->children->length == 1 &&
273 parent->parent->type == C_WORKSPACE) {
274 child = parent;
275 parent = parent->parent;
276 }
277
258 while (true) { 278 while (true) {
259 sway_log(L_DEBUG, "container:%p, parent:%p, child %p,", 279 sway_log(L_DEBUG, "container:%p, parent:%p, child %p,",
260 container,parent,child); 280 container,parent,child);
@@ -348,6 +368,9 @@ void move_container(swayc_t *container, enum movement_direction dir) {
348 } 368 }
349 // Create container around workspace to insert child into 369 // Create container around workspace to insert child into
350 parent = new_container(parent, layout); 370 parent = new_container(parent, layout);
371 // Previous line set the resulting container's layout to
372 // workspace_layout. It should have been just layout.
373 parent->layout = parent->parent->layout;
351 } 374 }
352 ascended = true; 375 ascended = true;
353 child = parent; 376 child = parent;