summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/container.h1
-rw-r--r--sway/commands.c45
-rw-r--r--sway/container.c3
3 files changed, 31 insertions, 18 deletions
diff --git a/include/container.h b/include/container.h
index d9f33b8a..29d4ea12 100644
--- a/include/container.h
+++ b/include/container.h
@@ -56,6 +56,7 @@ struct sway_container {
56 56
57 enum swayc_types type; 57 enum swayc_types type;
58 enum swayc_layouts layout; 58 enum swayc_layouts layout;
59 enum swayc_layouts prev_layout;
59 60
60 /** 61 /**
61 * Width and height of this container, without borders or gaps. 62 * Width and height of this container, without borders or gaps.
diff --git a/sway/commands.c b/sway/commands.c
index ce1fe8a3..ad5416f7 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1760,29 +1760,38 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
1760 } 1760 }
1761 1761
1762 if (strcasecmp(argv[0], "default") == 0) { 1762 if (strcasecmp(argv[0], "default") == 0) {
1763 swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT); 1763 parent->layout = parent->prev_layout;
1764 parent->layout = default_layout(output); 1764 if (parent->layout == L_NONE) {
1765 } else if (strcasecmp(argv[0], "tabbed") == 0) { 1765 swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT);
1766 if (parent->type != C_CONTAINER) { 1766 parent->layout = default_layout(output);
1767 parent = new_container(parent, L_TABBED);
1768 } 1767 }
1769 1768 } else {
1770 parent->layout = L_TABBED; 1769 if (parent->layout != L_TABBED && parent->layout != L_STACKED) {
1771 } else if (strcasecmp(argv[0], "stacking") == 0) { 1770 parent->prev_layout = parent->layout;
1772 if (parent->type != C_CONTAINER) {
1773 parent = new_container(parent, L_STACKED);
1774 } 1771 }
1775 1772
1776 parent->layout = L_STACKED; 1773 if (strcasecmp(argv[0], "tabbed") == 0) {
1777 } else if (strcasecmp(argv[0], "splith") == 0) { 1774 if (parent->type != C_CONTAINER) {
1778 parent->layout = L_HORIZ; 1775 parent = new_container(parent, L_TABBED);
1779 } else if (strcasecmp(argv[0], "splitv") == 0) { 1776 }
1780 parent->layout = L_VERT; 1777
1781 } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { 1778 parent->layout = L_TABBED;
1782 if (parent->layout == L_VERT) { 1779 } else if (strcasecmp(argv[0], "stacking") == 0) {
1780 if (parent->type != C_CONTAINER) {
1781 parent = new_container(parent, L_STACKED);
1782 }
1783
1784 parent->layout = L_STACKED;
1785 } else if (strcasecmp(argv[0], "splith") == 0) {
1783 parent->layout = L_HORIZ; 1786 parent->layout = L_HORIZ;
1784 } else { 1787 } else if (strcasecmp(argv[0], "splitv") == 0) {
1785 parent->layout = L_VERT; 1788 parent->layout = L_VERT;
1789 } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) {
1790 if (parent->layout == L_VERT) {
1791 parent->layout = L_HORIZ;
1792 } else {
1793 parent->layout = L_VERT;
1794 }
1786 } 1795 }
1787 } 1796 }
1788 1797
diff --git a/sway/container.c b/sway/container.c
index 5579fddb..42f6a69a 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -163,6 +163,7 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
163 sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle); 163 sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle);
164 swayc_t *workspace = new_swayc(C_WORKSPACE); 164 swayc_t *workspace = new_swayc(C_WORKSPACE);
165 165
166 workspace->prev_layout = L_NONE;
166 workspace->layout = default_layout(output); 167 workspace->layout = default_layout(output);
167 168
168 workspace->x = output->x; 169 workspace->x = output->x;
@@ -203,6 +204,7 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
203 204
204 sway_log(L_DEBUG, "creating container %p around %p", cont, child); 205 sway_log(L_DEBUG, "creating container %p around %p", cont, child);
205 206
207 cont->prev_layout = L_NONE;
206 cont->layout = layout; 208 cont->layout = layout;
207 cont->width = child->width; 209 cont->width = child->width;
208 cont->height = child->height; 210 cont->height = child->height;
@@ -229,6 +231,7 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
229 add_child(workspace, cont); 231 add_child(workspace, cont);
230 // give them proper layouts 232 // give them proper layouts
231 cont->layout = workspace->layout; 233 cont->layout = workspace->layout;
234 cont->prev_layout = workspace->prev_layout;
232 /* TODO: might break shit in move_container!!! workspace->layout = layout; */ 235 /* TODO: might break shit in move_container!!! workspace->layout = layout; */
233 set_focused_container_for(workspace, get_focused_view(workspace)); 236 set_focused_container_for(workspace, get_focused_view(workspace));
234 } else { // Or is built around container 237 } else { // Or is built around container