summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-04-12 15:14:55 -0500
committerDudemanguy <random342@airmail.cc>2024-04-13 14:33:58 +0000
commit1172c4ead962383b8d9fb012503d745a8098c270 (patch)
tree46ea6f606be772c1e102c7ee39483ae3a7c86098 /video/out
parent307255d00d5ab7a7e51a247cd1aa75218611d8d7 (diff)
downloadmpv-1172c4ead962383b8d9fb012503d745a8098c270.tar.bz2
mpv-1172c4ead962383b8d9fb012503d745a8098c270.tar.xz
wayland: apply keepaspect options to wayland configure bounds
Previously if mpv's size was constrained by the compositor's configure bounds event, there was no attempt to preserve the aspect ratio of the given coordinates if --keepaspect (the default) was used. Be sure to apply keepaspect to the bounded widths and heights if we are using this event.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/wayland_common.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 7a2346d759..edce4000a8 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -222,6 +222,7 @@ static int spawn_cursor(struct vo_wayland_state *wl);
static void add_feedback(struct vo_wayland_feedback_pool *fback_pool,
struct wp_presentation_feedback *fback);
+static void apply_keepaspect(struct vo_wayland_state *wl, int *width, int *height);
static void get_shape_device(struct vo_wayland_state *wl, struct vo_wayland_seat *s);
static int greatest_common_divisor(int a, int b);
static void guess_focus(struct vo_wayland_state *wl);
@@ -1155,12 +1156,7 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel,
}
if (!wl->locked_size) {
- 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);
- }
+ apply_keepaspect(wl, &width, &height);
wl->window_size.x0 = 0;
wl->window_size.y0 = 0;
wl->window_size.x1 = lround(width * wl->scaling);
@@ -1567,6 +1563,17 @@ static const struct wl_registry_listener registry_listener = {
};
/* Static functions */
+static void apply_keepaspect(struct vo_wayland_state *wl, int *width, int *height)
+{
+ if (!wl->vo_opts->keepaspect)
+ return;
+
+ double scale_factor = (double)*width / wl->reduced_width;
+ *width = ceil(wl->reduced_width * scale_factor);
+ if (wl->vo_opts->keepaspect_window)
+ *height = ceil(wl->reduced_height * scale_factor);
+}
+
static void free_dnd_data(struct vo_wayland_state *wl)
{
// caller should close wl->dnd_fd if appropriate
@@ -2106,6 +2113,8 @@ static void set_window_bounds(struct vo_wayland_state *wl)
return;
}
+ apply_keepaspect(wl, &wl->bounded_width, &wl->bounded_height);
+
if (wl->bounded_width && wl->bounded_width < wl->window_size.x1)
wl->window_size.x1 = wl->bounded_width;
if (wl->bounded_height && wl->bounded_height < wl->window_size.y1)