Skip to content

Commit

Permalink
wm: allow wm_find_by_client to be called with the root window
Browse files Browse the repository at this point in the history
(cherry picked from commit b2bf3cc)

Some window managers (e.g. qtile) may set _NET_ACTIVE_WINDOW to the root
window, and in that case `update_ewmh_active_win` will call
`wm_find_by_client` with the root, which crashes.

Fixes #1384

Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Nov 12, 2024
1 parent ab6ca6c commit 2fdeac0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 12.x (unreleased)

## Bug fixes

* Fix assertion failure when running with some window managers (e.g. qtile) and no window is focused (#1384)

# 12.4 (2024-Nov-09)

## Improvements
Expand Down
4 changes: 3 additions & 1 deletion src/wm/wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ struct wm_ref *wm_find(const struct wm *wm, xcb_window_t id) {

struct wm_ref *wm_find_by_client(const struct wm *wm, xcb_window_t client) {
auto node = wm_tree_find(&wm->tree, client);
if (node == NULL) {
if (node == NULL || node->parent == NULL) {
// If `client` is the root window, we return NULL too, technically
// the root window doesn't have a client window.
return NULL;
}
auto toplevel = wm_tree_find_toplevel_for(&wm->tree, node);
Expand Down

0 comments on commit 2fdeac0

Please sign in to comment.