summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-02 15:40:40 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-02 15:40:40 -0400
commitd070244362f7d34bc15418154e52f8c968fbad41 (patch)
tree6817e56203e5241d4a3231b231f4e2cbe567b51d
parentaddress feedback (diff)
downloadsway-d070244362f7d34bc15418154e52f8c968fbad41.tar.gz
sway-d070244362f7d34bc15418154e52f8c968fbad41.tar.zst
sway-d070244362f7d34bc15418154e52f8c968fbad41.zip
fix workspace splits
-rw-r--r--sway/commands/split.c25
-rw-r--r--sway/tree/layout.c38
2 files changed, 23 insertions, 40 deletions
diff --git a/sway/commands/split.c b/sway/commands/split.c
index fe4013e9..ca116aef 100644
--- a/sway/commands/split.c
+++ b/sway/commands/split.c
@@ -25,29 +25,8 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) {
25 } 25 }
26 26
27 struct sway_container *focused = config->handler_context.current_container; 27 struct sway_container *focused = config->handler_context.current_container;
28 28 struct sway_container *parent = container_split(focused, layout);
29 // TODO floating: dont split 29 arrange_windows(parent, -1, -1);
30
31 /* Case that focus is on an workspace with 0/1 children.change its layout */
32 if (focused->type == C_WORKSPACE && focused->children->length <= 1) {
33 wlr_log(L_DEBUG, "changing workspace layout");
34 container_set_layout(focused, layout);
35 } else if (focused->type != C_WORKSPACE &&
36 focused->parent->children->length == 1) {
37 /* Case of no siblings. change parent layout */
38 wlr_log(L_DEBUG, "changing container layout");
39 container_set_layout(focused->parent, layout);
40 } else {
41 // regular case where new split container is build around focused
42 // container or in case of workspace, container inherits its children
43 wlr_log(L_DEBUG,
44 "Adding new container around current focused container");
45 wlr_log(L_INFO, "FOCUSED SIZE: %.f %.f",
46 focused->width, focused->height);
47
48 struct sway_container *parent = container_split(focused, layout);
49 arrange_windows(parent, -1, -1);
50 }
51 30
52 // TODO borders: update borders 31 // TODO borders: update borders
53 32
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index e13c2ac4..bea15f8a 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -405,7 +405,12 @@ void apply_vert_layout(struct sway_container *container,
405 wlr_log(L_DEBUG, 405 wlr_log(L_DEBUG,
406 "Calculating arrangement for %p:%d (will scale %f by %f)", 406 "Calculating arrangement for %p:%d (will scale %f by %f)",
407 child, child->type, height, scale); 407 child, child->type, height, scale);
408 view_set_position(child->sway_view, x, child_y); 408 if (child->type == C_VIEW) {
409 view_set_position(child->sway_view, x, child_y);
410 } else {
411 child->x = x;
412 child->y = child_y;
413 }
409 414
410 if (i == end - 1) { 415 if (i == end - 1) {
411 double remaining_height = y + height - child_y; 416 double remaining_height = y + height - child_y;
@@ -691,34 +696,33 @@ struct sway_container *container_split(struct sway_container *child,
691 wlr_log(L_DEBUG, "creating container %p around %p", cont, child); 696 wlr_log(L_DEBUG, "creating container %p around %p", cont, child);
692 697
693 cont->prev_layout = L_NONE; 698 cont->prev_layout = L_NONE;
694 cont->layout = layout;
695 cont->width = child->width; 699 cont->width = child->width;
696 cont->height = child->height; 700 cont->height = child->height;
697 cont->x = child->x; 701 cont->x = child->x;
698 cont->y = child->y; 702 cont->y = child->y;
699 703
700 /* Container inherits all of workspaces children, layout and whatnot */
701 if (child->type == C_WORKSPACE) { 704 if (child->type == C_WORKSPACE) {
705 struct sway_seat *seat = sway_input_manager_get_default_seat(input_manager);
702 struct sway_container *workspace = child; 706 struct sway_container *workspace = child;
703 // reorder focus 707 bool set_focus = (sway_seat_get_focus(seat) == workspace);
704 int i; 708
705 for (i = 0; i < workspace->children->length; ++i) { 709 while (workspace->children->length) {
706 ((struct sway_container *)workspace->children->items[i])->parent = 710 struct sway_container *ws_child = workspace->children->items[0];
707 cont; 711 container_remove_child(ws_child);
712 container_add_child(cont, ws_child);
708 } 713 }
709 714
710 // Swap children
711 list_t *tmp_list = workspace->children;
712 workspace->children = cont->children;
713 cont->children = tmp_list;
714 // add container to workspace chidren
715 container_add_child(workspace, cont); 715 container_add_child(workspace, cont);
716 // give them proper layouts 716 container_set_layout(workspace, layout);
717 cont->layout = workspace->workspace_layout; 717
718 cont->prev_layout = workspace->prev_layout; 718 if (set_focus) {
719 } else { // Or is built around container 719 sway_seat_set_focus(seat, cont);
720 }
721 } else {
722 cont->layout = layout;
720 container_replace_child(child, cont); 723 container_replace_child(child, cont);
721 container_add_child(cont, child); 724 container_add_child(cont, child);
722 } 725 }
726
723 return cont; 727 return cont;
724} 728}