diff options
author | Philip Langdale <philipl@overt.org> | 2019-11-26 08:46:47 +0800 |
---|---|---|
committer | Philip Langdale <github.philipl@overt.org> | 2019-11-29 16:56:20 +0800 |
commit | c2bd3b1eccd90c6b579e6661ffc2d077119508c2 (patch) | |
tree | a64cf82dba2380a5107040953fef382b8609fccf /player | |
parent | f3c2f1f6aa969001a74455061637cc7e194f614a (diff) | |
download | mpv-c2bd3b1eccd90c6b579e6661ffc2d077119508c2.tar.bz2 mpv-c2bd3b1eccd90c6b579e6661ffc2d077119508c2.tar.xz |
command: add `window-maximized` and make `window-minimized` settable
If we want to implement window pseudo-decorations via OSC, we need a
way to tell the vo to minimize and maximize the window. Today, we have
minimized as a read-only property, and no property for maximized.
Let's made minimized settable and add a maximized property to go with
it. In turn, that requires us to add VOCTRLs for minimizing or
maximizing a window, and an additional WIN_STATE to indicate a
maximized window.
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/player/command.c b/player/command.c index cd8a7959c8..475552e28e 100644 --- a/player/command.c +++ b/player/command.c @@ -2299,7 +2299,40 @@ static int mp_property_win_minimized(void *ctx, struct m_property *prop, if (vo_control(vo, VOCTRL_GET_WIN_STATE, &state) < 1) return M_PROPERTY_UNAVAILABLE; - return m_property_flag_ro(action, arg, state & VO_WIN_STATE_MINIMIZED); + switch (action) { + case M_PROPERTY_SET: + vo_control(vo, VOCTRL_MINIMIZE, 0); + return M_PROPERTY_OK; + case M_PROPERTY_GET: + case M_PROPERTY_GET_TYPE: + return m_property_flag_ro(action, arg, state & VO_WIN_STATE_MINIMIZED); + default: + return M_PROPERTY_NOT_IMPLEMENTED; + } +} + +static int mp_property_win_maximized(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + struct vo *vo = mpctx->video_out; + if (!vo) + return M_PROPERTY_UNAVAILABLE; + + int state = 0; + if (vo_control(vo, VOCTRL_GET_WIN_STATE, &state) < 1) + return M_PROPERTY_UNAVAILABLE; + + switch (action) { + case M_PROPERTY_SET: + vo_control(vo, VOCTRL_MAXIMIZE, 0); + return M_PROPERTY_OK; + case M_PROPERTY_GET: + case M_PROPERTY_GET_TYPE: + return m_property_flag_ro(action, arg, state & VO_WIN_STATE_MAXIMIZED); + default: + return M_PROPERTY_NOT_IMPLEMENTED; + } } static int mp_property_display_fps(void *ctx, struct m_property *prop, @@ -3405,6 +3438,7 @@ static const struct m_property mp_properties_base[] = { PROPERTY_BITRATE("sub-bitrate", false, STREAM_SUB), {"window-minimized", mp_property_win_minimized}, + {"window-maximized", mp_property_win_maximized}, {"display-names", mp_property_display_names}, {"display-fps", mp_property_display_fps}, {"estimated-display-fps", mp_property_estimated_display_fps}, @@ -3484,7 +3518,7 @@ static const char *const *const mp_event_property_change[] = { "demuxer-cache-state"), E(MP_EVENT_WIN_RESIZE, "window-scale", "osd-width", "osd-height", "osd-par"), E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps", - "fullscreen"), + "fullscreen", "window-maximized"), E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1", "playlist-count", "playlist/count"), E(MP_EVENT_CORE_IDLE, "core-idle", "eof-reached"), @@ -3704,6 +3738,8 @@ static const struct property_osd_display { // By default, don't display the following properties on OSD {"pause", NULL}, {"fullscreen", NULL}, + {"window-minimized", NULL}, + {"window-maximized", NULL}, {0} }; |