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.
This commit is contained in:
Dudemanguy committed 2024-12-20 18:03:30 +00:00
1 parent 8ee1aeaf1a
commit 96bebf0935
2 files changed
+4 -14

No files matched your search

+4 -10
View File
@@ -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);
}
-4
View File
@@ -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 */