From 96bebf09354200fe2d89cc2e48089c542f63aeac Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sun, 15 Dec 2024 12:53:46 -0600 Subject: [PATCH] x11: simplify --geometry and --auto-window-resize logic There were a few pitfalls with the way this was previously implemented because --geometry implicitly depended on --auto-window-resize being enabled to operate in a few cases. Instead, let's change the logic a bit so that instead we choose whether or not to reuse the old rc (i.e. don't resize) and use the wh_valid and xy_valid fields within the m_geometry struct instead of using x11->geometry_change. This fixes several edge cases involving setting the position with --geometry when using --auto-window-resize=no. --- video/out/x11_common.c | 14 ++++---------- video/out/x11_common.h | 4 ---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 817a6ba3a9..465584d945 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1810,22 +1810,19 @@ void vo_x11_config_vo_window(struct vo *vo) !x11->pseudo_mapped, &geo); vo_apply_window_geometry(vo, &geo); - struct mp_rect rc = geo.win; + struct mp_rect rc = !x11->pseudo_mapped || opts->auto_window_resize || opts->geometry.wh_valid || + opts->geometry.xy_valid ? geo.win : x11->nofsrc; if (x11->parent) { vo_x11_update_geometry(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)) - && opts->auto_window_resize) || x11->geometry_change; - reset_size |= (x11->old_x != rc.x0 || x11->old_y != rc.y0) && - (x11->geometry_change); + bool reset_size = ((x11->old_dw != RC_W(rc) || x11->old_dh != RC_H(rc))) || + opts->geometry.wh_valid || opts->geometry.xy_valid; x11->old_dw = RC_W(rc); x11->old_dh = RC_H(rc); - x11->old_x = rc.x0; - x11->old_y = rc.y0; if (x11->window_hidden) { x11->nofsrc = rc; @@ -1834,8 +1831,6 @@ void vo_x11_config_vo_window(struct vo *vo) vo_x11_highlevel_resize(vo, rc, geo.flags & VO_WIN_FORCE_POS); } - x11->geometry_change = false; - if (opts->ontop) vo_x11_setlayer(vo, opts->ontop); if (!opts->show_in_taskbar) @@ -2069,7 +2064,6 @@ static void vo_x11_set_geometry(struct vo *vo) if (!x11->window) return; - x11->geometry_change = true; vo_x11_config_vo_window(vo); } diff --git a/video/out/x11_common.h b/video/out/x11_common.h index f1b1f38260..e3375de65a 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -115,16 +115,12 @@ struct vo_x11_state { * stays the same (even if that size is different from the current * window size after the user modified the latter). */ int old_dw, old_dh; - int old_x, old_y; /* Video size changed during fullscreen when we couldn't tell the new * size to the window manager. Must set window size when turning * fullscreen off. */ bool size_changed_during_fs; bool pos_changed_during_fs; - /* One of the autofit/geometry options changed at runtime. */ - bool geometry_change; - XComposeStatus compose_status; /* XShm stuff */