Revert previous fix for #299

Commits reverted:
b652e8b58d
bdf809d039
e9ab970989
481ac54f67

While those commits themselves could be useful even if they don't
completely fix #299, they come with the risks of introduce more
unforeseen bugs, which outweigh their benefit, so revert them.

A brief explanation of their problem:

The fix hinges on the destroy event of the client window to work.
However, the client window could be destroyed so fast, before we even
handle the map, or even the create, event of the frame. And we won't be
listening for substructure events on the frame at the point the client
window is destroyed. Thus completely miss the client window destroy
event.

Because of the inherent racy nature of Xorg, this approach is really
difficult to make work.

Fixes #371

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2020-04-06 20:22:54 +01:00
parent bdf809d039
commit 04fe4a76b2
4 changed files with 15 additions and 34 deletions

View File

@ -263,21 +263,8 @@ 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);
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) {
if (w) {
auto _ attr_unused = destroy_win_start(ps, w);
} else if (mw != NULL) {
win_recheck_client(ps, mw);
} else {
log_debug("Received a destroy notify from an unknown window, %#010x",
ev->window);
}
}
@ -349,13 +336,15 @@ static inline void ev_reparent_notify(session_t *ps, xcb_reparent_notify_event_t
ps->c, ev->window, XCB_CW_EVENT_MASK,
(const uint32_t[]){determine_evmask(ps, ev->window, WIN_EVMODE_UNKNOWN)});
// Mark the window as the client window of its parent.
auto w_real_top = find_managed_window_or_parent(ps, ev->parent);
// If found, and the client window has not been determined, or its
// frame may not have a correct client, continue
if (w_real_top) {
if (!w_real_top->client_win ||
w_real_top->client_win == w_real_top->base.id) {
// Check if the window is an undetected client window
// Firstly, check if it's a known client window
if (!w_top) {
// If not, look for its frame window
auto w_real_top = find_managed_window_or_parent(ps, ev->parent);
// If found, and the client window has not been determined, or its
// frame may not have a correct client, continue
if (w_real_top && (!w_real_top->client_win ||
w_real_top->client_win == w_real_top->base.id)) {
// If it has WM_STATE, mark it the client window
if (wid_has_prop(ps, ev->window, ps->atoms->aWM_STATE)) {
w_real_top->wmwin = false;
@ -370,11 +359,6 @@ static inline void ev_reparent_notify(session_t *ps, xcb_reparent_notify_event_t
determine_evmask(ps, ev->window, WIN_EVMODE_UNKNOWN) |
XCB_EVENT_MASK_PROPERTY_CHANGE});
}
} else {
log_warn("Window %#010x reparented to a window that "
"already has a client window, the parent is "
"%#010x (%s)",
ev->window, w_real_top->base.id, w_real_top->name);
}
}
}