summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-03-04 09:42:15 -0600
committersfan5 <sfan5@live.de>2024-03-04 22:42:46 +0100
commit781f78fb3a0457aea8084f94feeeb69978a02a71 (patch)
tree6b8e52974ae0f82d3d4182a1e6db63d37978bcf7 /video/out/wayland_common.c
parent9ac791c329aa967d6034da1543e03c777b09f4ef (diff)
downloadmpv-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
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r--video/out/wayland_common.c8
1 files changed, 7 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;
}