From f236e249a49d893b21a800a0f93618d3d1e13d6c Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sun, 3 Mar 2024 13:27:02 -0500 Subject: x11_common: fix window x/y position when updating geometry on runtime Currently, setting geometry on runtime only changes the window size but not the position. This is because reset_size is only set if the window size is changed, and vo_x11_highlevel_resize doesn't set the window position without force_window_position enabled. Fix this by setting the related flags and perform a window move when geometry is updated. Fixes 8e793bde78f00fbb64223db30851c6d080c4abeb. --- video/out/x11_common.c | 12 ++++++++---- video/out/x11_common.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'video/out') diff --git a/video/out/x11_common.c b/video/out/x11_common.c index ccb478b716..47dc2c31b0 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1726,12 +1726,12 @@ static void vo_x11_map_window(struct vo *vo, struct mp_rect rc) vo_x11_xembed_update(x11, XEMBED_MAPPED); } -static void vo_x11_highlevel_resize(struct vo *vo, struct mp_rect rc) +static void vo_x11_highlevel_resize(struct vo *vo, struct mp_rect rc, bool force) { struct vo_x11_state *x11 = vo->x11; struct mp_vo_opts *opts = x11->opts; - bool reset_pos = opts->force_window_position; + bool reset_pos = opts->force_window_position || force; if (reset_pos) { x11->nofsrc = rc; } else { @@ -1820,15 +1820,19 @@ void vo_x11_config_vo_window(struct vo *vo) 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); 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; vo_x11_map_window(vo, rc); } else if (reset_size) { - vo_x11_highlevel_resize(vo, rc); + vo_x11_highlevel_resize(vo, rc, x11->geometry_change); } x11->geometry_change = false; @@ -2122,7 +2126,7 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg) &x11->opts->window_maximized); vo_x11_maximize(vo); } - vo_x11_highlevel_resize(vo, rc); + vo_x11_highlevel_resize(vo, rc, false); if (!x11->fs) { // guess new window size, instead of waiting for X x11->winrc.x1 = x11->winrc.x0 + w; x11->winrc.y1 = x11->winrc.y0 + h; diff --git a/video/out/x11_common.h b/video/out/x11_common.h index 8a3b145161..b8ebfe0328 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -114,6 +114,7 @@ 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. */ -- cgit v1.2.3