diff options
author | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2016-04-01 21:39:15 +0200 |
---|---|---|
committer | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2016-04-25 00:00:49 +0200 |
commit | a0cebb7c5a0530414e85c85fb0231881f988df7c (patch) | |
tree | d2f58758747730cb79d5cc053b6b15300ea51fe8 | |
parent | Correctly determine default layout (diff) | |
download | sway-a0cebb7c5a0530414e85c85fb0231881f988df7c.tar.gz sway-a0cebb7c5a0530414e85c85fb0231881f988df7c.tar.zst sway-a0cebb7c5a0530414e85c85fb0231881f988df7c.zip |
Improve move command with tabbed/stacked layout
-rw-r--r-- | sway/debug_log.c | 1 | ||||
-rw-r--r-- | sway/layout.c | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sway/debug_log.c b/sway/debug_log.c index 761dca6c..f804a541 100644 --- a/sway/debug_log.c +++ b/sway/debug_log.c | |||
@@ -38,6 +38,7 @@ static void container_log(const swayc_t *c, int depth) { | |||
38 | c->layout == L_HORIZ ? "Horiz": | 38 | c->layout == L_HORIZ ? "Horiz": |
39 | c->layout == L_VERT ? "Vert": | 39 | c->layout == L_VERT ? "Vert": |
40 | c->layout == L_STACKED ? "Stack": | 40 | c->layout == L_STACKED ? "Stack": |
41 | c->layout == L_TABBED ? "Tab": | ||
41 | c->layout == L_FLOATING ? "Float": | 42 | c->layout == L_FLOATING ? "Float": |
42 | "Unknown"); | 43 | "Unknown"); |
43 | fprintf(stderr, "w:%4.f|h:%4.f|", c->width, c->height); | 44 | fprintf(stderr, "w:%4.f|h:%4.f|", c->width, c->height); |
diff --git a/sway/layout.c b/sway/layout.c index 261e2138..e9eb8add 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -244,7 +244,9 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
244 | while (true) { | 244 | while (true) { |
245 | sway_log(L_DEBUG, "container:%p, parent:%p, child %p,", | 245 | sway_log(L_DEBUG, "container:%p, parent:%p, child %p,", |
246 | container,parent,child); | 246 | container,parent,child); |
247 | if (parent->layout == layout) { | 247 | if (parent->layout == layout |
248 | || (parent->layout == L_TABBED && layout == L_HORIZ) | ||
249 | || (parent->layout == L_STACKED && layout == L_VERT)) { | ||
248 | int diff; | 250 | int diff; |
249 | // If it has ascended (parent has moved up), no container is removed | 251 | // If it has ascended (parent has moved up), no container is removed |
250 | // so insert it at index, or index+1. | 252 | // so insert it at index, or index+1. |
@@ -264,9 +266,11 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
264 | // Move container into sibling container | 266 | // Move container into sibling container |
265 | if (child->type == C_CONTAINER) { | 267 | if (child->type == C_CONTAINER) { |
266 | parent = child; | 268 | parent = child; |
267 | // Insert it in first/last if matching layout,otherwise | 269 | // Insert it in first/last if matching layout, otherwise |
268 | // inesrt it next to focused container | 270 | // inesrt it next to focused container |
269 | if (parent->layout == layout) { | 271 | if (parent->layout == layout |
272 | || (parent->layout == L_TABBED && layout == L_HORIZ) | ||
273 | || (parent->layout == L_STACKED && layout == L_VERT)) { | ||
270 | desired = (diff < 0) * parent->children->length; | 274 | desired = (diff < 0) * parent->children->length; |
271 | } else { | 275 | } else { |
272 | desired = index_child(child->focused); | 276 | desired = index_child(child->focused); |
@@ -300,7 +304,7 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
300 | parent = child->parent; | 304 | parent = child->parent; |
301 | } | 305 | } |
302 | // Dirty hack to fix a certain case | 306 | // Dirty hack to fix a certain case |
303 | arrange_windows(parent, -1, -1); | 307 | /* arrange_windows(parent, -1, -1); */ |
304 | arrange_windows(parent->parent, -1, -1); | 308 | arrange_windows(parent->parent, -1, -1); |
305 | set_focused_container_for(parent->parent, container); | 309 | set_focused_container_for(parent->parent, container); |
306 | } | 310 | } |