History

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.

Dudemanguy committed 1 year ago

Commit 96bebf01 parent 8ee1aea2 files · +4 −14Browse files

Unified · Split

2 files
  1. video/out/x11_common.c +4 −10
  2. video/out/x11_common.h +0 −4
video/out/x11_common.c+4−10
@@ -1810,22 +1810,19 @@ void vo_x11_config_vo_window(struct vo *vo) · 1809 unmodified lines
18101810 !x11->pseudo_mapped, &geo);
18111811 vo_apply_window_geometry(vo, &geo);
18121812
1813− struct mp_rect rc = geo.win;
1813+ struct mp_rect rc = !x11->pseudo_mapped || opts->auto_window_resize || opts->geometry.wh_valid ||
1814+ opts->geometry.xy_valid ? geo.win : x11->nofsrc;
18141815
18151816 if (x11->parent) {
18161817 vo_x11_update_geometry(vo);
18171818 rc = (struct mp_rect){0, 0, RC_W(x11->winrc), RC_H(x11->winrc)};
18181819 }
18191820
1820− bool reset_size = ((x11->old_dw != RC_W(rc) || x11->old_dh != RC_H(rc))
1821− && opts->auto_window_resize) || x11->geometry_change;
1822− reset_size |= (x11->old_x != rc.x0 || x11->old_y != rc.y0) &&
1823− (x11->geometry_change);
1821+ bool reset_size = ((x11->old_dw != RC_W(rc) || x11->old_dh != RC_H(rc))) ||
1822+ opts->geometry.wh_valid || opts->geometry.xy_valid;
18241823
18251824 x11->old_dw = RC_W(rc);
18261825 x11->old_dh = RC_H(rc);
1827− x11->old_x = rc.x0;
1828− x11->old_y = rc.y0;
18291826
18301827 if (x11->window_hidden) {
18311828 x11->nofsrc = rc;
@@ -1834,8 +1831,6 @@ void vo_x11_config_vo_window(struct vo *vo) · 2 unmodified lines
18341831 vo_x11_highlevel_resize(vo, rc, geo.flags & VO_WIN_FORCE_POS);
18351832 }
18361833
1837− x11->geometry_change = false;
1838−
18391834 if (opts->ontop)
18401835 vo_x11_setlayer(vo, opts->ontop);
18411836 if (!opts->show_in_taskbar)
@@ -2069,7 +2064,6 @@ static void vo_x11_set_geometry(struct vo *vo) · 227 unmodified lines
20692064 if (!x11->window)
20702065 return;
20712066
2072− x11->geometry_change = true;
20732067 vo_x11_config_vo_window(vo);
20742068 }
20752069
video/out/x11_common.h+0−4
@@ -115,16 +115,12 @@ struct vo_x11_state { · 114 unmodified lines
115115 * stays the same (even if that size is different from the current
116116 * window size after the user modified the latter). */
117117 int old_dw, old_dh;
118− int old_x, old_y;
119118 /* Video size changed during fullscreen when we couldn't tell the new
120119 * size to the window manager. Must set window size when turning
121120 * fullscreen off. */
122121 bool size_changed_during_fs;
123122 bool pos_changed_during_fs;
124123
125− /* One of the autofit/geometry options changed at runtime. */
126− bool geometry_change;
127−
128124 XComposeStatus compose_status;
129125
130126 /* XShm stuff */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t