aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Nate Symer <nate@symer.io>2018-06-09 09:34:56 -0400
committerLibravatar Nate Symer <nate@symer.io>2018-06-09 09:34:56 -0400
commit6a910b9ba5443aa31f7cc2468c943c2f9da4854b (patch)
tree24e4ea6634a734ed303c7aaf611df682adbf746c
parentMerge pull request #2123 from emersion/fix-disabled-outputs (diff)
downloadsway-6a910b9ba5443aa31f7cc2468c943c2f9da4854b.tar.gz
sway-6a910b9ba5443aa31f7cc2468c943c2f9da4854b.tar.zst
sway-6a910b9ba5443aa31f7cc2468c943c2f9da4854b.zip
Implement gaps (PR #2047)
-rw-r--r--include/sway/tree/arrange.h6
-rw-r--r--include/sway/tree/container.h7
-rw-r--r--sway/commands.c3
-rw-r--r--sway/commands/gaps.c183
-rw-r--r--sway/commands/smart_gaps.c28
-rw-r--r--sway/meson.build2
-rw-r--r--sway/tree/arrange.c88
-rw-r--r--sway/tree/container.c5
-rw-r--r--sway/tree/layout.c7
9 files changed, 320 insertions, 9 deletions
diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h
index ce95cfe9..a14bc5dc 100644
--- a/include/sway/tree/arrange.h
+++ b/include/sway/tree/arrange.h
@@ -3,6 +3,12 @@
3 3
4struct sway_container; 4struct sway_container;
5 5
6// Remove gaps around container
7void remove_gaps(struct sway_container *c);
8
9// Add gaps around container
10void add_gaps(struct sway_container *c);
11
6// Determine the root container's geometry, then iterate to everything below 12// Determine the root container's geometry, then iterate to everything below
7void arrange_root(void); 13void arrange_root(void);
8 14
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 7ed6aab1..b3406bbe 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -86,6 +86,13 @@ struct sway_container {
86 double saved_x, saved_y; 86 double saved_x, saved_y;
87 double saved_width, saved_height; 87 double saved_width, saved_height;
88 88
89 // The gaps currently applied to the container.
90 double current_gaps;
91
92 bool has_gaps;
93 double gaps_inner;
94 double gaps_outer;
95
89 list_t *children; 96 list_t *children;
90 97
91 struct sway_container *parent; 98 struct sway_container *parent;
diff --git a/sway/commands.c b/sway/commands.c
index 1523fdd1..5b20857a 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -105,6 +105,8 @@ static struct cmd_handler handlers[] = {
105 { "font", cmd_font }, 105 { "font", cmd_font },
106 { "for_window", cmd_for_window }, 106 { "for_window", cmd_for_window },
107 { "force_focus_wrapping", cmd_force_focus_wrapping }, 107 { "force_focus_wrapping", cmd_force_focus_wrapping },
108 { "fullscreen", cmd_fullscreen },
109 { "gaps", cmd_gaps },
108 { "hide_edge_borders", cmd_hide_edge_borders }, 110 { "hide_edge_borders", cmd_hide_edge_borders },
109 { "include", cmd_include }, 111 { "include", cmd_include },
110 { "input", cmd_input }, 112 { "input", cmd_input },
@@ -114,6 +116,7 @@ static struct cmd_handler handlers[] = {
114 { "seat", cmd_seat }, 116 { "seat", cmd_seat },
115 { "set", cmd_set }, 117 { "set", cmd_set },
116 { "show_marks", cmd_show_marks }, 118 { "show_marks", cmd_show_marks },
119 { "smart_gaps", cmd_smart_gaps },
117 { "workspace", cmd_workspace }, 120 { "workspace", cmd_workspace },
118 { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, 121 { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth },
119}; 122};
diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c
new file mode 100644
index 00000000..aacb792b
--- /dev/null
+++ b/sway/commands/gaps.c
@@ -0,0 +1,183 @@
1#include <string.h>
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "sway/tree/arrange.h"
5#include "log.h"
6#include "stringop.h"
7#include <math.h>
8
9enum gaps_op {
10 GAPS_OP_SET,
11 GAPS_OP_ADD,
12 GAPS_OP_SUBTRACT
13};
14
15enum gaps_scope {
16 GAPS_SCOPE_ALL,
17 GAPS_SCOPE_WORKSPACE,
18 GAPS_SCOPE_CURRENT
19};
20
21struct cmd_results *cmd_gaps(int argc, char **argv) {
22 struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1);
23 if (error) {
24 return error;
25 }
26
27 if (strcmp(argv[0], "edge_gaps") == 0) {
28 if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 2))) {
29 return error;
30 }
31
32 if (strcmp(argv[1], "on") == 0) {
33 config->edge_gaps = true;
34 arrange_root();
35 } else if (strcmp(argv[1], "off") == 0) {
36 config->edge_gaps = false;
37 arrange_root();
38 } else if (strcmp(argv[1], "toggle") == 0) {
39 if (!config->active) {
40 return cmd_results_new(CMD_INVALID, "gaps",
41 "Cannot toggle gaps while not running.");
42 }
43 config->edge_gaps = !config->edge_gaps;
44 arrange_root();
45 } else {
46 return cmd_results_new(CMD_INVALID, "gaps",
47 "gaps edge_gaps on|off|toggle");
48 }
49 } else {
50 int amount_idx = 0; // the current index in argv
51 enum gaps_op op = GAPS_OP_SET;
52 enum gaps_scope scope = GAPS_SCOPE_ALL;
53 bool inner = true;
54
55 if (strcmp(argv[0], "inner") == 0) {
56 amount_idx++;
57 inner = true;
58 } else if (strcmp(argv[0], "outer") == 0) {
59 amount_idx++;
60 inner = false;
61 }
62
63 // If one of the long variants of the gaps command is used
64 // (which starts with inner|outer) check the number of args
65 if (amount_idx > 0) { // if we've seen inner|outer
66 if (argc > 2) { // check the longest variant
67 error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 4);
68 if (error) {
69 return error;
70 }
71 } else { // check the next longest format
72 error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 2);
73 if (error) {
74 return error;
75 }
76 }
77 } else {
78 error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 1);
79 if (error) {
80 return error;
81 }
82 }
83
84 if (argc == 4) {
85 // Long format: all|workspace|current.
86 if (strcmp(argv[amount_idx], "all") == 0) {
87 amount_idx++;
88 scope = GAPS_SCOPE_ALL;
89 } else if (strcmp(argv[amount_idx], "workspace") == 0) {
90 amount_idx++;
91 scope = GAPS_SCOPE_WORKSPACE;
92 } else if (strcmp(argv[amount_idx], "current") == 0) {
93 amount_idx++;
94 scope = GAPS_SCOPE_CURRENT;
95 }
96
97 // Long format: set|plus|minus
98 if (strcmp(argv[amount_idx], "set") == 0) {
99 amount_idx++;
100 op = GAPS_OP_SET;
101 } else if (strcmp(argv[amount_idx], "plus") == 0) {
102 amount_idx++;
103 op = GAPS_OP_ADD;
104 } else if (strcmp(argv[amount_idx], "minus") == 0) {
105 amount_idx++;
106 op = GAPS_OP_SUBTRACT;
107 }
108 }
109
110 char *end;
111 double val = strtod(argv[amount_idx], &end);
112
113 if (strlen(end) && val == 0.0) { // invalid <amount>
114 // guess which variant of the command was attempted
115 if (argc == 1) {
116 return cmd_results_new(CMD_INVALID, "gaps", "gaps <amount>");
117 }
118 if (argc == 2) {
119 return cmd_results_new(CMD_INVALID, "gaps",
120 "gaps inner|outer <amount>");
121 }
122 return cmd_results_new(CMD_INVALID, "gaps",
123 "gaps inner|outer all|workspace|current set|plus|minus <amount>");
124 }
125
126 if (amount_idx == 0) { // gaps <amount>
127 config->gaps_inner = val;
128 config->gaps_outer = val;
129 arrange_root();
130 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
131 }
132 // Other variants. The middle-length variant (gaps inner|outer <amount>)
133 // just defaults the scope to "all" and defaults the op to "set".
134
135 double total;
136 switch (op) {
137 case GAPS_OP_SUBTRACT: {
138 total = (inner ? config->gaps_inner : config->gaps_outer) - val;
139 if (total < 0) {
140 total = 0;
141 }
142 break;
143 }
144 case GAPS_OP_ADD: {
145 total = (inner ? config->gaps_inner : config->gaps_outer) + val;
146 break;
147 }
148 case GAPS_OP_SET: {
149 total = val;
150 break;
151 }
152 }
153
154 if (scope == GAPS_SCOPE_ALL) {
155 if (inner) {
156 config->gaps_inner = total;
157 } else {
158 config->gaps_outer = total;
159 }
160 arrange_root();
161 } else {
162 struct sway_container *c =
163 config->handler_context.current_container;
164 if (scope == GAPS_SCOPE_WORKSPACE && c->type != C_WORKSPACE) {
165 c = container_parent(c, C_WORKSPACE);
166 }
167 c->has_gaps = true;
168 if (inner) {
169 c->gaps_inner = total;
170 } else {
171 c->gaps_outer = total;
172 }
173
174 if (c->parent) {
175 arrange_children_of(c->parent);
176 } else {
177 arrange_root();
178 }
179 }
180 }
181
182 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
183}
diff --git a/sway/commands/smart_gaps.c b/sway/commands/smart_gaps.c
new file mode 100644
index 00000000..38700d65
--- /dev/null
+++ b/sway/commands/smart_gaps.c
@@ -0,0 +1,28 @@
1#include <string.h>
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "sway/tree/arrange.h"
5#include "sway/tree/view.h"
6#include "sway/tree/container.h"
7#include "log.h"
8#include "stringop.h"
9
10struct cmd_results *cmd_smart_gaps(int argc, char **argv) {
11 struct cmd_results *error = checkarg(argc, "smart_gaps", EXPECTED_AT_LEAST, 1);
12
13 if (error) {
14 return error;
15 }
16
17 if (strcmp(argv[0], "on") == 0) {
18 config->smart_gaps = true;
19 arrange_root();
20 } else if (strcmp(argv[0], "off") == 0) {
21 config->smart_gaps = false;
22 arrange_root();
23 } else {
24 return cmd_results_new(CMD_INVALID, "smart_gaps",
25 "Expected 'smart_gaps <on|off>' ");
26 }
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
28}
diff --git a/sway/meson.build b/sway/meson.build
index b6bb02a7..0da67ed7 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -44,6 +44,7 @@ sway_sources = files(
44 'commands/for_window.c', 44 'commands/for_window.c',
45 'commands/force_focus_wrapping.c', 45 'commands/force_focus_wrapping.c',
46 'commands/fullscreen.c', 46 'commands/fullscreen.c',
47 'commands/gaps.c',
47 'commands/hide_edge_borders.c', 48 'commands/hide_edge_borders.c',
48 'commands/kill.c', 49 'commands/kill.c',
49 'commands/mark.c', 50 'commands/mark.c',
@@ -64,6 +65,7 @@ sway_sources = files(
64 'commands/seat/fallback.c', 65 'commands/seat/fallback.c',
65 'commands/set.c', 66 'commands/set.c',
66 'commands/show_marks.c', 67 'commands/show_marks.c',
68 'commands/smart_gaps.c',
67 'commands/split.c', 69 'commands/split.c',
68 'commands/sticky.c', 70 'commands/sticky.c',
69 'commands/swaybg_command.c', 71 'commands/swaybg_command.c',
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index 721b557e..53c95820 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -43,6 +43,7 @@ void arrange_output(struct sway_container *output) {
43 "called arrange_output() on non-output container")) { 43 "called arrange_output() on non-output container")) {
44 return; 44 return;
45 } 45 }
46
46 const struct wlr_box *output_box = wlr_output_layout_get_box( 47 const struct wlr_box *output_box = wlr_output_layout_get_box(
47 root_container.sway_root->output_layout, 48 root_container.sway_root->output_layout,
48 output->sway_output->wlr_output); 49 output->sway_output->wlr_output);
@@ -52,6 +53,7 @@ void arrange_output(struct sway_container *output) {
52 output->height = output_box->height; 53 output->height = output_box->height;
53 wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f", 54 wlr_log(L_DEBUG, "Arranging output '%s' at %f,%f",
54 output->name, output->x, output->y); 55 output->name, output->x, output->y);
56
55 for (int i = 0; i < output->children->length; ++i) { 57 for (int i = 0; i < output->children->length; ++i) {
56 struct sway_container *workspace = output->children->items[i]; 58 struct sway_container *workspace = output->children->items[i];
57 arrange_workspace(workspace); 59 arrange_workspace(workspace);
@@ -67,18 +69,62 @@ void arrange_workspace(struct sway_container *workspace) {
67 "called arrange_workspace() on non-workspace container")) { 69 "called arrange_workspace() on non-workspace container")) {
68 return; 70 return;
69 } 71 }
72
70 struct sway_container *output = workspace->parent; 73 struct sway_container *output = workspace->parent;
71 struct wlr_box *area = &output->sway_output->usable_area; 74 struct wlr_box *area = &output->sway_output->usable_area;
72 wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", 75 wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d",
73 area->width, area->height, area->x, area->y); 76 area->width, area->height, area->x, area->y);
77
78 remove_gaps(workspace);
79
74 workspace->width = area->width; 80 workspace->width = area->width;
75 workspace->height = area->height; 81 workspace->height = area->height;
76 workspace->x = output->x + area->x; 82 workspace->x = output->x + area->x;
77 workspace->y = output->y + area->y; 83 workspace->y = output->y + area->y;
84
85 add_gaps(workspace);
86
78 wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", 87 wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
79 workspace->name, workspace->x, workspace->y); 88 workspace->name, workspace->x, workspace->y);
80 arrange_children_of(workspace); 89 arrange_children_of(workspace);
81 container_damage_whole(workspace); 90}
91
92void remove_gaps(struct sway_container *c) {
93 if (c->current_gaps == 0) {
94 wlr_log(L_DEBUG, "Removing gaps: not gapped: %p", c);
95 return;
96 }
97
98 c->width += c->current_gaps * 2;
99 c->height += c->current_gaps * 2;
100 c->x -= c->current_gaps;
101 c->y -= c->current_gaps;
102
103 c->current_gaps = 0;
104
105 wlr_log(L_DEBUG, "Removing gaps %p", c);
106}
107
108void add_gaps(struct sway_container *c) {
109 if (c->current_gaps > 0 || c->type == C_CONTAINER) {
110 wlr_log(L_DEBUG, "Not adding gaps: %p", c);
111 return;
112 }
113
114 if (c->type == C_WORKSPACE &&
115 !(config->edge_gaps || (config->smart_gaps && c->children->length > 1))) {
116 return;
117 }
118
119 double gaps = c->has_gaps ? c->gaps_inner : config->gaps_inner;
120
121 c->x += gaps;
122 c->y += gaps;
123 c->width -= 2 * gaps;
124 c->height -= 2 * gaps;
125 c->current_gaps = gaps;
126
127 wlr_log(L_DEBUG, "Adding gaps: %p", c);
82} 128}
83 129
84static void apply_horiz_layout(struct sway_container *parent) { 130static void apply_horiz_layout(struct sway_container *parent) {
@@ -99,6 +145,7 @@ static void apply_horiz_layout(struct sway_container *parent) {
99 double total_width = 0; 145 double total_width = 0;
100 for (size_t i = 0; i < num_children; ++i) { 146 for (size_t i = 0; i < num_children; ++i) {
101 struct sway_container *child = parent->children->items[i]; 147 struct sway_container *child = parent->children->items[i];
148
102 if (child->width <= 0) { 149 if (child->width <= 0) {
103 if (num_children > 1) { 150 if (num_children > 1) {
104 child->width = parent->width / (num_children - 1); 151 child->width = parent->width / (num_children - 1);
@@ -106,6 +153,7 @@ static void apply_horiz_layout(struct sway_container *parent) {
106 child->width = parent->width; 153 child->width = parent->width;
107 } 154 }
108 } 155 }
156 remove_gaps(child);
109 total_width += child->width; 157 total_width += child->width;
110 } 158 }
111 double scale = parent->width / total_width; 159 double scale = parent->width / total_width;
@@ -121,12 +169,19 @@ static void apply_horiz_layout(struct sway_container *parent) {
121 child, child->type, child->width, scale); 169 child, child->type, child->width, scale);
122 child->x = child_x; 170 child->x = child_x;
123 child->y = parent->y + parent_offset; 171 child->y = parent->y + parent_offset;
124 child->width = floor(child->width * scale);
125 child->height = parent_height; 172 child->height = parent_height;
173
174 if (i == num_children - 1) {
175 // Make last child use remaining width of parent
176 child->width = parent->x + parent->width - child->x;
177 } else {
178 child->width = floor(child->width * scale);
179 }
180
126 child_x += child->width; 181 child_x += child->width;
182
183 add_gaps(child);
127 } 184 }
128 // Make last child use remaining width of parent
129 child->width = parent->x + parent->width - child->x;
130} 185}
131 186
132static void apply_vert_layout(struct sway_container *parent) { 187static void apply_vert_layout(struct sway_container *parent) {
@@ -141,12 +196,13 @@ static void apply_vert_layout(struct sway_container *parent) {
141 parent_offset = 196 parent_offset =
142 container_titlebar_height() * parent->parent->children->length; 197 container_titlebar_height() * parent->parent->children->length;
143 } 198 }
144 size_t parent_height = parent->height - parent_offset; 199 size_t parent_height = parent->height + parent_offset;
145 200
146 // Calculate total height of children 201 // Calculate total height of children
147 double total_height = 0; 202 double total_height = 0;
148 for (size_t i = 0; i < num_children; ++i) { 203 for (size_t i = 0; i < num_children; ++i) {
149 struct sway_container *child = parent->children->items[i]; 204 struct sway_container *child = parent->children->items[i];
205
150 if (child->height <= 0) { 206 if (child->height <= 0) {
151 if (num_children > 1) { 207 if (num_children > 1) {
152 child->height = parent_height / (num_children - 1); 208 child->height = parent_height / (num_children - 1);
@@ -154,6 +210,7 @@ static void apply_vert_layout(struct sway_container *parent) {
154 child->height = parent_height; 210 child->height = parent_height;
155 } 211 }
156 } 212 }
213 remove_gaps(child);
157 total_height += child->height; 214 total_height += child->height;
158 } 215 }
159 double scale = parent_height / total_height; 216 double scale = parent_height / total_height;
@@ -170,11 +227,18 @@ static void apply_vert_layout(struct sway_container *parent) {
170 child->x = parent->x; 227 child->x = parent->x;
171 child->y = child_y; 228 child->y = child_y;
172 child->width = parent->width; 229 child->width = parent->width;
173 child->height = floor(child->height * scale); 230
231 if (i == num_children - 1) {
232 // Make last child use remaining height of parent
233 child->height = parent->y + parent_offset + parent_height - child->y;
234 } else {
235 child->height = floor(child->height * scale);
236 }
237
174 child_y += child->height; 238 child_y += child->height;
239
240 add_gaps(child);
175 } 241 }
176 // Make last child use remaining height of parent
177 child->height = parent->y + parent_offset + parent_height - child->y;
178} 242}
179 243
180static void apply_tabbed_or_stacked_layout(struct sway_container *parent) { 244static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
@@ -191,10 +255,12 @@ static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
191 size_t parent_height = parent->height - parent_offset; 255 size_t parent_height = parent->height - parent_offset;
192 for (int i = 0; i < parent->children->length; ++i) { 256 for (int i = 0; i < parent->children->length; ++i) {
193 struct sway_container *child = parent->children->items[i]; 257 struct sway_container *child = parent->children->items[i];
258 remove_gaps(child);
194 child->x = parent->x; 259 child->x = parent->x;
195 child->y = parent->y + parent_offset; 260 child->y = parent->y + parent_offset;
196 child->width = parent->width; 261 child->width = parent->width;
197 child->height = parent_height; 262 child->height = parent_height;
263 add_gaps(child);
198 } 264 }
199} 265}
200 266
@@ -211,6 +277,7 @@ void arrange_children_of(struct sway_container *parent) {
211 if (workspace->type != C_WORKSPACE) { 277 if (workspace->type != C_WORKSPACE) {
212 workspace = container_parent(workspace, C_WORKSPACE); 278 workspace = container_parent(workspace, C_WORKSPACE);
213 } 279 }
280
214 if (workspace->sway_workspace->fullscreen) { 281 if (workspace->sway_workspace->fullscreen) {
215 // Just arrange the fullscreen view and jump out 282 // Just arrange the fullscreen view and jump out
216 view_autoconfigure(workspace->sway_workspace->fullscreen); 283 view_autoconfigure(workspace->sway_workspace->fullscreen);
@@ -241,6 +308,11 @@ void arrange_children_of(struct sway_container *parent) {
241 // Apply x, y, width and height to children and recurse if needed 308 // Apply x, y, width and height to children and recurse if needed
242 for (int i = 0; i < parent->children->length; ++i) { 309 for (int i = 0; i < parent->children->length; ++i) {
243 struct sway_container *child = parent->children->items[i]; 310 struct sway_container *child = parent->children->items[i];
311 if (parent->has_gaps && !child->has_gaps) {
312 child->has_gaps = true;
313 child->gaps_inner = parent->gaps_inner;
314 child->gaps_outer = parent->gaps_outer;
315 }
244 if (child->type == C_VIEW) { 316 if (child->type == C_VIEW) {
245 view_autoconfigure(child->sway_view); 317 view_autoconfigure(child->sway_view);
246 } else { 318 } else {
diff --git a/sway/tree/container.c b/sway/tree/container.c
index cd2c083c..af55a54e 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -124,6 +124,11 @@ struct sway_container *container_create(enum sway_container_type type) {
124 wl_signal_add(&c->events.reparent, &c->reparent); 124 wl_signal_add(&c->events.reparent, &c->reparent);
125 c->reparent.notify = handle_reparent; 125 c->reparent.notify = handle_reparent;
126 126
127 c->has_gaps = false;
128 c->gaps_inner = 0;
129 c->gaps_outer = 0;
130 c->current_gaps = 0;
131
127 return c; 132 return c;
128} 133}
129 134
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 6d4cd088..a8aba618 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -871,6 +871,8 @@ struct sway_container *container_split(struct sway_container *child,
871 871
872 wlr_log(L_DEBUG, "creating container %p around %p", cont, child); 872 wlr_log(L_DEBUG, "creating container %p around %p", cont, child);
873 873
874 remove_gaps(child);
875
874 cont->prev_layout = L_NONE; 876 cont->prev_layout = L_NONE;
875 cont->width = child->width; 877 cont->width = child->width;
876 cont->height = child->height; 878 cont->height = child->height;
@@ -879,6 +881,9 @@ struct sway_container *container_split(struct sway_container *child,
879 881
880 struct sway_seat *seat = input_manager_get_default_seat(input_manager); 882 struct sway_seat *seat = input_manager_get_default_seat(input_manager);
881 bool set_focus = (seat_get_focus(seat) == child); 883 bool set_focus = (seat_get_focus(seat) == child);
884
885 add_gaps(cont);
886
882 if (child->type == C_WORKSPACE) { 887 if (child->type == C_WORKSPACE) {
883 struct sway_container *workspace = child; 888 struct sway_container *workspace = child;
884 while (workspace->children->length) { 889 while (workspace->children->length) {
@@ -906,7 +911,7 @@ struct sway_container *container_split(struct sway_container *child,
906 } 911 }
907 912
908 container_notify_subtree_changed(cont); 913 container_notify_subtree_changed(cont);
909 914 arrange_children_of(cont);
910 return cont; 915 return cont;
911} 916}
912 917