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
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 af3cf50 commit b2bf3cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- `sw-opti`
- `clear-shadow`

## Bug fixes

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

# 12.x (unreleased)

## Build fixes
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 b2bf3cc

Please sign in to comment.