From 8e793bde78f00fbb64223db30851c6d080c4abeb Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sun, 13 Dec 2020 17:44:36 -0600 Subject: 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. --- video/out/x11_common.c | 21 +++++++++++++++++++++ video/out/x11_common.h | 4 ++++ 2 files changed, 25 insertions(+) (limited to 'video/out') 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 */ -- cgit v1.2.3