1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00

inspect: fix reporting of matched rules

When we checked each rule, we didn't just match the window against that
one rule, we were matching it against all subsequent rules in the list
as well.

This commit fixes that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-05-19 22:54:44 +01:00
parent 315bd3222b
commit 50e092cbc0
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4
3 changed files with 18 additions and 1 deletions

View file

@ -1875,6 +1875,21 @@ bool c2_match(struct c2_state *state, const struct managed_win *w,
return false; return false;
} }
/// Match a window against the first condition in a condition linked list.
bool c2_match_one(struct c2_state *state, const struct managed_win *w,
const c2_lptr_t *condlst, void **pdata) {
if (!condlst) {
return false;
}
if (c2_match_once(state, w, condlst->ptr)) {
if (pdata) {
*pdata = condlst->data;
}
return true;
}
return false;
}
/// Iterate over all conditions in a condition linked list. Call the callback for /// Iterate over all conditions in a condition linked list. Call the callback for
/// each of the conditions. If the callback returns true, the iteration stops /// each of the conditions. If the callback returns true, the iteration stops
/// early. /// early.

View file

@ -59,6 +59,8 @@ void c2_window_state_update(struct c2_state *state, struct c2_window_state *wind
bool c2_match(struct c2_state *state, const struct managed_win *w, bool c2_match(struct c2_state *state, const struct managed_win *w,
const c2_lptr_t *condlst, void **pdata); const c2_lptr_t *condlst, void **pdata);
bool c2_match_one(struct c2_state *state, const struct managed_win *w,
const c2_lptr_t *condlst, void **pdata);
bool c2_list_postprocess(struct c2_state *state, xcb_connection_t *c, c2_lptr_t *list); bool c2_list_postprocess(struct c2_state *state, xcb_connection_t *c, c2_lptr_t *list);
typedef bool (*c2_list_foreach_cb_t)(const c2_lptr_t *cond, void *data); typedef bool (*c2_list_foreach_cb_t)(const c2_lptr_t *cond, void *data);

View file

@ -148,7 +148,7 @@ bool c2_match_once_and_log(const c2_lptr_t *cond, void *data) {
struct c2_match_state *state = data; struct c2_match_state *state = data;
void *rule_data = NULL; void *rule_data = NULL;
printf(" %s ... ", c2_lptr_to_str(cond)); printf(" %s ... ", c2_lptr_to_str(cond));
bool matched = c2_match(state->state, state->w, cond, &rule_data); bool matched = c2_match_one(state->state, state->w, cond, rule_data);
printf("%s", matched ? "\033[1;32mmatched\033[0m" : "not matched"); printf("%s", matched ? "\033[1;32mmatched\033[0m" : "not matched");
if (state->print_value && matched) { if (state->print_value && matched) {
printf("/%lu", (unsigned long)(intptr_t)rule_data); printf("/%lu", (unsigned long)(intptr_t)rule_data);