summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-29 13:49:33 +0100
committerwm4 <wm4@nowhere>2019-11-29 13:56:58 +0100
commit40c2f2eeb05f83176d325d4efd7a2e1635447f04 (patch)
tree8cd822c02ba57aac71b4e7891990f64d739cf9d6
parentd37e461eab16f990751d3ab9a459cad600e3b510 (diff)
downloadmpv-40c2f2eeb05f83176d325d4efd7a2e1635447f04.tar.bz2
mpv-40c2f2eeb05f83176d325d4efd7a2e1635447f04.tar.xz
command: change window-minimized/window-maximized to options
Unfortunately, this breaks window state reporting for all VOs which supported it. This can be fixed later (for x11 in the next commit).
-rw-r--r--DOCS/man/input.rst10
-rw-r--r--DOCS/man/options.rst17
-rw-r--r--options/options.c2
-rw-r--r--options/options.h2
-rw-r--r--player/command.c54
-rw-r--r--video/out/vo.h7
6 files changed, 28 insertions, 64 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 57261c39d0..c96fd57300 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -2017,16 +2017,6 @@ Property list
(or to be exact, the size the video filters output). ``2`` will set the
double size, ``0.5`` halves the size.
-``window-maximized`` (RW)
- Whether the video window is maximized or not. Setting this will maximize,
- or unmaximize, the video window if the current VO supports it.
-
-``window-minimized`` (RW)
- Whether the video window is minimized or not. Setting this will minimize,
- or unminimze, the video window if the current VO supports it. Note that
- some VOs may support minimization while not supporting unminimization
- (eg: X11 and Wayland).
-
``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
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index fde338ceb6..7c36cb657a 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2807,6 +2807,23 @@ Window
For example, ``--window-scale=0.5`` would show the window at half the
video size.
+``--window-minimized=<yes|no>``
+ Whether the video window is minimized or not. Setting this will minimize,
+ or unminimze, the video window if the current VO supports it. Note that
+ some VOs may support minimization while not supporting unminimization
+ (eg: X11 and Wayland).
+
+ Whether this option and ``--window-maximized`` work on program start or
+ at runtime, and whether they're (at runtime) updated to reflect the actual
+ window state, heavily depends on the VO and the windowing system. Some VOs
+ simply do not implement them or parts of them, while other VOs may be
+ restricted by the windowing systems (especially Wayland).
+
+``--window-maximized=<yes|no>``
+ Whether the video window is maximized or not. Setting this will maximize,
+ or unmaximize, the video window if the current VO supports it. See
+ ``--window-minimized`` for further remarks.
+
``--cursor-autohide=<number|no|always>``
Make mouse cursor automatically hide after given number of milliseconds.
``no`` will disable cursor autohide. ``always`` means the cursor will stay
diff --git a/options/options.c b/options/options.c
index ee226843c2..7cb750d81b 100644
--- a/options/options.c
+++ b/options/options.c
@@ -119,6 +119,8 @@ static const m_option_t mp_vo_opt_list[] = {
OPT_SIZE_BOX("autofit-larger", autofit_larger, 0),
OPT_SIZE_BOX("autofit-smaller", autofit_smaller, 0),
OPT_DOUBLE("window-scale", window_scale, CONF_RANGE, .min = 0.001, .max = 100),
+ OPT_FLAG("window-minimized", window_minimized, 0),
+ OPT_FLAG("window-maximized", window_maximized, 0),
OPT_FLAG("force-window-position", force_window_position, 0),
OPT_STRING("x11-name", winname, 0),
OPT_FLOATRANGE("monitoraspect", force_monitor_aspect, 0, 0.0, 9.0),
diff --git a/options/options.h b/options/options.h
index 1935888032..e20e2c937a 100644
--- a/options/options.h
+++ b/options/options.h
@@ -17,6 +17,8 @@ typedef struct mp_vo_opts {
int border;
int fit_border;
int all_workspaces;
+ int window_minimized;
+ int window_maximized;
int screen_id;
int fsscreen_id;
diff --git a/player/command.c b/player/command.c
index 10359e2352..9e42b8367d 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2289,54 +2289,6 @@ static void update_window_scale(struct MPContext *mpctx)
vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
}
-static int mp_property_win_minimized(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_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,
int action, void *arg)
{
@@ -3439,8 +3391,6 @@ static const struct m_property mp_properties_base[] = {
PROPERTY_BITRATE("audio-bitrate", false, STREAM_AUDIO),
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},
@@ -6220,6 +6170,10 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
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->window_minimized)
+ vo_control(mpctx->video_out, VOCTRL_MINIMIZE, 0);
+ if (opt_ptr == &opts->vo->window_maximized)
+ vo_control(mpctx->video_out, VOCTRL_MAXIMIZE, 0);
}
if (opt_ptr == &opts->vo->taskbar_progress)
diff --git a/video/out/vo.h b/video/out/vo.h
index 68d8273937..8ff99db07d 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -92,6 +92,8 @@ enum mp_voctrl {
VOCTRL_ALL_WORKSPACES,
VOCTRL_GET_FULLSCREEN,
VOCTRL_GET_WIN_STATE, // int* (VO_WIN_STATE_* flags)
+ VOCTRL_MAXIMIZE,
+ VOCTRL_MINIMIZE,
VOCTRL_UPDATE_WINDOW_TITLE, // char*
VOCTRL_UPDATE_PLAYBACK_STATE, // struct voctrl_playback_state*
@@ -130,12 +132,9 @@ enum mp_voctrl {
/* private to vo_gpu */
VOCTRL_EXTERNAL_RESIZE,
-
- VOCTRL_MAXIMIZE,
- VOCTRL_MINIMIZE,
};
-// VOCTRL_GET_WIN_STATE
+// VOCTRL_GET_WIN_STATE (legacy, ignored)
#define VO_WIN_STATE_MINIMIZED (1 << 0)
#define VO_WIN_STATE_MAXIMIZED (1 << 1)