From d87dd41f4cf1ca1bbc5ff36883c75ee8dbbc754d Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 21 Jan 2024 19:58:29 +0000 Subject: [PATCH] win: make sure window's client_win can't be XCB_NONE This is a follow up to 81d137a3cc645c914ba5d9d41258856cfccd2180 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 --- src/event.c | 5 ----- src/win.c | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/event.c b/src/event.c index 355aa3304a..739540dc9a 100644 --- a/src/event.c +++ b/src/event.c @@ -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; diff --git a/src/win.c b/src/win.c index 25bfb8cdfb..b8bfe76093 100644 --- a/src/win.c +++ b/src/win.c @@ -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 |