diff options
author | 2015-08-09 14:35:59 -0400 | |
---|---|---|
committer | 2015-08-09 14:35:59 -0400 | |
commit | ec2fedf6d0d4d101351bfa03a60beb02c90573fc (patch) | |
tree | 89783660d016779d4555b7d5975f7d1f8213a5b3 | |
parent | Load config after xwayland is created (diff) | |
download | sway-ec2fedf6d0d4d101351bfa03a60beb02c90573fc.tar.gz sway-ec2fedf6d0d4d101351bfa03a60beb02c90573fc.tar.zst sway-ec2fedf6d0d4d101351bfa03a60beb02c90573fc.zip |
Implement layout [splith|splitv|toggle split]
-rw-r--r-- | sway/commands.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c index 8030712e..33a5e485 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <unistd.h> | 7 | #include <unistd.h> |
8 | #include <ctype.h> | 8 | #include <ctype.h> |
9 | #include "stringop.h" | 9 | #include "stringop.h" |
10 | #include "layout.h" | ||
10 | #include "log.h" | 11 | #include "log.h" |
11 | #include "commands.h" | 12 | #include "commands.h" |
12 | 13 | ||
@@ -106,6 +107,31 @@ int cmd_focus_follows_mouse(struct sway_config *config, int argc, char **argv) { | |||
106 | return 0; | 107 | return 0; |
107 | } | 108 | } |
108 | 109 | ||
110 | int cmd_layout(struct sway_config *config, int argc, char **argv) { | ||
111 | if (argc < 1) { | ||
112 | sway_log(L_ERROR, "Invalid layout command (expected at least 1 argument, got %d)", argc); | ||
113 | return 1; | ||
114 | } | ||
115 | swayc_t *parent = get_focused_container(&root_container); | ||
116 | while (parent->type == C_VIEW) { | ||
117 | parent = parent->parent; | ||
118 | } | ||
119 | if (strcasecmp(argv[0], "splith") == 0) { | ||
120 | parent->layout = L_HORIZ; | ||
121 | } else if (strcasecmp(argv[0], "splitv") == 0) { | ||
122 | parent->layout = L_VERT; | ||
123 | } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { | ||
124 | if (parent->layout == L_VERT) { | ||
125 | parent->layout = L_HORIZ; | ||
126 | } else { | ||
127 | parent->layout = L_VERT; | ||
128 | } | ||
129 | } | ||
130 | arrange_windows(parent, parent->width, parent->height); | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
109 | int cmd_set(struct sway_config *config, int argc, char **argv) { | 135 | int cmd_set(struct sway_config *config, int argc, char **argv) { |
110 | if (argc != 2) { | 136 | if (argc != 2) { |
111 | sway_log(L_ERROR, "Invalid set command (expected 2 arguments, got %d)", argc); | 137 | sway_log(L_ERROR, "Invalid set command (expected 2 arguments, got %d)", argc); |
@@ -126,6 +152,7 @@ struct cmd_handler handlers[] = { | |||
126 | { "exec", cmd_exec }, | 152 | { "exec", cmd_exec }, |
127 | { "exit", cmd_exit }, | 153 | { "exit", cmd_exit }, |
128 | { "focus_follows_mouse", cmd_focus_follows_mouse }, | 154 | { "focus_follows_mouse", cmd_focus_follows_mouse }, |
155 | { "layout", cmd_layout }, | ||
129 | { "set", cmd_set }, | 156 | { "set", cmd_set }, |
130 | }; | 157 | }; |
131 | 158 | ||