Revert "command: make current-window-scale writeable"

This reverts commit 873ae0de2a.

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.
This commit is contained in:
Avi Halachmi (:avih) 2021-08-07 14:59:47 +03:00 committed by avih
parent 19c4ae004a
commit 2667dd6643
4 changed files with 48 additions and 52 deletions

View File

@ -42,7 +42,6 @@ Interface changes
instead be used to specifically set the contrast to any value.
- add a `--watch-later-options` option to allow configuring which
options quit-watch-later saves
- make `current-window-scale` writeable and use it in the default input.conf
--- mpv 0.33.0 ---
- add `--d3d11-exclusive-fs` flag to enable D3D11 exclusive fullscreen mode
when the player enters fullscreen.

View File

@ -2518,20 +2518,26 @@ Property list
enabled, or after precise seeking). Files with imprecise timestamps (such
as Matroska) might lead to unstable results.
``current-window-scale`` (RW)
``window-scale`` (RW)
Window size multiplier. Setting this will resize the video window to the
values contained in ``dwidth`` and ``dheight`` multiplied with the value
set with this property. Setting ``1`` will resize to original video size
(or to be exact, the size the video filters output). ``2`` will set the
double size, ``0.5`` halves the size. When reading this property, this
returns the scale value calculated from the current window size.
double size, ``0.5`` halves the size.
The similarly named ``window-scale`` option behaves like a typical mpv
option. It does not pay attention to realtime window changes and only
updates if the user changes its value. In most cases, you probably want
to set ``current-window-scale`` directly.
See ``current-window-scale`` for the value derived from the actual window
size.
``current-window-scale`` is unavailable if no video is active.
Since mpv 0.31.0, this always returns the previously set value (or the
default value), instead of the value implied by the actual window size.
Before mpv 0.31.0, this returned what ``current-window-scale`` returns now,
after the window was created.
``current-window-scale``
The ``window-scale`` value calculated from the current window size. This
has the same value as ``window-scale`` if the window size was not changed
since setting the option, and the window size was not restricted in other
ways. The property is unavailable if no video is active.
``focused``
Whether the window has focus. Might not be supported by all VOs.

View File

@ -118,9 +118,9 @@
#6 add gamma 1
#7 add saturation -1
#8 add saturation 1
#Alt+0 set current-window-scale 0.5
#Alt+1 set current-window-scale 1.0
#Alt+2 set current-window-scale 2.0
#Alt+0 set window-scale 0.5
#Alt+1 set window-scale 1.0
#Alt+2 set window-scale 2.0
# toggle deinterlacer (automatically inserts or removes required filter)
#d cycle deinterlace
#r add sub-pos -1 # move subtitles up

View File

@ -2316,24 +2316,6 @@ 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)
{
struct vo *vo = mpctx->video_out;
if (!vo)
return -1;
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;
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;
}
static int mp_property_current_window_scale(void *ctx, struct m_property *prop,
int action, void *arg)
{
@ -2342,29 +2324,38 @@ static int mp_property_current_window_scale(void *ctx, struct m_property *prop,
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;
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;
int s[2];
if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
s[0] < 1 || s[1] < 1)
return M_PROPERTY_UNAVAILABLE;
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);
}
return M_PROPERTY_NOT_IMPLEMENTED;
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 void update_window_scale(struct MPContext *mpctx)
{
struct vo *vo = mpctx->video_out;
if (!vo)
return;
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 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;