summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-08-08 20:55:26 -0500
committerDudemanguy <random342@airmail.cc>2021-08-08 21:17:02 -0500
commit8d4f10fcc0837573a54ccc1f3c9951fa2bedd6ed (patch)
tree17d332231ea852fed0f82ddaaa88f6758fd8ae6c
parent8300830951e2b0b90b22fc7d33b7556ed05e139c (diff)
downloadmpv-8d4f10fcc0837573a54ccc1f3c9951fa2bedd6ed.tar.bz2
mpv-8d4f10fcc0837573a54ccc1f3c9951fa2bedd6ed.tar.xz
wayland: fix keepaspect-window during resize
So the resizing mechanism is actually supposed to match the video size to the window size while preserving the aspect ratio. In wayland, the current logic behaves as if --no-keepaspect-window was set. Fix this by simply multiplying the height by the same scale factor the width is multiplied by. Also get rid of the pointless (width > height) test (it makes no difference in any case) as well as some unneccesary checks for the keepaspect-window option. The use of ceil here is to make sure the window coordinates can never possibly have be 0 due to truncation (weston can still give you a 1x1 window which is fun). Fixes #9098.
-rw-r--r--video/out/wayland_common.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 8e03be84ab..e34c84a0b4 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -859,14 +859,11 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
return;
if (!is_fullscreen && !is_maximized) {
- if (vo_opts->keepaspect && vo_opts->keepaspect_window) {
- if (width > height) {
- double scale_factor = (double)width / wl->reduced_width;
- width = wl->reduced_width * scale_factor;
- } else {
- double scale_factor = (double)height / wl->reduced_height;
- height = wl->reduced_height * scale_factor;
- }
+ 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);
}
wl->window_size.x0 = 0;
wl->window_size.y0 = 0;
@@ -1761,7 +1758,7 @@ int vo_wayland_reconfig(struct vo *vo)
set_geometry(wl);
- if (wl->vo_opts->keepaspect && wl->vo_opts->keepaspect_window)
+ if (wl->vo_opts->keepaspect)
wl->window_size = wl->vdparams;
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)