From b652e8b58d942730f8c772f384c2d1004660b301 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 5 Apr 2020 21:30:33 +0100 Subject: [PATCH] event: destroy: unmark client when a client window is destroyed We do nothing when a non-wm-frame window is destroyed. This will cause trouble if a wm-frame window is reused (i.e. its child is destroyed then a new child is reparented to it), because we didn't clear client_win. So this commit adds a call to win_unmark_client for that case. Related: #299 Signed-off-by: Yuxuan Shui --- src/event.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/event.c b/src/event.c index 87de238de3..07c2a2196e 100644 --- a/src/event.c +++ b/src/event.c @@ -263,8 +263,21 @@ static inline void ev_configure_notify(session_t *ps, xcb_configure_notify_event static inline void ev_destroy_notify(session_t *ps, xcb_destroy_notify_event_t *ev) { auto w = find_win(ps, ev->window); - if (w) { + auto mw = find_toplevel(ps, ev->window); + if (mw && mw->client_win == mw->base.id) { + // We only want _real_ frame window + assert(&mw->base == w); + mw = NULL; + } + assert(w == NULL || mw == NULL); + + if (w != NULL) { auto _ attr_unused = destroy_win_start(ps, w); + } else if (mw != NULL) { + win_unmark_client(ps, mw); + } else { + log_debug("Received a destroy notify from an unknown window, %#010x", + ev->window); } }