mirror of
https://github.com/swaywm/sway.git
synced 2024-11-16 05:03:17 +00:00
Merge pull request #3184 from kupospelov/fix-resize
resize set: fix units for floating containers
This commit is contained in:
commit
91bbb2a7dd
|
@ -512,34 +512,42 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
|
||||||
calculate_constraints(&min_width, &max_width, &min_height, &max_height);
|
calculate_constraints(&min_width, &max_width, &min_height, &max_height);
|
||||||
|
|
||||||
if (width->amount) {
|
if (width->amount) {
|
||||||
if (width->unit == RESIZE_UNIT_PPT ||
|
switch (width->unit) {
|
||||||
width->unit == RESIZE_UNIT_DEFAULT) {
|
case RESIZE_UNIT_PPT:
|
||||||
// Convert to px
|
// Convert to px
|
||||||
width->amount = con->workspace->width * width->amount / 100;
|
width->amount = con->workspace->width * width->amount / 100;
|
||||||
width->unit = RESIZE_UNIT_PX;
|
width->unit = RESIZE_UNIT_PX;
|
||||||
}
|
// Falls through
|
||||||
if (width->unit == RESIZE_UNIT_PX) {
|
case RESIZE_UNIT_PX:
|
||||||
|
case RESIZE_UNIT_DEFAULT:
|
||||||
width->amount = fmax(min_width, fmin(width->amount, max_width));
|
width->amount = fmax(min_width, fmin(width->amount, max_width));
|
||||||
grow_width = width->amount - con->width;
|
grow_width = width->amount - con->width;
|
||||||
|
|
||||||
con->x -= grow_width / 2;
|
con->x -= grow_width / 2;
|
||||||
con->width = width->amount;
|
con->width = width->amount;
|
||||||
|
break;
|
||||||
|
case RESIZE_UNIT_INVALID:
|
||||||
|
sway_assert(false, "invalid width unit");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height->amount) {
|
if (height->amount) {
|
||||||
if (height->unit == RESIZE_UNIT_PPT ||
|
switch (height->unit) {
|
||||||
height->unit == RESIZE_UNIT_DEFAULT) {
|
case RESIZE_UNIT_PPT:
|
||||||
// Convert to px
|
// Convert to px
|
||||||
height->amount = con->workspace->height * height->amount / 100;
|
height->amount = con->workspace->height * height->amount / 100;
|
||||||
height->unit = RESIZE_UNIT_PX;
|
height->unit = RESIZE_UNIT_PX;
|
||||||
}
|
// Falls through
|
||||||
if (height->unit == RESIZE_UNIT_PX) {
|
case RESIZE_UNIT_PX:
|
||||||
|
case RESIZE_UNIT_DEFAULT:
|
||||||
height->amount = fmax(min_height, fmin(height->amount, max_height));
|
height->amount = fmax(min_height, fmin(height->amount, max_height));
|
||||||
grow_height = height->amount - con->height;
|
grow_height = height->amount - con->height;
|
||||||
|
|
||||||
con->y -= grow_height / 2;
|
con->y -= grow_height / 2;
|
||||||
con->height = height->amount;
|
con->height = height->amount;
|
||||||
|
break;
|
||||||
|
case RESIZE_UNIT_INVALID:
|
||||||
|
sway_assert(false, "invalid height unit");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue