win: make sure window's client_win can't be XCB_NONE

This is a follow up to 81d137a3cc and
bug #704. Basically a window will have a `XCB_NONE` as `client_win` if its
previous client_win detached and then the window itself is immediately
destroyed. Because the window is destroyed we couldn't call
`win_recheck_client` so its `client_win` will remain `XCB_NONE`.

However, it turns out we have a convention of setting `client_win` to
the window itself if windows that don't have a client window. So make
sure this convention is followed even for destroyed windows.

Doesn't really fix anything, just to make sure an invariant holds.

Related: #704

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-01-21 19:58:29 +00:00
parent ce205d1591
commit d87dd41f4c
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
2 changed files with 7 additions and 5 deletions

View File

@ -270,11 +270,6 @@ static inline void ev_destroy_notify(session_t *ps, xcb_destroy_notify_event_t *
if (w != NULL) {
auto _ attr_unused = destroy_win_start(ps, w);
} else if (mw != NULL) {
// XXX the hope here is the WM will destroy the frame window
// quickly after the client window is destroyed. Otherwise a
// frame window without a client window would linger around. Who
// knows what kind of bugs it could cause. This has caused at
// least one: #704
win_unmark_client(ps, mw);
win_set_flags(mw, WIN_FLAGS_CLIENT_STALE);
ps->pending_updates = true;

View File

@ -2339,6 +2339,13 @@ bool destroy_win_start(session_t *ps, struct win *w) {
add_damage_from_win(ps, mw);
}
if (win_check_flags_all(mw, WIN_FLAGS_CLIENT_STALE)) {
mw->client_win = mw->base.id;
mw->wmwin = !mw->a.override_redirect;
log_debug("(%#010x): client self (%s)", mw->base.id,
(mw->wmwin ? "wmwin" : "override-redirected"));
}
// Clear some flags about stale window information. Because now
// the window is destroyed, we can't update them anyway.
win_clear_flags(mw, WIN_FLAGS_SIZE_STALE | WIN_FLAGS_POSITION_STALE |