mirror of https://github.com/mpv-player/mpv
command: change "window-scale" property behavior
This is similar to the "edition" change. I considered making this go through deprecation, but didn't have a good idea how to do that. Maybe it's fine, because this is pretty obscure. But it might break some API users/scripts (it certainly broke stats.lua), and all I have to say is sorry for that.
This commit is contained in:
parent
9800855895
commit
d07b7f068d
|
@ -67,6 +67,10 @@ Interface changes
|
|||
be queried to read the runtime-chosen edition. This is a breaking change
|
||||
for any users which expected "edition" to return the runtime-chosen
|
||||
edition at default settings (--edition=auto).
|
||||
- the "window-scale" property now strictly returns the value of the option,
|
||||
instead of the actual size of the window. The new "current-window-scale"
|
||||
property needs to be queried to read the value as indicated by the current
|
||||
window size. This is a breaking change.
|
||||
--- mpv 0.30.0 ---
|
||||
- add `--d3d11-output-format` to enable explicit selection of a D3D11
|
||||
swap chain format.
|
||||
|
|
|
@ -2026,6 +2026,20 @@ Property list
|
|||
(or to be exact, the size the video filters output). ``2`` will set the
|
||||
double size, ``0.5`` halves the size.
|
||||
|
||||
See ``current-window-scale`` for the value derived from the actual window
|
||||
size.
|
||||
|
||||
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.
|
||||
|
||||
``display-names``
|
||||
Names of the displays that the mpv window covers. On X11, these
|
||||
are the xrandr names (LVDS1, HDMI1, DP1, VGA1, etc.). On Windows, these
|
||||
|
@ -2731,10 +2745,6 @@ caveats with some properties (due to historical reasons):
|
|||
option is for loading playlist during command line parsing. For client API
|
||||
uses, you should use the ``loadlist`` command instead.
|
||||
|
||||
``window-scale``
|
||||
Returns the current window values if a window exists, and the option value
|
||||
otherwise.
|
||||
|
||||
``profile``, ``include``
|
||||
These are write-only, and will perform actions as they are written to,
|
||||
exactly as if they were used on the mpv CLI commandline. Their only use is
|
||||
|
|
|
@ -2226,34 +2226,28 @@ static int mp_property_video_frame_info(void *ctx, struct m_property *prop,
|
|||
return m_property_read_sub(props, action, arg);
|
||||
}
|
||||
|
||||
static int mp_property_window_scale(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
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)
|
||||
goto generic;
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
struct mp_image_params params = get_video_out_params(mpctx);
|
||||
int vid_w, vid_h;
|
||||
mp_image_params_get_dsize(¶ms, &vid_w, &vid_h);
|
||||
if (vid_w < 1 || vid_h < 1)
|
||||
goto generic;
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
switch (action) {
|
||||
case M_PROPERTY_GET: {
|
||||
int s[2];
|
||||
if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
|
||||
s[0] < 1 || s[1] < 1)
|
||||
goto generic;
|
||||
double xs = (double)s[0] / vid_w;
|
||||
double ys = (double)s[1] / vid_h;
|
||||
*(double *)arg = (xs + ys) / 2;
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
}
|
||||
generic:
|
||||
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||
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 void update_window_scale(struct MPContext *mpctx)
|
||||
|
@ -3328,7 +3322,7 @@ static const struct m_property mp_properties_base[] = {
|
|||
M_PROPERTY_ALIAS("dheight", "video-out-params/dh"),
|
||||
M_PROPERTY_ALIAS("width", "video-params/w"),
|
||||
M_PROPERTY_ALIAS("height", "video-params/h"),
|
||||
{"window-scale", mp_property_window_scale},
|
||||
{"current-window-scale", mp_property_current_window_scale},
|
||||
{"vo-configured", mp_property_vo_configured},
|
||||
{"vo-passes", mp_property_vo_passes},
|
||||
{"current-vo", mp_property_vo},
|
||||
|
@ -3449,7 +3443,8 @@ static const char *const *const mp_event_property_change[] = {
|
|||
"demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache",
|
||||
"demuxer-cache-time", "cache-buffering-state", "cache-speed",
|
||||
"demuxer-cache-state"),
|
||||
E(MP_EVENT_WIN_RESIZE, "window-scale", "osd-width", "osd-height", "osd-par"),
|
||||
E(MP_EVENT_WIN_RESIZE, "current-window-scale", "osd-width", "osd-height",
|
||||
"osd-par"),
|
||||
E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps",
|
||||
"fullscreen", "window-maximized"),
|
||||
E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",
|
||||
|
|
|
@ -506,7 +506,7 @@ local function add_video(s)
|
|||
if append(s, r["w"], {prefix="Native Resolution:"}) then
|
||||
append(s, r["h"], {prefix="x", nl="", indent=" ", prefix_sep=" ", no_prefix_markup=true})
|
||||
end
|
||||
append_property(s, "window-scale", {prefix="Window Scale:"})
|
||||
append_property(s, "current-window-scale", {prefix="Window Scale:"})
|
||||
append(s, format("%.2f", r["aspect"]), {prefix="Aspect Ratio:"})
|
||||
append(s, r["pixelformat"], {prefix="Pixel Format:"})
|
||||
|
||||
|
|
Loading…
Reference in New Issue