command: shuffle around even more crap

Convert some remaining properties to work without the option-to-property
bridge. Behavior shouldn't change (except for the corner case that it
tries to reapply the new state when setting a property, while it used to
ignore redundant sets).

As it is the case with many of these changes, much of the code is not in
its final proper state yet, but is rather a temporary workaround. For
example, these "VO flag" properties should just be fully handled in the
VO backend. (Currently, the config or VO layers don't provide enough
mechanism yet as that all the backends like x11, win32, etc. could be
changed yet, but that's another refactoring mess for another time.)

Now nothing relies on this option-to-property bridge anymore, which
opens the way to even more refactoring, which eventually may result in
tiny improvements for the end user.
This commit is contained in:
wm4 2019-11-25 20:17:29 +01:00
parent fba7c69b8a
commit 78bb1586d3
2 changed files with 23 additions and 79 deletions

View File

@ -2104,77 +2104,6 @@ static int mp_property_hwdec_interop(void *ctx, struct m_property *prop,
return res;
}
/// Helper to set vo flags.
/** \ingroup PropertyImplHelper
*/
static int mp_property_vo_flag(struct m_property *prop, int action, void *arg,
int vo_ctrl, int *vo_var, MPContext *mpctx)
{
int old = *vo_var;
int res = mp_property_generic_option(mpctx, prop, action, arg);
if (action == M_PROPERTY_SET && old != *vo_var) {
if (mpctx->video_out)
vo_control(mpctx->video_out, vo_ctrl, 0);
}
return res;
}
/// Fullscreen state (RW)
static int mp_property_fullscreen(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
int oldval = mpctx->opts->vo->fullscreen;
int r = mp_property_vo_flag(prop, action, arg, VOCTRL_FULLSCREEN,
&mpctx->opts->vo->fullscreen, mpctx);
if (oldval && oldval != mpctx->opts->vo->fullscreen)
mpctx->mouse_event_ts--; // Show mouse cursor
return r;
}
/// Show playback progress in Windows 7+ taskbar (RW)
static int mp_property_taskbar_progress(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
if (action == M_PROPERTY_SET) {
int desired = !!*(int *) arg;
if (mpctx->opts->vo->taskbar_progress == desired)
return M_PROPERTY_OK;
mpctx->opts->vo->taskbar_progress = desired;
if (mpctx->video_out)
update_vo_playback_state(mpctx);
return M_PROPERTY_OK;
}
return mp_property_generic_option(mpctx, prop, action, arg);
}
/// Window always on top (RW)
static int mp_property_ontop(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP,
&mpctx->opts->vo->ontop, mpctx);
}
/// Show window borders (RW)
static int mp_property_border(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER,
&mpctx->opts->vo->border, mpctx);
}
static int mp_property_all_workspaces(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
return mp_property_vo_flag(prop, action, arg, VOCTRL_ALL_WORKSPACES,
&mpctx->opts->vo->all_workspaces, mpctx);
}
static int get_frame_count(struct MPContext *mpctx)
{
struct demuxer *demuxer = mpctx->demuxer;
@ -3464,11 +3393,6 @@ static const struct m_property mp_properties_base[] = {
{"current-ao", mp_property_ao},
// Video
{"fullscreen", mp_property_fullscreen},
{"taskbar-progress", mp_property_taskbar_progress},
{"ontop", mp_property_ontop},
{"border", mp_property_border},
{"on-all-workspaces", mp_property_all_workspaces},
{"video-out-params", mp_property_vo_imgparams},
{"video-dec-params", mp_property_dec_imgparams},
{"video-params", mp_property_vd_imgparams},
@ -6297,6 +6221,23 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags)
}
}
}
if (mpctx->video_out) {
if (opt_ptr == &opts->vo->fullscreen) {
vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0);
if (!opts->vo->fullscreen)
mpctx->mouse_event_ts--; // Show mouse cursor
}
if (opt_ptr == &opts->vo->ontop)
vo_control(mpctx->video_out, VOCTRL_ONTOP, 0);
if (opt_ptr == &opts->vo->border)
vo_control(mpctx->video_out, VOCTRL_BORDER, 0);
if (opt_ptr == &opts->vo->all_workspaces)
vo_control(mpctx->video_out, VOCTRL_ALL_WORKSPACES, 0);
}
if (opt_ptr == &opts->vo->taskbar_progress)
update_vo_playback_state(mpctx);
}
void mp_notify_property(struct MPContext *mpctx, const char *property)

View File

@ -840,10 +840,13 @@ static void handle_vo_events(struct MPContext *mpctx)
if (events & VO_EVENT_FULLSCREEN_STATE) {
// The only purpose of this is to update the fullscreen flag on the
// playloop side if it changes "from outside" on the VO.
int fs = mpctx->opts->vo->fullscreen;
int old_fs = mpctx->opts->vo->fullscreen;
int fs = old_fs;
vo_control(vo, VOCTRL_GET_FULLSCREEN, &fs);
m_config_set_option_raw_direct(mpctx->mconfig,
m_config_get_co(mpctx->mconfig, bstr0("fullscreen")), &fs, 0);
if (old_fs != fs) {
m_config_set_option_raw_direct(mpctx->mconfig,
m_config_get_co(mpctx->mconfig, bstr0("fullscreen")), &fs, 0);
}
}
}