summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-10-19 21:47:23 -0500
committerDudemanguy <random342@airmail.cc>2023-03-02 02:55:36 +0000
commitc993d5c0ce79ab560e86da8d6d5fe25da35b4c78 (patch)
treef6833a88bf313984df738d1cecca875455aa2370 /video/out
parentcd02b5ccf6426645796b18c0692a5c4ca1f83174 (diff)
downloadmpv-c993d5c0ce79ab560e86da8d6d5fe25da35b4c78.tar.bz2
mpv-c993d5c0ce79ab560e86da8d6d5fe25da35b4c78.tar.xz
player: add --auto-window-resize option
mpv's window resizing logic always automatically resized the window whenever the video resolution changed (i.e. advancing forward in a playlist). This simply introduces the option to make this behavior configurable. Every windowing backend would need to implement this behavior in their code since a reconfigure event must always be a resize. The params of the frame changed so you either have to resize the window to the new size of the params or make the params the same size as the window. This commit implements it for wayland, win32, and x11.
Diffstat (limited to 'video/out')
-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
4 files changed, 23 insertions, 14 deletions
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;