Add support for _NET_WM_STATE_DEMANDS_ATTENTION

This commit is contained in:
Bastien Dejean 2013-03-26 11:34:06 +01:00
parent afab0f66a4
commit 1f894fe492
4 changed files with 22 additions and 11 deletions

View file

@ -76,6 +76,7 @@ void setup(void)
ewmh->_NET_WM_DESKTOP,
ewmh->_NET_WM_STATE,
ewmh->_NET_WM_STATE_FULLSCREEN,
ewmh->_NET_WM_STATE_DEMANDS_ATTENTION,
ewmh->_NET_WM_WINDOW_TYPE,
ewmh->_NET_WM_WINDOW_TYPE_DOCK,
ewmh->_NET_WM_WINDOW_TYPE_NOTIFICATION,

View file

@ -181,17 +181,9 @@ void property_notify(xcb_generic_event_t *evt)
return;
window_location_t loc;
if (locate_window(e->window, &loc)) {
if (xcb_icccm_get_wm_hints_reply(dpy, xcb_icccm_get_wm_hints(dpy, e->window), &hints, NULL) == 1) {
uint32_t urgent = xcb_icccm_wm_hints_get_urgency(&hints);
if (urgent != 0 && loc.node != mon->desk->focus) {
loc.node->client->urgent = urgent;
put_status();
if (loc.monitor->desk == loc.desktop)
arrange(loc.monitor, loc.desktop);
}
}
}
if (locate_window(e->window, &loc)
&& xcb_icccm_get_wm_hints_reply(dpy, xcb_icccm_get_wm_hints(dpy, e->window), &hints, NULL) == 1)
set_urgency(loc.monitor, loc.desktop, loc.node, xcb_icccm_wm_hints_get_urgency(&hints));
}
void client_message(xcb_generic_event_t *evt)
@ -262,6 +254,13 @@ void handle_state(monitor_t *m, desktop_t *d, node_t *n, xcb_atom_t state, unsig
toggle_fullscreen(m, n->client);
arrange(m, d);
}
} else if (state == ewmh->_NET_WM_STATE_DEMANDS_ATTENTION) {
if (action == XCB_EWMH_WM_STATE_ADD)
set_urgency(m, d, n, true);
else if (action == XCB_EWMH_WM_STATE_REMOVE)
set_urgency(m, d, n, false);
else if (action == XCB_EWMH_WM_STATE_TOGGLE)
set_urgency(m, d, n, !n->client->urgent);
}
}

View file

@ -353,6 +353,16 @@ void toggle_locked(client_t *c)
c->locked = !c->locked;
}
void set_urgency(monitor_t *m, desktop_t *d, node_t *n, bool value)
{
if (value && mon->desk->focus == n)
return;
n->client->urgent = value;
put_status();
if (m->desk == d)
arrange(m, d);
}
void set_shadow(xcb_window_t win, uint32_t value)
{
if (!apply_shadow_property)

View file

@ -26,6 +26,7 @@ void window_kill(desktop_t *, node_t *);
void toggle_fullscreen(monitor_t *, client_t *);
void toggle_floating(node_t *);
void toggle_locked(client_t *);
void set_urgency(monitor_t *, desktop_t *, node_t *, bool);
void set_shadow(xcb_window_t, uint32_t);
void enable_shadow(xcb_window_t);
void disable_shadow(xcb_window_t);