aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-28 23:53:51 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-28 23:53:51 +1000
commit126a82f14ff47925c7f88523ed9abe0ae9aeb7e8 (patch)
tree7cdac6c37f6ad87c056690bdeac3d5ea0489668d /sway
parentPrepare arrange code for type safe arguments (diff)
downloadsway-126a82f14ff47925c7f88523ed9abe0ae9aeb7e8.tar.gz
sway-126a82f14ff47925c7f88523ed9abe0ae9aeb7e8.tar.zst
sway-126a82f14ff47925c7f88523ed9abe0ae9aeb7e8.zip
Fix gaps issues
* In layout command, arrange parent of parent - not sure why this is needed but it is * Remove gap adjustment when rendering * Workspace should use outer gaps, not inner * Add exceptions for tabbed and stacked containers * Don't mess with gap state when splitting a container
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/layout.c2
-rw-r--r--sway/desktop/render.c7
-rw-r--r--sway/tree/container.c18
-rw-r--r--sway/tree/workspace.c10
4 files changed, 24 insertions, 13 deletions
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index f4e4dda9..a06832de 100644
--- a/sway/commands/layout.c
+++ b/sway/commands/layout.c
@@ -103,7 +103,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
103 parent->prev_split_layout = prev; 103 parent->prev_split_layout = prev;
104 } 104 }
105 container_notify_subtree_changed(parent); 105 container_notify_subtree_changed(parent);
106 arrange_windows(parent); 106 arrange_windows(parent->parent);
107 } 107 }
108 108
109 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 109 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index b52dd196..5556e5b3 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -619,9 +619,7 @@ static void render_container_tabbed(struct sway_output *output,
619 struct sway_container *current = pstate->focused_inactive_child; 619 struct sway_container *current = pstate->focused_inactive_child;
620 struct border_colors *current_colors = &config->border_colors.unfocused; 620 struct border_colors *current_colors = &config->border_colors.unfocused;
621 621
622 double width_gap_adjustment = 2 * pstate->current_gaps; 622 int tab_width = (pstate->swayc_width) / pstate->children->length;
623 int tab_width =
624 (pstate->swayc_width - width_gap_adjustment) / pstate->children->length;
625 623
626 // Render tabs 624 // Render tabs
627 for (int i = 0; i < pstate->children->length; ++i) { 625 for (int i = 0; i < pstate->children->length; ++i) {
@@ -656,8 +654,7 @@ static void render_container_tabbed(struct sway_output *output,
656 654
657 // Make last tab use the remaining width of the parent 655 // Make last tab use the remaining width of the parent
658 if (i == pstate->children->length - 1) { 656 if (i == pstate->children->length - 1) {
659 tab_width = 657 tab_width = pstate->swayc_width - tab_width * i;
660 pstate->swayc_width - width_gap_adjustment - tab_width * i;
661 } 658 }
662 659
663 render_titlebar(output, damage, child, x, pstate->swayc_y, tab_width, 660 render_titlebar(output, damage, child, x, pstate->swayc_y, tab_width,
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 1b193944..ee019098 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1159,7 +1159,17 @@ void container_add_gaps(struct sway_container *c) {
1159 "Expected a container or view")) { 1159 "Expected a container or view")) {
1160 return; 1160 return;
1161 } 1161 }
1162 if (c->current_gaps > 0 || c->type != C_VIEW) { 1162 if (c->current_gaps > 0) {
1163 return;
1164 }
1165 // Linear containers don't have gaps because it'd create double gaps
1166 if (c->type == C_CONTAINER &&
1167 c->layout != L_TABBED && c->layout != L_STACKED) {
1168 return;
1169 }
1170 // Children of tabbed/stacked containers re-use the gaps of the container
1171 enum sway_container_layout layout = c->parent->layout;
1172 if (layout == L_TABBED || layout == L_STACKED) {
1163 return; 1173 return;
1164 } 1174 }
1165 1175
@@ -1355,20 +1365,16 @@ struct sway_container *container_split(struct sway_container *child,
1355 1365
1356 wlr_log(WLR_DEBUG, "creating container %p around %p", cont, child); 1366 wlr_log(WLR_DEBUG, "creating container %p around %p", cont, child);
1357 1367
1358 child->type == C_WORKSPACE ? workspace_remove_gaps(child)
1359 : container_remove_gaps(child);
1360
1361 cont->prev_split_layout = L_NONE; 1368 cont->prev_split_layout = L_NONE;
1362 cont->width = child->width; 1369 cont->width = child->width;
1363 cont->height = child->height; 1370 cont->height = child->height;
1364 cont->x = child->x; 1371 cont->x = child->x;
1365 cont->y = child->y; 1372 cont->y = child->y;
1373 cont->current_gaps = child->current_gaps;
1366 1374
1367 struct sway_seat *seat = input_manager_get_default_seat(input_manager); 1375 struct sway_seat *seat = input_manager_get_default_seat(input_manager);
1368 bool set_focus = (seat_get_focus(seat) == child); 1376 bool set_focus = (seat_get_focus(seat) == child);
1369 1377
1370 container_add_gaps(cont);
1371
1372 if (child->type == C_WORKSPACE) { 1378 if (child->type == C_WORKSPACE) {
1373 struct sway_container *workspace = child; 1379 struct sway_container *workspace = child;
1374 while (workspace->children->length) { 1380 while (workspace->children->length) {
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index d930826e..60256336 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -694,7 +694,15 @@ void workspace_add_gaps(struct sway_container *ws) {
694 return; 694 return;
695 } 695 }
696 696
697 ws->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner; 697 ws->current_gaps = ws->has_gaps ? ws->gaps_outer : config->gaps_outer;
698
699 if (ws->layout == L_TABBED || ws->layout == L_STACKED) {
700 // We have to add inner gaps for this, because children of tabbed and
701 // stacked containers don't apply their own gaps - they assume the
702 // tabbed/stacked container is using gaps.
703 ws->current_gaps += ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
704 }
705
698 ws->x += ws->current_gaps; 706 ws->x += ws->current_gaps;
699 ws->y += ws->current_gaps; 707 ws->y += ws->current_gaps;
700 ws->width -= 2 * ws->current_gaps; 708 ws->width -= 2 * ws->current_gaps;