Skip to content

Commit

Permalink
river: fix resize command
Browse files Browse the repository at this point in the history
In 489a497 the view.move() call, which is used to keep the view centered after
a resize, was accidentally removed.
  • Loading branch information
Leon-Plickat committed Dec 29, 2022
1 parent e18d0d5 commit 5d4c2f2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions river/command/move.zig
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,32 @@ pub fn resize(
view.output.wlr_output.effectiveResolution(&output_width, &output_height);
switch (orientation) {
.horizontal => {
const prev_width = view.pending.box.width;
view.pending.box.width += delta;
view.applyConstraints();
// Get width difference after applying view constraints, so that the
// move reflects the actual size difference, but before applying the
// output size constraints, to allow growing a view even if it is
// up against an output edge.
const diff_width = prev_width - view.pending.box.width;
// Do not grow bigger than the output
view.pending.box.width = math.min(
view.pending.box.width,
output_width - 2 * server.config.border_width,
);
view.move(@divFloor(diff_width, 2), 0);
},
.vertical => {
const prev_height = view.pending.box.height;
view.pending.box.height += delta;
view.applyConstraints();
const diff_height = prev_height - view.pending.box.height;
// Do not grow bigger than the output
view.pending.box.height = math.min(
view.pending.box.height,
output_height - 2 * server.config.border_width,
);
view.move(0, @divFloor(diff_height, 2));
},
}

Expand Down

0 comments on commit 5d4c2f2

Please sign in to comment.