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 8e793bde78.
This commit is contained in:
nanahi 2024-03-03 13:27:02 -05:00 committed by Dudemanguy
parent 83da97f955
commit f236e249a4
2 changed files with 9 additions and 4 deletions

View File

@ -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;

View File

@ -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. */