From 8e620c8e76ec0b8b5b5a0581f3f581cdf86923a4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 20 Dec 2019 12:47:00 +0100 Subject: [PATCH] command: add property returning hidpi scale --- DOCS/man/input.rst | 6 ++++++ player/command.c | 12 ++++++++++++ video/out/vo.h | 1 + 3 files changed, 19 insertions(+) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 94e1f2fd27..d3e49fc83d 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -2073,6 +2073,12 @@ Property list ``vsync-jitter`` Estimated deviation factor of the vsync duration. +``display-hidpi-scale`` + The HiDPI scale factor as reported by the windowing backend. If no VO is + active, or if the VO does not report a value, this property is unavailable. + It may be saner to report an absolute DPI, however, this is the way HiDPI + support is implemented on most OS APIs. See also ``--hidpi-window-scale``. + ``video-aspect`` (RW) Deprecated. This is tied to ``--video-aspect-override``, but always reports the current video aspect if video is active. diff --git a/player/command.c b/player/command.c index ea6e3bb76c..8b41631b4b 100644 --- a/player/command.c +++ b/player/command.c @@ -2325,6 +2325,17 @@ static int mp_property_vsync_jitter(void *ctx, struct m_property *prop, return m_property_double_ro(action, arg, stddev); } +static int mp_property_hidpi_scale(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + struct vo *vo = mpctx->video_out; + double scale = 0; + if (!vo || vo_control(vo, VOCTRL_GET_HIDPI_SCALE, &scale) < 1 || scale <= 0) + return M_PROPERTY_UNAVAILABLE; + return m_property_double_ro(action, arg, scale); +} + static int mp_property_display_names(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3398,6 +3409,7 @@ static const struct m_property mp_properties_base[] = { {"display-fps", mp_property_display_fps}, {"estimated-display-fps", mp_property_estimated_display_fps}, {"vsync-jitter", mp_property_vsync_jitter}, + {"display-hidpi-scale", mp_property_hidpi_scale}, {"working-directory", mp_property_cwd}, diff --git a/video/out/vo.h b/video/out/vo.h index f50df6c179..a05860cbc7 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -116,6 +116,7 @@ enum mp_voctrl { VOCTRL_GET_ICC_PROFILE, // bstr* VOCTRL_GET_AMBIENT_LUX, // int* VOCTRL_GET_DISPLAY_FPS, // double* + VOCTRL_GET_HIDPI_SCALE, // double* VOCTRL_GET_PREF_DEINT, // int*