diff options
author | Ryan Dwyer <RyanDwyer@users.noreply.github.com> | 2018-05-30 11:53:20 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-30 11:53:20 +1000 |
commit | 536773e3a1dab6662d371f0f7ee462a4802ae6df (patch) | |
tree | 62668d1e573c2b7a898b39abf8c8f6cacf2d4367 | |
parent | Merge pull request #2069 from RyanDwyer/ipc-workspace-representation (diff) | |
parent | Send IPC layout of node itself (diff) | |
download | sway-536773e3a1dab6662d371f0f7ee462a4802ae6df.tar.gz sway-536773e3a1dab6662d371f0f7ee462a4802ae6df.tar.zst sway-536773e3a1dab6662d371f0f7ee462a4802ae6df.zip |
Merge pull request #2065 from RedSoxFan/fix-2018
Fix #2018 - Moving containers out of tabs/stacks
-rw-r--r-- | sway/ipc-json.c | 5 | ||||
-rw-r--r-- | sway/tree/layout.c | 44 |
2 files changed, 43 insertions, 6 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 0233a36e..03582950 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -160,11 +160,8 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
160 | json_object_object_add(object, "type", json_object_new_string("con")); | 160 | json_object_object_add(object, "type", json_object_new_string("con")); |
161 | 161 | ||
162 | if (c->parent) { | 162 | if (c->parent) { |
163 | enum sway_container_layout layout = (c->parent->type == C_CONTAINER) ? | ||
164 | c->parent->layout : c->layout; | ||
165 | |||
166 | json_object_object_add(object, "layout", | 163 | json_object_object_add(object, "layout", |
167 | json_object_new_string(ipc_json_layout_description(layout))); | 164 | json_object_new_string(ipc_json_layout_description(c->layout))); |
168 | } | 165 | } |
169 | } | 166 | } |
170 | 167 | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 1507eba9..9594b75a 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -309,6 +309,31 @@ static void workspace_rejigger(struct sway_container *ws, | |||
309 | arrange_workspace(ws); | 309 | arrange_workspace(ws); |
310 | } | 310 | } |
311 | 311 | ||
312 | static void move_out_of_tabs_stacks(struct sway_container *container, | ||
313 | struct sway_container *current, enum movement_direction move_dir, | ||
314 | int offs) { | ||
315 | wlr_log(L_DEBUG, "Moving out of tab/stack into a split"); | ||
316 | bool is_workspace = current->parent->type == C_WORKSPACE; | ||
317 | struct sway_container *old_parent = current->parent->parent; | ||
318 | struct sway_container *new_parent = container_split(current->parent, | ||
319 | move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT); | ||
320 | if (is_workspace) { | ||
321 | container_insert_child(new_parent->parent, container, offs < 0 ? 0 : 1); | ||
322 | } else { | ||
323 | container_insert_child(new_parent, container, offs < 0 ? 0 : 1); | ||
324 | container_reap_empty_recursive(new_parent->parent); | ||
325 | container_flatten(new_parent->parent); | ||
326 | } | ||
327 | wl_signal_emit(&container->events.reparent, old_parent); | ||
328 | container_create_notify(new_parent); | ||
329 | if (is_workspace) { | ||
330 | arrange_workspace(new_parent->parent); | ||
331 | } else { | ||
332 | arrange_children_of(new_parent); | ||
333 | } | ||
334 | container_notify_subtree_changed(new_parent); | ||
335 | } | ||
336 | |||
312 | void container_move(struct sway_container *container, | 337 | void container_move(struct sway_container *container, |
313 | enum movement_direction move_dir, int move_amt) { | 338 | enum movement_direction move_dir, int move_amt) { |
314 | if (!sway_assert( | 339 | if (!sway_assert( |
@@ -390,6 +415,10 @@ void container_move(struct sway_container *container, | |||
390 | arrange_workspace(current); | 415 | arrange_workspace(current); |
391 | } | 416 | } |
392 | return; | 417 | return; |
418 | } else if (current->layout == L_TABBED | ||
419 | || current->layout == L_STACKED) { | ||
420 | wlr_log(L_DEBUG, "Rejiggering out of tabs/stacks"); | ||
421 | workspace_rejigger(current, container, move_dir); | ||
393 | } else { | 422 | } else { |
394 | wlr_log(L_DEBUG, "Selecting output"); | 423 | wlr_log(L_DEBUG, "Selecting output"); |
395 | current = current->parent; | 424 | current = current->parent; |
@@ -401,8 +430,15 @@ void container_move(struct sway_container *container, | |||
401 | if ((index == parent->children->length - 1 && offs > 0) | 430 | if ((index == parent->children->length - 1 && offs > 0) |
402 | || (index == 0 && offs < 0)) { | 431 | || (index == 0 && offs < 0)) { |
403 | if (current->parent == container->parent) { | 432 | if (current->parent == container->parent) { |
404 | wlr_log(L_DEBUG, "Hit limit, selecting parent"); | 433 | if (parent->layout == L_TABBED |
405 | current = current->parent; | 434 | || parent->layout == L_STACKED) { |
435 | move_out_of_tabs_stacks(container, current, | ||
436 | move_dir, offs); | ||
437 | return; | ||
438 | } else { | ||
439 | wlr_log(L_DEBUG, "Hit limit, selecting parent"); | ||
440 | current = current->parent; | ||
441 | } | ||
406 | } else { | 442 | } else { |
407 | wlr_log(L_DEBUG, "Hit limit, " | 443 | wlr_log(L_DEBUG, "Hit limit, " |
408 | "promoting descendant to sibling"); | 444 | "promoting descendant to sibling"); |
@@ -419,6 +455,10 @@ void container_move(struct sway_container *container, | |||
419 | sibling = parent->children->items[index + offs]; | 455 | sibling = parent->children->items[index + offs]; |
420 | wlr_log(L_DEBUG, "Selecting sibling id:%zd", sibling->id); | 456 | wlr_log(L_DEBUG, "Selecting sibling id:%zd", sibling->id); |
421 | } | 457 | } |
458 | } else if (parent->layout == L_TABBED | ||
459 | || parent->layout == L_STACKED) { | ||
460 | move_out_of_tabs_stacks(container, current, move_dir, offs); | ||
461 | return; | ||
422 | } else { | 462 | } else { |
423 | wlr_log(L_DEBUG, "Moving up to find a parallel container"); | 463 | wlr_log(L_DEBUG, "Moving up to find a parallel container"); |
424 | current = current->parent; | 464 | current = current->parent; |