summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/options.rst7
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
-rw-r--r--video/out/w32_common.c5
-rw-r--r--video/out/wayland_common.c6
-rw-r--r--video/out/x11_common.c21
-rw-r--r--video/out/x11_common.h5
8 files changed, 34 insertions, 14 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 785a39b1e7..5908367e90 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -58,6 +58,7 @@ Interface changes
- change type of `--brightness`, `--saturation`, `--contrast`, `--hue` and
`--gamma` to float.
- add `platform` property
+ - add `--auto-window-resize`
--- mpv 0.35.0 ---
- add the `--vo=gpu-next` video output driver, as well as the options
`--allow-delayed-peak-detect`, `--builtin-scalers`,
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 95b7853d81..a90c406a4b 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -3266,6 +3266,13 @@ Window
there is a change in video parameters, video stream or file. This used to
be the default behavior. Currently only affects X11 VOs.
+``--auto-window-resize=<yes|no>``
+ (Wayland, Win32, and X11)
+ By default, mpv will automatically resize itself if the video's size changes
+ (i.e. advancing forward in a playlist). Setting this to ``no`` disables this
+ behavior so the window size never changes automatically. This option does
+ not have any impact on the ``--autofit`` or ``--geometry`` options.
+
``--no-keepaspect``, ``--keepaspect``
``--no-keepaspect`` will always stretch the video to window size, and will
disable the window manager hints that force the window aspect ratio.
diff --git a/options/options.c b/options/options.c
index 2beb5d01b8..1e49731709 100644
--- a/options/options.c
+++ b/options/options.c
@@ -118,6 +118,7 @@ static const m_option_t mp_vo_opt_list[] = {
{"autofit", OPT_SIZE_BOX(autofit)},
{"autofit-larger", OPT_SIZE_BOX(autofit_larger)},
{"autofit-smaller", OPT_SIZE_BOX(autofit_smaller)},
+ {"auto-window-resize", OPT_BOOL(auto_window_resize)},
{"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)},
{"window-minimized", OPT_BOOL(window_minimized)},
{"window-maximized", OPT_BOOL(window_maximized)},
@@ -201,6 +202,7 @@ const struct m_sub_options vo_sub_opts = {
.panscan = 0.0f,
.scale_x = 1.0f,
.scale_y = 1.0f,
+ .auto_window_resize = true,
.keepaspect = true,
.keepaspect_window = true,
.hidpi_window_scale = true,
diff --git a/options/options.h b/options/options.h
index 2830a7a14d..a44a8253a3 100644
--- a/options/options.h
+++ b/options/options.h
@@ -48,6 +48,7 @@ typedef struct mp_vo_opts {
struct m_geometry autofit_smaller;
double window_scale;
+ bool auto_window_resize;
bool keepaspect;
bool keepaspect_window;
bool hidpi_window_scale;
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index 4ef57dc53d..64d69d8242 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -1438,8 +1438,9 @@ static void gui_thread_reconfig(void *ptr)
vo_calc_window_geometry3(vo, &screen, &mon, w32->dpi_scale, &geo);
vo_apply_window_geometry(vo, &geo);
- bool reset_size = w32->o_dwidth != vo->dwidth ||
- w32->o_dheight != vo->dheight;
+ bool reset_size = (w32->o_dwidth != vo->dwidth ||
+ w32->o_dheight != vo->dheight) &&
+ w32->opts->auto_window_resize;
w32->o_dwidth = vo->dwidth;
w32->o_dheight = vo->dheight;
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 192231bb65..ee4ac030dd 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -2217,7 +2217,11 @@ bool vo_wayland_reconfig(struct vo *vo)
wl->pending_vo_events |= VO_EVENT_DPI;
}
- set_geometry(wl, false);
+ if (wl->vo_opts->auto_window_resize || mp_rect_w(wl->geometry) == 0 ||
+ mp_rect_h(wl->geometry) == 0)
+ {
+ set_geometry(wl, false);
+ }
if (wl->opts->configure_bounds)
set_window_bounds(wl);
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index e8054f3b55..0b028b9122 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1092,9 +1092,9 @@ static void vo_x11_check_net_wm_state_change(struct vo *vo)
XFree(elems);
}
- if (opts->window_maximized && !is_maximized && x11->pending_geometry_change) {
+ if (opts->window_maximized && !is_maximized && x11->geometry_change) {
+ x11->geometry_change = false;
vo_x11_config_vo_window(vo);
- x11->pending_geometry_change = false;
}
opts->window_minimized = is_minimized;
@@ -1722,6 +1722,10 @@ void vo_x11_config_vo_window(struct vo *vo)
assert(x11->window);
+ // Don't attempt to change autofit/geometry on maximized windows.
+ if (x11->geometry_change && opts->window_maximized)
+ return;
+
vo_x11_update_screeninfo(vo);
struct vo_win_geometry geo;
@@ -1735,7 +1739,9 @@ void vo_x11_config_vo_window(struct vo *vo)
rc = (struct mp_rect){0, 0, RC_W(x11->winrc), RC_H(x11->winrc)};
}
- bool reset_size = x11->old_dw != RC_W(rc) || x11->old_dh != RC_H(rc);
+ bool reset_size = (x11->old_dw != RC_W(rc) || x11->old_dh != RC_H(rc)) &&
+ (opts->auto_window_resize || x11->geometry_change);
+
x11->old_dw = RC_W(rc);
x11->old_dh = RC_H(rc);
@@ -1746,6 +1752,8 @@ void vo_x11_config_vo_window(struct vo *vo)
vo_x11_highlevel_resize(vo, rc);
}
+ x11->geometry_change = false;
+
if (opts->ontop)
vo_x11_setlayer(vo, opts->ontop);
@@ -1961,11 +1969,8 @@ static void vo_x11_set_geometry(struct vo *vo)
if (!x11->window)
return;
- if (x11->opts->window_maximized) {
- x11->pending_geometry_change = true;
- } else {
- vo_x11_config_vo_window(vo);
- }
+ x11->geometry_change = true;
+ vo_x11_config_vo_window(vo);
}
bool vo_x11_check_visible(struct vo *vo) {
diff --git a/video/out/x11_common.h b/video/out/x11_common.h
index 48516a77ad..de17113c55 100644
--- a/video/out/x11_common.h
+++ b/video/out/x11_common.h
@@ -118,9 +118,8 @@ struct vo_x11_state {
bool size_changed_during_fs;
bool pos_changed_during_fs;
- /* The geometry/autofit option was changed while the window was maximized.
- * Wait until the state changes to resize. */
- bool pending_geometry_change;
+ /* One of the autofit/geometry options changed at runtime. */
+ bool geometry_change;
XComposeStatus compose_status;