diff options
author | Dudemanguy <random342@airmail.cc> | 2024-02-13 17:11:00 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-02-24 20:31:08 +0000 |
commit | 17d9abd08fb77d3a33b4717b29257a27ee6bab47 (patch) | |
tree | 238213de708d052358456789d6dd0b43325e1749 /player | |
parent | a3648ddac8382e2144feec6485328c6e53ae0062 (diff) | |
download | mpv-17d9abd08fb77d3a33b4717b29257a27ee6bab47.tar.bz2 mpv-17d9abd08fb77d3a33b4717b29257a27ee6bab47.tar.xz |
player/command: handle runtime toggling of hidpi-window-scale
Wayland was the only backend that attempted this, but it can be done in
a centralized place for anything that supports this. hidpi-window-scale
is just the same as a normal window scale but with the OS DPI as the
factor.
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c index e81874010b..a286dc2d4a 100644 --- a/player/command.c +++ b/player/command.c @@ -2626,6 +2626,26 @@ static int mp_property_hidpi_scale(void *ctx, struct m_property *prop, return m_property_double_ro(action, arg, cmd->cached_window_scale); } +static void update_hidpi_window_scale(struct MPContext *mpctx, bool hidpi_scale) +{ + struct command_ctx *cmd = mpctx->command_ctx; + struct vo *vo = mpctx->video_out; + if (!vo || cmd->cached_window_scale <= 0) + return; + + double scale = hidpi_scale ? cmd->cached_window_scale : 1 / cmd->cached_window_scale; + + int s[2]; + if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 || s[0] < 1 || s[1] < 1) + return; + + s[0] *= scale; + s[1] *= scale; + if (s[0] <= 0 || s[1] <= 0) + return; + vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s); +} + static int mp_property_focused(void *ctx, struct m_property *prop, int action, void *arg) { @@ -7192,6 +7212,9 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, if (opt_ptr == &opts->vo->window_scale) update_window_scale(mpctx); + if (opt_ptr == &opts->vo->hidpi_window_scale) + update_hidpi_window_scale(mpctx, opts->vo->hidpi_window_scale); + if (opt_ptr == &opts->cursor_autohide_delay) mpctx->mouse_timer = 0; |