diff options
author | Dudemanguy <random342@airmail.cc> | 2024-03-04 09:42:15 -0600 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2024-03-04 22:42:46 +0100 |
commit | 781f78fb3a0457aea8084f94feeeb69978a02a71 (patch) | |
tree | 6b8e52974ae0f82d3d4182a1e6db63d37978bcf7 | |
parent | 9ac791c329aa967d6034da1543e03c777b09f4ef (diff) | |
download | mpv-781f78fb3a0457aea8084f94feeeb69978a02a71.tar.bz2 mpv-781f78fb3a0457aea8084f94feeeb69978a02a71.tar.xz |
wayland: guess the first hidpi frame better
It's been a longstanding issue in wayland* that the first frame on a
hidpi screen will have wrong scaling. A well behaved client immediately
corrects this, but it's noticeable and also can affect window placement
due to the way resizng works. Preferred scale from the fractional
protocol and preferred buffer scale can actually solve this problem. It
depends on compositors mostly, but one could simply send the event
before the client maps its surface so it knows what the correct scale is
in the first place. I'm not sure if any compositors currently behave
like this (sway seems to still require the client to render before
sending any scaling information at least), but it makes to sense to
account for this possibility.
*: https://gitlab.freedesktop.org/wayland/wayland/-/issues/133
-rw-r--r-- | video/out/wayland_common.c | 8 | ||||
-rw-r--r-- | video/out/wayland_common.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index c7314cb144..52d5e90f88 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -985,6 +985,7 @@ static void surface_handle_preferred_buffer_scale(void *data, return; wl->scaling = scale; + wl->scale_configured = true; MP_VERBOSE(wl, "Obtained preferred scale, %f, from the compositor.\n", wl->scaling); wl->pending_vo_events |= VO_EVENT_DPI; @@ -1209,6 +1210,7 @@ static void preferred_scale(void *data, double old_scale = wl->scaling; wl->scaling = (double)scale / 120; + wl->scale_configured = true; MP_VERBOSE(wl, "Obtained preferred scale, %f, from the compositor.\n", wl->scaling); wl->pending_vo_events |= VO_EVENT_DPI; @@ -2071,8 +2073,11 @@ static int set_screensaver_inhibitor(struct vo_wayland_state *wl, int state) static void set_surface_scaling(struct vo_wayland_state *wl) { - if (wl->fractional_scale_manager || wl_surface_get_version(wl->surface) >= 6) + if (wl->scale_configured && (wl->fractional_scale_manager || + wl_surface_get_version(wl->surface) >= 6)) + { return; + } double old_scale = wl->scaling; wl->scaling = wl->current_output->scale; @@ -2587,6 +2592,7 @@ bool vo_wayland_reconfig(struct vo *vo) if (!wl->current_output) return false; set_surface_scaling(wl); + wl->scale_configured = true; wl->pending_vo_events |= VO_EVENT_DPI; } diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h index 721d4fb2eb..3e8530eaff 100644 --- a/video/out/wayland_common.h +++ b/video/out/wayland_common.h @@ -75,6 +75,7 @@ struct vo_wayland_state { bool hidden; bool initial_size_hint; bool locked_size; + bool scale_configured; bool state_change; bool tiled; bool toplevel_configured; |