summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-11-07 18:36:26 -0600
committeravih <avih@users.noreply.github.com>2021-08-07 17:30:19 +0300
commita0441ddb5e1a494275dcb8235268cd113babc491 (patch)
tree3ecd9be906ef83a34f908302433ab89baf73b847 /player
parent2667dd66437723580f80671933b55963cc6bc8f5 (diff)
downloadmpv-a0441ddb5e1a494275dcb8235268cd113babc491.tar.bz2
mpv-a0441ddb5e1a494275dcb8235268cd113babc491.tar.xz
command: make current-window-scale writeable, 2nd attempt
The window-scale property mirrors the respective option (not the effective scale derived from the current window size), and as such setting its value to the same value it had before has no effect. Specifically - the window will not resize. This is consistent as far as property-option bridge behavior goes, but we do end up with an issue that we can't set an arbitrary scale and expect the window to always resize accordingly. We do also have a current-window-scale property which does reflect the actual window size, however, it's been read-only till now. This commit makes current-window-scale RW so that it's now always possible to set an arbitrary scale and expect the window to resize accordingly (without affecting window-scale - like manual resize). Also, mention window-scale no-effect-if-not-changed at the docs. Based on code by @Dudemanguy from commit 873ae0d, with same effect.
Diffstat (limited to 'player')
-rw-r--r--player/command.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 5119857986..02a008ef57 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2330,6 +2330,15 @@ static int mp_property_current_window_scale(void *ctx, struct m_property *prop,
if (vid_w < 1 || vid_h < 1)
return M_PROPERTY_UNAVAILABLE;
+ if (action == M_PROPERTY_SET) {
+ double scale = *(double *)arg;
+ int s[2] = {vid_w * scale, vid_h * scale};
+ if (s[0] <= 0 || s[1] <= 0)
+ return M_PROPERTY_INVALID_FORMAT;
+ vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
+ return M_PROPERTY_OK;
+ }
+
int s[2];
if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
s[0] < 1 || s[1] < 1)