mirror of
https://github.com/mpv-player/mpv
synced 2025-01-20 22:40:52 +00:00
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
This commit is contained in:
parent
9ac791c329
commit
781f78fb3a
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user