mirror of https://github.com/mpv-player/mpv
command: unify handling of fullscreen and other VO flags
The "ontop" and "border" properties already used a common mp_property_vo_flag() function, and the corresponding VOCTRLs used the same conventions. "fullscreen" is pretty similar, but was handled slightly similar. Change how VOCTRL_FULLSCREEN behaves, and use the same helper function for "fullscreen" as the other flags.
This commit is contained in:
parent
1883b7cc0c
commit
fc524e8a07
|
@ -1986,25 +1986,6 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop,
|
|||
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||
}
|
||||
|
||||
/// Fullscreen state (RW)
|
||||
static int mp_property_fullscreen(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
if (!mpctx->video_out)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
struct mp_vo_opts *opts = mpctx->video_out->opts;
|
||||
|
||||
if (action == M_PROPERTY_SET) {
|
||||
int val = *(int *)arg;
|
||||
opts->fullscreen = val;
|
||||
if (mpctx->video_out->config_ok)
|
||||
vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0);
|
||||
return opts->fullscreen == val ? M_PROPERTY_OK : M_PROPERTY_ERROR;
|
||||
}
|
||||
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||
}
|
||||
|
||||
#define VF_DEINTERLACE_LABEL "deinterlace"
|
||||
|
||||
static bool probe_deint_filter(struct MPContext *mpctx, const char *filt)
|
||||
|
@ -2254,15 +2235,25 @@ static int mp_property_vo_flag(struct m_property *prop, int action, void *arg,
|
|||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
if (action == M_PROPERTY_SET) {
|
||||
if (*vo_var == !!*(int *) arg)
|
||||
int desired = !!*(int *) arg;
|
||||
if (*vo_var == desired)
|
||||
return M_PROPERTY_OK;
|
||||
if (mpctx->video_out->config_ok)
|
||||
vo_control(mpctx->video_out, vo_ctrl, 0);
|
||||
return M_PROPERTY_OK;
|
||||
return *vo_var == desired ? M_PROPERTY_OK : M_PROPERTY_ERROR;
|
||||
}
|
||||
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||
}
|
||||
|
||||
/// Fullscreen state (RW)
|
||||
static int mp_property_fullscreen(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
return mp_property_vo_flag(prop, action, arg, VOCTRL_FULLSCREEN,
|
||||
&mpctx->opts->vo.fullscreen, mpctx);
|
||||
}
|
||||
|
||||
/// Window always on top (RW)
|
||||
static int mp_property_ontop(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
|
|
|
@ -581,6 +581,8 @@ static void vo_cocoa_fullscreen(struct vo *vo)
|
|||
if (s->embedded)
|
||||
return;
|
||||
|
||||
opts->fullscreen = !opts->fullscreen;
|
||||
|
||||
vo_cocoa_update_screen_info(vo, NULL);
|
||||
|
||||
draw_changes_after_next_frame(vo);
|
||||
|
|
|
@ -1001,6 +1001,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
|||
|
||||
switch (request) {
|
||||
case VOCTRL_FULLSCREEN:
|
||||
vo->opts->fullscreen = !vo->opts->fullscreen;
|
||||
set_fullscreen(vo);
|
||||
return 1;
|
||||
case VOCTRL_REDRAW_FRAME:
|
||||
|
|
|
@ -1215,6 +1215,7 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg)
|
|||
{
|
||||
switch (request) {
|
||||
case VOCTRL_FULLSCREEN:
|
||||
w32->opts->fullscreen = !w32->opts->fullscreen;
|
||||
if (w32->opts->fullscreen != w32->current_fs)
|
||||
reinit_window_state(w32);
|
||||
return VO_TRUE;
|
||||
|
|
|
@ -1189,6 +1189,7 @@ int vo_wayland_control (struct vo *vo, int *events, int request, void *arg)
|
|||
*events |= vo_wayland_check_events(vo);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_FULLSCREEN:
|
||||
vo->opts->fullscreen = !vo->opts->fullscreen;
|
||||
vo_wayland_fullscreen(vo);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_ONTOP:
|
||||
|
|
|
@ -1615,12 +1615,14 @@ static void vo_x11_border(struct vo *vo)
|
|||
|
||||
int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
||||
{
|
||||
struct mp_vo_opts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
switch (request) {
|
||||
case VOCTRL_CHECK_EVENTS:
|
||||
*events |= vo_x11_check_events(vo);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_FULLSCREEN:
|
||||
opts->fullscreen = !opts->fullscreen;
|
||||
vo_x11_fullscreen(vo);
|
||||
*events |= VO_EVENT_RESIZE;
|
||||
return VO_TRUE;
|
||||
|
|
Loading…
Reference in New Issue