mirror of
https://github.com/mpv-player/mpv
synced 2024-12-29 10:32:15 +00:00
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.
This commit is contained in:
parent
8300830951
commit
8d4f10fcc0
@ -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) {
|
||||
if (vo_opts->keepaspect) {
|
||||
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;
|
||||
}
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user