event: set WIN_FLAGS_FACTOR_CHANGED on tracked property change

Previously, when some explicitly checked property (e.g.
_NET_WM_WINDOW_OPACITY) changed, it won't trigger a
win_on_factor_change, and the rules will not be re-evaluated. Because
that property stale flag will be cleared after we explicitly check the
property, so it won't be detected as a tracked property change.

Here, we instead set WIN_FLAGS_FACTOR_CHANGED directly when a tracked
property changed.

Fixes: f3ff7eff8c

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2020-10-23 01:51:28 +01:00
parent a099678664
commit 21e9aab6b6
2 changed files with 9 additions and 14 deletions

View File

@@ -570,7 +570,11 @@ static inline void ev_property_notify(session_t *ps, xcb_property_notify_event_t
w = find_toplevel(ps, ev->window);
}
if (w) {
win_set_property_stale(w, ev->atom);
// Set FACTOR_CHANGED so rules based on properties will be
// re-evaluated.
// Don't need to set property stale here, since that only
// concerns properties we explicitly check.
win_set_flags(w, WIN_FLAGS_FACTOR_CHANGED);
}
break;
}

View File

@@ -348,7 +348,7 @@ void win_release_images(struct backend_base *backend, struct managed_win *w) {
/// Returns true if the `prop` property is stale, as well as clears the stale flag.
static bool win_fetch_and_unset_property_stale(struct managed_win *w, xcb_atom_t prop);
/// Returns true if any of the properties are stale, as well as clear all the stale flags.
static bool win_check_and_clear_all_properties_stale(struct managed_win *w);
static void win_clear_all_properties_stale(struct managed_win *w);
/// Fetch new window properties from the X server, and run appropriate updates. Might set
/// WIN_FLAGS_FACTOR_CHANGED
@@ -397,11 +397,7 @@ static void win_update_properties(session_t *ps, struct managed_win *w) {
win_update_leader(ps, w);
}
if (win_check_and_clear_all_properties_stale(w)) {
// Some other flags we didn't explicitly check has changed, must
// have been a tracked atom for the custom rules
win_set_flags(w, WIN_FLAGS_FACTOR_CHANGED);
}
win_clear_all_properties_stale(w);
}
void win_process_update_flags(session_t *ps, struct managed_win *w) {
@@ -2502,14 +2498,9 @@ void win_set_property_stale(struct managed_win *w, xcb_atom_t prop) {
win_set_flags(w, WIN_FLAGS_PROPERTY_STALE);
}
static bool win_check_and_clear_all_properties_stale(struct managed_win *w) {
bool ret = false;
for (size_t i = 0; i < w->stale_props_capacity; i++) {
ret = ret || (w->stale_props[i] != 0);
w->stale_props[i] = 0;
}
static void win_clear_all_properties_stale(struct managed_win *w) {
memset(w->stale_props, 0, w->stale_props_capacity * sizeof(*w->stale_props));
win_clear_flags(w, WIN_FLAGS_PROPERTY_STALE);
return ret;
}
static bool win_fetch_and_unset_property_stale(struct managed_win *w, xcb_atom_t prop) {