summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-12-13 17:44:36 -0600
committerDudemanguy <random342@airmail.cc>2020-12-14 22:44:05 +0000
commit8e793bde78f00fbb64223db30851c6d080c4abeb (patch)
treecb7761ab42885c5dc09e84e4ada26490720e5028
parent04018c306196888861775b248a8596ae494f122b (diff)
downloadmpv-8e793bde78f00fbb64223db30851c6d080c4abeb.tar.bz2
mpv-8e793bde78f00fbb64223db30851c6d080c4abeb.tar.xz
x11: update geometry/autofit opts on runtime
If the window is maximized, we can't change the size immediately. In that case, we set a bool and wait for the state to change before triggering the resize.
-rw-r--r--video/out/x11_common.c21
-rw-r--r--video/out/x11_common.h4
2 files changed, 25 insertions, 0 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 1d59b89ea8..ac551fae8e 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1037,6 +1037,11 @@ static void vo_x11_check_net_wm_state_change(struct vo *vo)
XFree(elems);
}
+ if (opts->window_maximized && !is_maximized && x11->pending_geometry_change) {
+ vo_x11_config_vo_window(vo);
+ x11->pending_geometry_change = false;
+ }
+
opts->window_minimized = is_minimized;
m_config_cache_write_opt(x11->opts_cache, &opts->window_minimized);
opts->window_maximized = is_maximized;
@@ -1838,6 +1843,17 @@ static void vo_x11_minimize(struct vo *vo)
}
}
+static void vo_x11_set_geometry(struct vo *vo)
+{
+ struct vo_x11_state *x11 = vo->x11;
+
+ if (x11->opts->window_maximized) {
+ x11->pending_geometry_change = true;
+ } else {
+ vo_x11_config_vo_window(vo);
+ }
+}
+
int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
{
struct vo_x11_state *x11 = vo->x11;
@@ -1871,6 +1887,11 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
vo_x11_minimize(vo);
if (opt == &opts->window_maximized)
vo_x11_maximize(vo);
+ if (opt == &opts->geometry || opt == &opts->autofit ||
+ opt == &opts->autofit_smaller || opt == &opts->autofit_larger)
+ {
+ vo_x11_set_geometry(vo);
+ }
}
return VO_TRUE;
}
diff --git a/video/out/x11_common.h b/video/out/x11_common.h
index 774a76afbe..45c8d04d21 100644
--- a/video/out/x11_common.h
+++ b/video/out/x11_common.h
@@ -111,6 +111,10 @@ 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;
+
XComposeStatus compose_status;
/* XShm stuff */