aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree
diff options
context:
space:
mode:
authorLibravatar Ronan Pigott <rpigott@berkeley.edu>2020-10-25 14:20:11 -0700
committerLibravatar Tudor Brindus <me@tbrindus.ca>2020-12-20 00:58:42 -0500
commitece6a1d408456ade74c88dee7d4b9e0491f0bdaf (patch)
tree09f5a40a02347c927a91ab66da6c794cfd787c97 /sway/tree
parentRevert "commands/move: maintain workspace_layout when moving" (diff)
downloadsway-ece6a1d408456ade74c88dee7d4b9e0491f0bdaf.tar.gz
sway-ece6a1d408456ade74c88dee7d4b9e0491f0bdaf.tar.zst
sway-ece6a1d408456ade74c88dee7d4b9e0491f0bdaf.zip
Change workspace_layout to match i3 behavior
In i3, the workspace_layout command does not affect the workspace layout. Instead, new workspace level containers are wrapped in the desired layout and the workspace layout always defaults to the output orientation.
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c7
-rw-r--r--sway/tree/output.c3
-rw-r--r--sway/tree/view.c23
-rw-r--r--sway/tree/workspace.c34
4 files changed, 41 insertions, 26 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index b0d23700..23b6c997 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -804,9 +804,10 @@ void container_set_floating(struct sway_container *container, bool enable) {
804 container->width = reference->width; 804 container->width = reference->width;
805 container->height = reference->height; 805 container->height = reference->height;
806 } else { 806 } else {
807 workspace_add_tiling(workspace, container); 807 struct sway_container *other =
808 container->width = workspace->width; 808 workspace_add_tiling(workspace, container);
809 container->height = workspace->height; 809 other->width = workspace->width;
810 other->height = workspace->height;
810 } 811 }
811 if (container->view) { 812 if (container->view) {
812 view_set_tiled(container->view, true); 813 view_set_tiled(container->view, true);
diff --git a/sway/tree/output.c b/sway/tree/output.c
index f15a84b3..a8ae30f7 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -395,9 +395,6 @@ void output_get_box(struct sway_output *output, struct wlr_box *box) {
395 395
396enum sway_container_layout output_get_default_layout( 396enum sway_container_layout output_get_default_layout(
397 struct sway_output *output) { 397 struct sway_output *output) {
398 if (config->default_layout != L_NONE) {
399 return config->default_layout;
400 }
401 if (config->default_orientation != L_NONE) { 398 if (config->default_orientation != L_NONE) {
402 return config->default_orientation; 399 return config->default_orientation;
403 } 400 }
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 354f2d34..e690c334 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -732,10 +732,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
732 ws = seat_get_last_known_workspace(seat); 732 ws = seat_get_last_known_workspace(seat);
733 } 733 }
734 734
735 struct sway_container *container = view->container;
735 if (target_sibling) { 736 if (target_sibling) {
736 container_add_sibling(target_sibling, view->container, 1); 737 container_add_sibling(target_sibling, container, 1);
737 } else if (ws) { 738 } else if (ws) {
738 workspace_add_tiling(ws, view->container); 739 container = workspace_add_tiling(ws, container);
739 } 740 }
740 ipc_event_window(view->container, "new"); 741 ipc_event_window(view->container, "new");
741 742
@@ -759,26 +760,26 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
759 } 760 }
760 761
761 if (config->popup_during_fullscreen == POPUP_LEAVE && 762 if (config->popup_during_fullscreen == POPUP_LEAVE &&
762 view->container->workspace && 763 container->workspace &&
763 view->container->workspace->fullscreen && 764 container->workspace->fullscreen &&
764 view->container->workspace->fullscreen->view) { 765 container->workspace->fullscreen->view) {
765 struct sway_container *fs = view->container->workspace->fullscreen; 766 struct sway_container *fs = container->workspace->fullscreen;
766 if (view_is_transient_for(view, fs->view)) { 767 if (view_is_transient_for(view, fs->view)) {
767 container_set_fullscreen(fs, false); 768 container_set_fullscreen(fs, false);
768 } 769 }
769 } 770 }
770 771
771 view_update_title(view, false); 772 view_update_title(view, false);
772 container_update_representation(view->container); 773 container_update_representation(container);
773 774
774 if (fullscreen) { 775 if (fullscreen) {
775 container_set_fullscreen(view->container, true); 776 container_set_fullscreen(view->container, true);
776 arrange_workspace(view->container->workspace); 777 arrange_workspace(view->container->workspace);
777 } else { 778 } else {
778 if (view->container->parent) { 779 if (container->parent) {
779 arrange_container(view->container->parent); 780 arrange_container(container->parent);
780 } else if (view->container->workspace) { 781 } else if (container->workspace) {
781 arrange_workspace(view->container->workspace); 782 arrange_workspace(container->workspace);
782 } 783 }
783 } 784 }
784 785
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index ffcbe933..e40792ae 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -627,6 +627,21 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws,
627 return NULL; 627 return NULL;
628} 628}
629 629
630static void set_workspace(struct sway_container *container, void *data) {
631 container->workspace = container->parent->workspace;
632}
633
634static void workspace_attach_tiling(struct sway_workspace *ws,
635 struct sway_container *con) {
636 list_add(ws->tiling, con);
637 con->workspace = ws;
638 container_for_each_child(con, set_workspace, NULL);
639 container_handle_fullscreen_reparent(con);
640 workspace_update_representation(ws);
641 node_set_dirty(&ws->node);
642 node_set_dirty(&con->node);
643}
644
630struct sway_container *workspace_wrap_children(struct sway_workspace *ws) { 645struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
631 struct sway_container *fs = ws->fullscreen; 646 struct sway_container *fs = ws->fullscreen;
632 struct sway_container *middle = container_create(NULL); 647 struct sway_container *middle = container_create(NULL);
@@ -636,7 +651,7 @@ struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
636 container_detach(child); 651 container_detach(child);
637 container_add_child(middle, child); 652 container_add_child(middle, child);
638 } 653 }
639 workspace_add_tiling(ws, middle); 654 workspace_attach_tiling(ws, middle);
640 ws->fullscreen = fs; 655 ws->fullscreen = fs;
641 return middle; 656 return middle;
642} 657}
@@ -668,15 +683,14 @@ void workspace_detach(struct sway_workspace *workspace) {
668 node_set_dirty(&output->node); 683 node_set_dirty(&output->node);
669} 684}
670 685
671static void set_workspace(struct sway_container *container, void *data) { 686struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
672 container->workspace = container->parent->workspace;
673}
674
675void workspace_add_tiling(struct sway_workspace *workspace,
676 struct sway_container *con) { 687 struct sway_container *con) {
677 if (con->workspace) { 688 if (con->workspace) {
678 container_detach(con); 689 container_detach(con);
679 } 690 }
691 if (config->default_layout != L_NONE) {
692 con = container_split(con, config->default_layout);
693 }
680 list_add(workspace->tiling, con); 694 list_add(workspace->tiling, con);
681 con->workspace = workspace; 695 con->workspace = workspace;
682 container_for_each_child(con, set_workspace, NULL); 696 container_for_each_child(con, set_workspace, NULL);
@@ -684,6 +698,7 @@ void workspace_add_tiling(struct sway_workspace *workspace,
684 workspace_update_representation(workspace); 698 workspace_update_representation(workspace);
685 node_set_dirty(&workspace->node); 699 node_set_dirty(&workspace->node);
686 node_set_dirty(&con->node); 700 node_set_dirty(&con->node);
701 return con;
687} 702}
688 703
689void workspace_add_floating(struct sway_workspace *workspace, 704void workspace_add_floating(struct sway_workspace *workspace,
@@ -699,13 +714,13 @@ void workspace_add_floating(struct sway_workspace *workspace,
699 node_set_dirty(&con->node); 714 node_set_dirty(&con->node);
700} 715}
701 716
702void workspace_insert_tiling(struct sway_workspace *workspace, 717struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
703 struct sway_container *con, int index) { 718 struct sway_container *con, int index) {
704 if (con->workspace) { 719 if (con->workspace) {
705 container_detach(con); 720 container_detach(con);
706 } 721 }
707 if (workspace->layout == L_STACKED || workspace->layout == L_TABBED) { 722 if (config->default_layout != L_NONE) {
708 con = container_split(con, workspace->layout); 723 con = container_split(con, config->default_layout);
709 } 724 }
710 list_insert(workspace->tiling, index, con); 725 list_insert(workspace->tiling, index, con);
711 con->workspace = workspace; 726 con->workspace = workspace;
@@ -714,6 +729,7 @@ void workspace_insert_tiling(struct sway_workspace *workspace,
714 workspace_update_representation(workspace); 729 workspace_update_representation(workspace);
715 node_set_dirty(&workspace->node); 730 node_set_dirty(&workspace->node);
716 node_set_dirty(&con->node); 731 node_set_dirty(&con->node);
732 return con;
717} 733}
718 734
719void workspace_add_gaps(struct sway_workspace *ws) { 735void workspace_add_gaps(struct sway_workspace *ws) {