Skip to content

Commit

Permalink
win: make sure window's client_win can't be XCB_NONE
Browse files Browse the repository at this point in the history
This is a follow up to 81d137a 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>
  • Loading branch information
yshui committed Jan 21, 2024
1 parent ce205d1 commit d87dd41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit d87dd41

Please sign in to comment.