summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-08-07 14:59:47 +0300
committeravih <avih@users.noreply.github.com>2021-08-07 17:30:19 +0300
commit2667dd66437723580f80671933b55963cc6bc8f5 (patch)
treecb074da3ee29ee24aa2c9dd4ef93650b902091eb /player
parent19c4ae004a14617c8ecff191119723d0b7731b0c (diff)
downloadmpv-2667dd66437723580f80671933b55963cc6bc8f5.tar.bz2
mpv-2667dd66437723580f80671933b55963cc6bc8f5.tar.xz
Revert "command: make current-window-scale writeable"
This reverts commit 873ae0de2af3bb84a11e5e57f6e3a8942b2263c2. The next commit will restore this functionality, with the following differences from the reverted commit: - Smaller and simpler code change. - On bad scale: use "Invalid value" (compared to "no such property"). - Doesn't combine the docs for window-scale and current-window-scale. - Doesn't remove the docs for window-scale behavior prior to 0.31.0.
Diffstat (limited to 'player')
-rw-r--r--player/command.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/player/command.c b/player/command.c
index 0a66bbcbac..5119857986 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2316,55 +2316,46 @@ static int mp_property_video_frame_info(void *ctx, struct m_property *prop,
return m_property_read_sub(props, action, arg);
}
-static int update_window_scale(struct MPContext *mpctx, double scale)
+static int mp_property_current_window_scale(void *ctx, struct m_property *prop,
+ int action, void *arg)
{
+ MPContext *mpctx = ctx;
struct vo *vo = mpctx->video_out;
if (!vo)
- return -1;
+ return M_PROPERTY_UNAVAILABLE;
struct mp_image_params params = get_video_out_params(mpctx);
int vid_w, vid_h;
mp_image_params_get_dsize(&params, &vid_w, &vid_h);
if (vid_w < 1 || vid_h < 1)
- return -1;
+ return M_PROPERTY_UNAVAILABLE;
- int s[2] = {vid_w * scale, vid_h * scale};
- if (s[0] > 0 && s[1] > 0)
- vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
- return 0;
+ int s[2];
+ if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
+ s[0] < 1 || s[1] < 1)
+ return M_PROPERTY_UNAVAILABLE;
+
+ double xs = (double)s[0] / vid_w;
+ double ys = (double)s[1] / vid_h;
+ return m_property_double_ro(action, arg, (xs + ys) / 2);
}
-static int mp_property_current_window_scale(void *ctx, struct m_property *prop,
- int action, void *arg)
+static void update_window_scale(struct MPContext *mpctx)
{
- MPContext *mpctx = ctx;
struct vo *vo = mpctx->video_out;
if (!vo)
- return M_PROPERTY_UNAVAILABLE;
-
- switch (action) {
- case M_PROPERTY_SET:
- if (update_window_scale(mpctx, *(double *)arg) < 0)
- return M_PROPERTY_UNAVAILABLE;
- return M_PROPERTY_OK;
- case M_PROPERTY_GET_TYPE:
- case M_PROPERTY_GET: ;
- struct mp_image_params params = get_video_out_params(mpctx);
- int vid_w, vid_h;
- mp_image_params_get_dsize(&params, &vid_w, &vid_h);
- if (vid_w < 1 || vid_h < 1)
- return M_PROPERTY_UNAVAILABLE;
+ return;
- int s[2];
- if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
- s[0] < 1 || s[1] < 1)
- return M_PROPERTY_UNAVAILABLE;
+ struct mp_image_params params = get_video_out_params(mpctx);
+ int vid_w, vid_h;
+ mp_image_params_get_dsize(&params, &vid_w, &vid_h);
+ if (vid_w < 1 || vid_h < 1)
+ return;
- double xs = (double)s[0] / vid_w;
- double ys = (double)s[1] / vid_h;
- return m_property_double_ro(action, arg, (xs + ys) / 2);
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
+ double scale = mpctx->opts->vo->window_scale;
+ int s[2] = {vid_w * scale, vid_h * scale};
+ if (s[0] > 0 && s[1] > 0)
+ vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
}
static int mp_property_display_fps(void *ctx, struct m_property *prop,
@@ -6710,7 +6701,7 @@ 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, opts->vo->window_scale);
+ update_window_scale(mpctx);
if (opt_ptr == &opts->cursor_autohide_delay)
mpctx->mouse_timer = 0;