Skip to content

Commit

Permalink
wayland: fix vertical resize
Browse files Browse the repository at this point in the history
The calculation was only implemented for horizontal resize,
now it works with vertical resize as well.
  • Loading branch information
christoph-heinrich committed Mar 7, 2023
1 parent dcc9bc5 commit 54a4c01
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,18 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,

if (!is_fullscreen && !is_maximized) {
if (vo_opts->keepaspect) {
double scale_factor = (double)width / wl->reduced_width;
width = ceil(wl->reduced_width * scale_factor);
if (vo_opts->keepaspect_window)
height = ceil(wl->reduced_height * scale_factor);
const double sf_w = (double)width / wl->reduced_width;
const double sf_h = (double)height / wl->reduced_height;
const bool horizontal = sf_w > sf_h;
const double scale_factor = horizontal ? sf_w : sf_h;
int *const resized_dimension = horizontal ? &width : &height;
int *const not_resized_dimension = horizontal ? &height : &width;
int *red_rd = horizontal ? &wl->reduced_width : &wl->reduced_height;
int *red_nrd = horizontal ? &wl->reduced_height : &wl->reduced_width;
*resized_dimension = ceil(*red_rd * scale_factor);
if (vo_opts->keepaspect_window) {
*not_resized_dimension = ceil(*red_nrd * scale_factor);
}
}
wl->window_size.x0 = 0;
wl->window_size.y0 = 0;
Expand Down

0 comments on commit 54a4c01

Please sign in to comment.