summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.c
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/x11_common.c
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/x11_common.c')
-rw-r--r--video/out/x11_common.c21
1 files changed, 13 insertions, 8 deletions
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) {