1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 17:12:36 +00:00

command: if window-scale can't be set properly, set it as option

Kind of sketchy, but happens to fix #3724.
This commit is contained in:
wm4 2016-10-25 16:05:46 +02:00
parent 6953a1ca2f
commit ee4bed25a8

View File

@ -2747,40 +2747,35 @@ static int mp_property_window_scale(void *ctx, struct m_property *prop,
MPContext *mpctx = ctx;
struct vo *vo = mpctx->video_out;
if (!vo)
return mp_property_generic_option(mpctx, prop, action, arg);
goto generic;
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;
goto generic;
switch (action) {
case M_PROPERTY_SET: {
double scale = *(double *)arg;
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) > 0)
{
mpctx->opts->vo->window_scale = scale;
return M_PROPERTY_OK;
}
return M_PROPERTY_UNAVAILABLE;
if (s[0] > 0 && s[1] > 0)
vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
goto generic;
}
case M_PROPERTY_GET: {
int s[2];
if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
s[0] < 1 || s[1] < 1)
return M_PROPERTY_UNAVAILABLE;
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;
}
case M_PROPERTY_GET_TYPE:
return mp_property_generic_option(mpctx, prop, action, arg);
}
return M_PROPERTY_NOT_IMPLEMENTED;
generic:
return mp_property_generic_option(mpctx, prop, action, arg);
}
static int mp_property_win_minimized(void *ctx, struct m_property *prop,