Skip to content

Commit

Permalink
Fix gaps issues
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
RyanDwyer committed Aug 28, 2018
1 parent f5b9815 commit 126a82f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion sway/commands/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
parent->prev_split_layout = prev;
}
container_notify_subtree_changed(parent);
arrange_windows(parent);
arrange_windows(parent->parent);
}

return cmd_results_new(CMD_SUCCESS, NULL, NULL);
Expand Down
7 changes: 2 additions & 5 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,7 @@ static void render_container_tabbed(struct sway_output *output,
struct sway_container *current = pstate->focused_inactive_child;
struct border_colors *current_colors = &config->border_colors.unfocused;

double width_gap_adjustment = 2 * pstate->current_gaps;
int tab_width =
(pstate->swayc_width - width_gap_adjustment) / pstate->children->length;
int tab_width = (pstate->swayc_width) / pstate->children->length;

// Render tabs
for (int i = 0; i < pstate->children->length; ++i) {
Expand Down Expand Up @@ -656,8 +654,7 @@ static void render_container_tabbed(struct sway_output *output,

// Make last tab use the remaining width of the parent
if (i == pstate->children->length - 1) {
tab_width =
pstate->swayc_width - width_gap_adjustment - tab_width * i;
tab_width = pstate->swayc_width - tab_width * i;
}

render_titlebar(output, damage, child, x, pstate->swayc_y, tab_width,
Expand Down
18 changes: 12 additions & 6 deletions sway/tree/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,17 @@ void container_add_gaps(struct sway_container *c) {
"Expected a container or view")) {
return;
}
if (c->current_gaps > 0 || c->type != C_VIEW) {
if (c->current_gaps > 0) {
return;
}
// Linear containers don't have gaps because it'd create double gaps
if (c->type == C_CONTAINER &&
c->layout != L_TABBED && c->layout != L_STACKED) {
return;
}
// Children of tabbed/stacked containers re-use the gaps of the container
enum sway_container_layout layout = c->parent->layout;
if (layout == L_TABBED || layout == L_STACKED) {
return;
}

Expand Down Expand Up @@ -1355,20 +1365,16 @@ struct sway_container *container_split(struct sway_container *child,

wlr_log(WLR_DEBUG, "creating container %p around %p", cont, child);

child->type == C_WORKSPACE ? workspace_remove_gaps(child)
: container_remove_gaps(child);

cont->prev_split_layout = L_NONE;
cont->width = child->width;
cont->height = child->height;
cont->x = child->x;
cont->y = child->y;
cont->current_gaps = child->current_gaps;

struct sway_seat *seat = input_manager_get_default_seat(input_manager);
bool set_focus = (seat_get_focus(seat) == child);

container_add_gaps(cont);

if (child->type == C_WORKSPACE) {
struct sway_container *workspace = child;
while (workspace->children->length) {
Expand Down
10 changes: 9 additions & 1 deletion sway/tree/workspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,15 @@ void workspace_add_gaps(struct sway_container *ws) {
return;
}

ws->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
ws->current_gaps = ws->has_gaps ? ws->gaps_outer : config->gaps_outer;

if (ws->layout == L_TABBED || ws->layout == L_STACKED) {
// We have to add inner gaps for this, because children of tabbed and
// stacked containers don't apply their own gaps - they assume the
// tabbed/stacked container is using gaps.
ws->current_gaps += ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
}

ws->x += ws->current_gaps;
ws->y += ws->current_gaps;
ws->width -= 2 * ws->current_gaps;
Expand Down

0 comments on commit 126a82f

Please sign in to comment.