summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 11284577..34364917 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1,6 +1,7 @@
1#include <xkbcommon/xkbcommon.h> 1#include <xkbcommon/xkbcommon.h>
2#include <xkbcommon/xkbcommon-names.h> 2#include <xkbcommon/xkbcommon-names.h>
3#include <wlc/wlc.h> 3#include <wlc/wlc.h>
4#include <wlc/wlc-render.h>
4#include <stdio.h> 5#include <stdio.h>
5#include <stdlib.h> 6#include <stdlib.h>
6#include <errno.h> 7#include <errno.h>
@@ -1759,17 +1760,46 @@ static struct cmd_results *cmd_layout(int argc, char **argv) {
1759 parent = parent->parent; 1760 parent = parent->parent;
1760 } 1761 }
1761 1762
1762 if (strcasecmp(argv[0], "splith") == 0) { 1763 enum swayc_layouts old_layout = parent->layout;
1763 parent->layout = L_HORIZ; 1764
1764 } else if (strcasecmp(argv[0], "splitv") == 0) { 1765 if (strcasecmp(argv[0], "default") == 0) {
1765 parent->layout = L_VERT; 1766 parent->layout = parent->prev_layout;
1766 } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { 1767 if (parent->layout == L_NONE) {
1767 if (parent->layout == L_VERT) { 1768 swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT);
1769 parent->layout = default_layout(output);
1770 }
1771 } else {
1772 if (parent->layout != L_TABBED && parent->layout != L_STACKED) {
1773 parent->prev_layout = parent->layout;
1774 }
1775
1776 if (strcasecmp(argv[0], "tabbed") == 0) {
1777 if (parent->type != C_CONTAINER) {
1778 parent = new_container(parent, L_TABBED);
1779 }
1780
1781 parent->layout = L_TABBED;
1782 } else if (strcasecmp(argv[0], "stacking") == 0) {
1783 if (parent->type != C_CONTAINER) {
1784 parent = new_container(parent, L_STACKED);
1785 }
1786
1787 parent->layout = L_STACKED;
1788 } else if (strcasecmp(argv[0], "splith") == 0) {
1768 parent->layout = L_HORIZ; 1789 parent->layout = L_HORIZ;
1769 } else { 1790 } else if (strcasecmp(argv[0], "splitv") == 0) {
1770 parent->layout = L_VERT; 1791 parent->layout = L_VERT;
1792 } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) {
1793 if (parent->layout == L_VERT) {
1794 parent->layout = L_HORIZ;
1795 } else {
1796 parent->layout = L_VERT;
1797 }
1771 } 1798 }
1772 } 1799 }
1800
1801 update_layout_geometry(parent, old_layout);
1802
1773 arrange_windows(parent, parent->width, parent->height); 1803 arrange_windows(parent, parent->width, parent->height);
1774 1804
1775 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 1805 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
@@ -2007,10 +2037,22 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) {
2007 /* regular case where new split container is build around focused container 2037 /* regular case where new split container is build around focused container
2008 * or in case of workspace, container inherits its children */ 2038 * or in case of workspace, container inherits its children */
2009 sway_log(L_DEBUG, "Adding new container around current focused container"); 2039 sway_log(L_DEBUG, "Adding new container around current focused container");
2040 sway_log(L_INFO, "FOCUSED SIZE: %.f %.f", focused->width, focused->height);
2010 swayc_t *parent = new_container(focused, layout); 2041 swayc_t *parent = new_container(focused, layout);
2011 set_focused_container(focused); 2042 set_focused_container(focused);
2012 arrange_windows(parent, -1, -1); 2043 arrange_windows(parent, -1, -1);
2013 } 2044 }
2045
2046 // update container title if tabbed/stacked
2047 if (swayc_tabbed_stacked_parent(focused)) {
2048 update_view_border(focused);
2049 swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
2050 // schedule render to make changes take effect right away,
2051 // otherwise we would have to wait for the view to render,
2052 // which is unpredictable.
2053 wlc_output_schedule_render(output->handle);
2054 }
2055
2014 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 2056 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
2015} 2057}
2016 2058