1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-29 02:22:19 +00:00

wayland: support the display-hidpi-scale property

So apparently this property had existed since 2019. Internally, it's
used as a part of the console.lua script for scaling. Yours truly
somehow didn't bat an eye at the fact that the text in the console was
super small (made worse by the fact that xwayland does scale) and just
ignored it for all this time. Oh well.

To report dpi changes to mpv's core, we need to use VO_EVENT_DPI in a
couple of places. One place is, of course, the surface listener if the
scale value reported by the wayland server changes. The other place is
in the very first reconfig since mpv's core will not find the correct
scale value until we actually get a wl_output from the wayland server.
This commit is contained in:
Dudemanguy 2021-04-12 13:53:10 -05:00
parent f1d0365a6f
commit 74f5d4940e

View File

@ -873,6 +873,7 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
double factor = (double)wl->scaling / wl->current_output->scale;
wl->scaling = wl->current_output->scale;
rescale_geometry_dimensions(wl, factor);
wl->pending_vo_events |= VO_EVENT_DPI;
}
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
@ -1570,6 +1571,7 @@ int vo_wayland_reconfig(struct vo *vo)
wl->window_size = wl->vdparams;
wl->geometry = wl->window_size;
wl_display_roundtrip(wl->display);
wl->pending_vo_events |= VO_EVENT_DPI;
}
wl->pending_vo_events |= VO_EVENT_RESIZE;
@ -1730,6 +1732,12 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
*(double *)arg = wl->current_output->refresh_rate;
return VO_TRUE;
}
case VOCTRL_GET_HIDPI_SCALE: {
if (!wl->scaling)
return VO_NOTAVAIL;
*(double *)arg = wl->scaling;
return VO_TRUE;
}
case VOCTRL_UPDATE_WINDOW_TITLE:
return update_window_title(wl, (const char *)arg);
case VOCTRL_SET_CURSOR_VISIBILITY: