client: add client_seturgent() and remove urgent hint on focus
According to EWMH, the window manager is responsible for removing the urgent state of a client. Also, this commit adds a new client_seturgent(client_t *, bool) function to set the urgent state if needed. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
01eff69bf4
commit
050a6bbb61
33
client.c
33
client.c
|
@ -110,6 +110,36 @@ window_hasproto(xcb_window_t win, xcb_atom_t atom)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Change the clients urgency flag.
|
||||||
|
* \param c The client
|
||||||
|
* \param urgent The new flag state
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
client_seturgent(client_t *c, bool urgent)
|
||||||
|
{
|
||||||
|
if(c->isurgent != urgent)
|
||||||
|
{
|
||||||
|
xcb_get_property_cookie_t hints =
|
||||||
|
xcb_get_wm_hints_unchecked(globalconf.connection, c->win);
|
||||||
|
|
||||||
|
c->isurgent = urgent;
|
||||||
|
ewmh_client_update_hints(c);
|
||||||
|
|
||||||
|
/* update ICCCM hints */
|
||||||
|
xcb_wm_hints_t wmh;
|
||||||
|
xcb_get_wm_hints_reply(globalconf.connection, hints, &wmh, NULL);
|
||||||
|
|
||||||
|
if(urgent)
|
||||||
|
wmh.flags |= XCB_WM_HINT_X_URGENCY;
|
||||||
|
else
|
||||||
|
wmh.flags &= ~XCB_WM_HINT_X_URGENCY;
|
||||||
|
|
||||||
|
xcb_set_wm_hints(globalconf.connection, c->win, &wmh);
|
||||||
|
|
||||||
|
hooks_property(c, "urgent");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns true if a client is tagged
|
/** Returns true if a client is tagged
|
||||||
* with one of the tags of the specified screen.
|
* with one of the tags of the specified screen.
|
||||||
* \param c The client to check.
|
* \param c The client to check.
|
||||||
|
@ -296,6 +326,9 @@ client_focus(client_t *c)
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.focus, 1, 0);
|
luaA_dofunction(globalconf.L, globalconf.hooks.focus, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* according to EWMH, we have to remove the urgent state from a client */
|
||||||
|
client_seturgent(c, false);
|
||||||
|
|
||||||
ewmh_update_net_active_window(c->phys_screen);
|
ewmh_update_net_active_window(c->phys_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
client.h
1
client.h
|
@ -66,6 +66,7 @@ void client_setmaxhoriz(client_t *, bool);
|
||||||
void client_setmaxvert(client_t *, bool);
|
void client_setmaxvert(client_t *, bool);
|
||||||
void client_setminimized(client_t *, bool);
|
void client_setminimized(client_t *, bool);
|
||||||
void client_setborder(client_t *, int);
|
void client_setborder(client_t *, int);
|
||||||
|
void client_seturgent(client_t *, bool);
|
||||||
void client_focus(client_t *);
|
void client_focus(client_t *);
|
||||||
|
|
||||||
int luaA_client_newindex(lua_State *);
|
int luaA_client_newindex(lua_State *);
|
||||||
|
|
9
ewmh.c
9
ewmh.c
|
@ -347,14 +347,11 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
|
||||||
else if(state == _NET_WM_STATE_DEMANDS_ATTENTION)
|
else if(state == _NET_WM_STATE_DEMANDS_ATTENTION)
|
||||||
{
|
{
|
||||||
if(set == _NET_WM_STATE_REMOVE)
|
if(set == _NET_WM_STATE_REMOVE)
|
||||||
c->isurgent = false;
|
client_seturgent(c, false);
|
||||||
else if(set == _NET_WM_STATE_ADD)
|
else if(set == _NET_WM_STATE_ADD)
|
||||||
c->isurgent = true;
|
client_seturgent(c, true);
|
||||||
else if(set == _NET_WM_STATE_TOGGLE)
|
else if(set == _NET_WM_STATE_TOGGLE)
|
||||||
c->isurgent = !c->isurgent;
|
client_seturgent(c, !c->isurgent);
|
||||||
|
|
||||||
/* execute hook */
|
|
||||||
hooks_property(c, "urgent");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,12 +172,7 @@ property_update_wm_hints(client_t *c, xcb_get_property_reply_t *reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isurgent = xcb_wm_hints_get_urgency(&wmh);
|
bool isurgent = xcb_wm_hints_get_urgency(&wmh);
|
||||||
if(isurgent != c->isurgent)
|
client_seturgent(c, isurgent);
|
||||||
{
|
|
||||||
c->isurgent = isurgent;
|
|
||||||
/* execute hook */
|
|
||||||
hooks_property(c, "urgent");
|
|
||||||
}
|
|
||||||
if(wmh.flags & XCB_WM_HINT_STATE &&
|
if(wmh.flags & XCB_WM_HINT_STATE &&
|
||||||
wmh.initial_state == XCB_WM_STATE_WITHDRAWN)
|
wmh.initial_state == XCB_WM_STATE_WITHDRAWN)
|
||||||
client_setborder(c, 0);
|
client_setborder(c, 0);
|
||||||
|
|
Loading…
Reference in New Issue