Skip to content

Commit

Permalink
wm/win: workaround an xfce bug
Browse files Browse the repository at this point in the history
xfce will set the WM_TRANSIENT_FOR of some windows to the root window,
which is invalid. Make sure we are robust against this and don't crash.

Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Jun 26, 2024
1 parent b8db1d1 commit db1b05d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/wm/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,13 +1536,15 @@ win_get_leader_property(struct x_connection *c, struct atom *atoms, xcb_window_t
// Read the leader properties
if (detect_transient) {
leader = wid_get_prop_window(c, wid, atoms->aWM_TRANSIENT_FOR);
log_debug("Leader via WM_TRANSIENT_FOR of window %#010x: %#010x", wid, leader);

Check warning on line 1539 in src/wm/win.c

View check run for this annotation

Codecov / codecov/patch

src/wm/win.c#L1539

Added line #L1539 was not covered by tests
}

if (detect_client_leader && leader == XCB_NONE) {
leader = wid_get_prop_window(c, wid, atoms->aWM_CLIENT_LEADER);
log_debug("Leader via WM_CLIENT_LEADER of window %#010x: %#010x", wid, leader);

Check warning on line 1544 in src/wm/win.c

View check run for this annotation

Codecov / codecov/patch

src/wm/win.c#L1544

Added line #L1544 was not covered by tests
}

log_trace("window %#010x: leader %#010x", wid, leader);
log_debug("window %#010x: leader %#010x", wid, leader);
return leader;
}

Expand All @@ -1556,6 +1558,12 @@ static struct wm_ref *win_get_leader_raw(session_t *ps, struct win *w, int recur
// Leader defaults to client window, or to the window itself if
// it doesn't have a client window
w->cache_leader = wm_find(ps->wm, w->leader);
if (w->cache_leader == wm_root_ref(ps->wm)) {
log_warn("Window manager set the leader of window %#010x to "

Check warning on line 1562 in src/wm/win.c

View check run for this annotation

Codecov / codecov/patch

src/wm/win.c#L1561-L1562

Added lines #L1561 - L1562 were not covered by tests
"root, a broken window manager.",
win_id(w));
w->cache_leader = NULL;

Check warning on line 1565 in src/wm/win.c

View check run for this annotation

Codecov / codecov/patch

src/wm/win.c#L1565

Added line #L1565 was not covered by tests
}
if (!w->cache_leader) {
w->cache_leader = client_win ?: w->tree_ref;
}
Expand Down

0 comments on commit db1b05d

Please sign in to comment.