Skip to content

Commit

Permalink
event: simplify property notify handling
Browse files Browse the repository at this point in the history
We can always set property stale no matter if we care about the
property, it doesn't hurt.

Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Mar 25, 2024
1 parent f8b44a0 commit 2b9d7e7
Showing 1 changed file with 11 additions and 71 deletions.
82 changes: 11 additions & 71 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static inline void ev_property_notify(session_t *ps, xcb_property_notify_event_t
}

ps->pending_updates = true;
// If WM_STATE changes
auto w = find_toplevel(ps, ev->window);
if (ev->atom == ps->atoms->aWM_STATE) {
auto pending_client = session_find_pending_client(ps, ev->window);
if (pending_client) {
Expand All @@ -509,96 +509,36 @@ static inline void ev_property_notify(session_t *ps, xcb_property_notify_event_t
}
return;
}
auto w = find_toplevel(ps, ev->window);
if (w != NULL) {
// Recheck toplevel's client window since WM_STATE could be
// unset.
win_set_flags(w, WIN_FLAGS_CLIENT_STALE);
}
}

// If _NET_WM_WINDOW_TYPE changes... God knows why this would happen, but
// there are always some stupid applications. (#144)
if (ev->atom == ps->atoms->a_NET_WM_WINDOW_TYPE) {
struct managed_win *w = find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
}

if (ev->atom == ps->atoms->a_NET_WM_BYPASS_COMPOSITOR) {
// Unnecessary until we remove the queue_redraw in ev_handle
queue_redraw(ps);
}

// If _NET_WM_WINDOW_OPACITY changes
if (ev->atom == ps->atoms->a_NET_WM_WINDOW_OPACITY) {
auto w = find_managed_win(ps, ev->window) ?: find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
}

// If frame extents property changes
if (ev->atom == ps->atoms->a_NET_FRAME_EXTENTS) {
auto w = find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
}

// If name changes
if (ps->atoms->aWM_NAME == ev->atom || ps->atoms->a_NET_WM_NAME == ev->atom) {
auto w = find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
}

// If class changes
if (ps->atoms->aWM_CLASS == ev->atom) {
auto w = find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
}

// If role changes
if (ps->atoms->aWM_WINDOW_ROLE == ev->atom) {
auto w = find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
}

// If _COMPTON_SHADOW changes
if (ps->atoms->a_COMPTON_SHADOW == ev->atom) {
auto w = find_managed_win(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
}

// If a leader property changes
if ((ps->o.detect_transient && ps->atoms->aWM_TRANSIENT_FOR == ev->atom) ||
(ps->o.detect_client_leader && ps->atoms->aWM_CLIENT_LEADER == ev->atom)) {
auto w = find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
}
if (w) {
win_set_property_stale(w, ev->atom);
}

if (!ps->o.no_ewmh_fullscreen && ev->atom == ps->atoms->a_NET_WM_STATE) {
auto w = find_toplevel(ps, ev->window);
if (w) {
win_set_property_stale(w, ev->atom);
if (ev->atom == ps->atoms->a_NET_WM_WINDOW_OPACITY) {
// We already handle if this is set on the client window, check
// if this is set on the frame window as well.
// TODO(yshui) do we really need this?
auto toplevel = find_managed_win(ps, ev->window);
if (toplevel) {
win_set_property_stale(toplevel, ev->atom);
}
}

// Check for other atoms we are tracking
if (c2_state_is_property_tracked(ps->c2_state, ev->atom)) {
bool change_is_on_client = false;
auto w = find_managed_win(ps, ev->window);
w = find_managed_win(ps, ev->window);
if (!w) {
w = find_toplevel(ps, ev->window);
change_is_on_client = true;
Expand Down

0 comments on commit 2b9d7e7

Please sign in to comment.