From 97c14ee65dc6d140c53b246820a3d8e8fcaa9e71 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Thu, 16 May 2024 18:27:29 +0100 Subject: [PATCH] c2: make override_redirect only match top-level windows without a client Fixes #625 Signed-off-by: Yuxuan Shui --- CHANGELOG.md | 1 + src/c2.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0260598e..f42501ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ ## Notable changes +* `override_redirect` in rules now only matches top-level windows that doesn't have a client window. Some window managers (e.g. awesome) set override_redirect for all window manager frame windows, causing this rule to match against everything (#625). * Marginally improve performance when resizing/opening/closing windows. (#1190) * Type and format specifiers are no longer used in rules. These specifiers are what you put after the colon (':') in rules, e.g. the `:32c` in `"_GTK_FRAME_EXTENTS@:32c"`. Now this information is ignored and the property is matched regardless of format or type. diff --git a/src/c2.c b/src/c2.c index f0771a9f..2e8da444 100644 --- a/src/c2.c +++ b/src/c2.c @@ -1588,7 +1588,6 @@ static bool c2_match_once_leaf_int(const struct managed_win *w, const c2_l_t *le case C2_L_PHEIGHTB: predef_target = w->heightb; break; case C2_L_PBDW: predef_target = w->g.border_width; break; case C2_L_PFULLSCREEN: predef_target = w->is_fullscreen; break; - case C2_L_POVREDIR: predef_target = w->a.override_redirect; break; case C2_L_PARGB: predef_target = win_has_alpha(w); break; case C2_L_PFOCUSED: predef_target = win_is_focused_raw(w); break; case C2_L_PWMWIN: predef_target = win_is_wmwin(w); break; @@ -1596,6 +1595,16 @@ static bool c2_match_once_leaf_int(const struct managed_win *w, const c2_l_t *le case C2_L_PROUNDED: predef_target = w->rounded_corners; break; case C2_L_PCLIENT: predef_target = w->client_win; break; case C2_L_PLEADER: predef_target = w->leader; break; + case C2_L_POVREDIR: + // When user wants to check override-redirect, they almost always + // want to check the client window, not the frame window. We + // don't track the override-redirect state of the client window + // directly, however we can assume if a window has a window + // manager frame around it, it's not override-redirect. + predef_target = + w->a.override_redirect && (w->client_win == w->base.id || + w->client_win == XCB_WINDOW_NONE); + break; default: unreachable(); } return c2_int_op(leaf, predef_target);