Skip to content

Commit

Permalink
Calculate tiled resize amount relative to parent container
Browse files Browse the repository at this point in the history
sway should shrinks/grows tiled windows according to parent container
for ppt unit for i3 compatibility.

Resolves: swaywm#7593
  • Loading branch information
nukoseer authored and rpigott committed Jul 13, 2023
1 parent fc16fb6 commit 6c234d0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sway/commands/resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,27 @@ static struct cmd_results *resize_adjust_tiled(uint32_t axis,
amount->unit = MOVEMENT_UNIT_PPT;
}
if (amount->unit == MOVEMENT_UNIT_PPT) {
struct sway_container *parent = current->pending.parent;
float pct = amount->amount / 100.0f;

if (is_horizontal(axis)) {
amount->amount = (float)current->pending.width * pct;
while (parent && parent->pending.layout != L_HORIZ) {
parent = parent->pending.parent;
}
if (parent) {
amount->amount = (float)parent->pending.width * pct;
} else {
amount->amount = (float)current->pending.workspace->width * pct;
}
} else {
amount->amount = (float)current->pending.height * pct;
while (parent && parent->pending.layout != L_VERT) {
parent = parent->pending.parent;
}
if (parent) {
amount->amount = (float)parent->pending.height * pct;
} else {
amount->amount = (float)current->pending.workspace->height * pct;
}
}
}

Expand Down

0 comments on commit 6c234d0

Please sign in to comment.