summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2023-06-05 19:34:24 +0000
committerFurkan Sahin <furkan-dev@proton.me>2023-06-05 19:34:24 +0000
commitf03ea753b506e2a5342ab86fbd3f1de5dc6bd939 (patch)
treea04e6e287403b71b728a5312296fbe593be02356
parent68860cb49dee4938b6ba358c8054f58494ae1313 (diff)
Calculate tiled resize amount relative to parent container
sway should shrinks/grows tiled windows according to parent container for ppt unit for i3 compatibility. Resolves: #7593
-rw-r--r--sway/commands/resize.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index e69e5506..f59e2aeb 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -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;
+ }
}
}