At Wed, 11 Feb 2009 17:57:52 +0100
Gregor Best wrote:

> At Wed, 11 Feb 2009 17:40:40 +0100
> Julien Danjou wrote:
> 
> > At 1234370360 time_t, Julien Danjou wrote:
> > > At 1234369845 time_t, Gregor Best wrote:
> > > > +        wmh.flags ^= 0x100;
> > > 
> > > XCB_WM_HINT_X_URGENCY ?
> > 
> > Well, and XORing is a bad idea. You may finish by having awesome
> > thinking it's true because of EWMH hint where the ICCCM hint is not set.
> > So this will break everything.
> > It should not happen but you never know with bad implementation.
> > 
> 
> Okay, i'll change that.
> 
This time everything should be alright.

-- 
    Gregor Best
From 53237d70fb1652c06bd04f72ee8b2d4ee4b0ad61 Mon Sep 17 00:00:00 2001
From: Gregor Best <farha...@googlemail.com>
Date: Wed, 11 Feb 2009 15:18:02 +0100
Subject: [PATCH] client.c: 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.
---
 client.c   |   31 +++++++++++++++++++++++++++++++
 client.h   |    1 +
 ewmh.c     |    9 +++------
 property.c |    7 +------
 4 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/client.c b/client.c
index ea107f6..73a0536 100644
--- a/client.c
+++ b/client.c
@@ -110,6 +110,34 @@ window_hasproto(xcb_window_t win, xcb_atom_t atom)
     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)
+    {
+        c->isurgent = urgent;
+        ewmh_client_update_hints(c);
+        /* update ICCCM hints */
+        xcb_wm_hints_t wmh;
+        xcb_get_wm_hints_reply(globalconf.connection,
+                              xcb_get_wm_hints_unchecked(globalconf.connection, c->win),
+                              &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
  * with one of the tags of the specified screen.
  * \param c The client to check.
@@ -274,6 +302,9 @@ client_focus(client_t *c)
         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);
 }
 
diff --git a/client.h b/client.h
index 657c4e1..780bff2 100644
--- a/client.h
+++ b/client.h
@@ -66,6 +66,7 @@ void client_setmaxhoriz(client_t *, bool);
 void client_setmaxvert(client_t *, bool);
 void client_setminimized(client_t *, bool);
 void client_setborder(client_t *, int);
+void client_seturgent(client_t *, bool);
 void client_focus(client_t *);
 
 int luaA_client_newindex(lua_State *);
diff --git a/ewmh.c b/ewmh.c
index e00c46c..81dd8e1 100644
--- a/ewmh.c
+++ b/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)
     {
         if(set == _NET_WM_STATE_REMOVE)
-            c->isurgent = false;
+            client_seturgent(c, false);
         else if(set == _NET_WM_STATE_ADD)
-            c->isurgent = true;
+            client_seturgent(c, true);
         else if(set == _NET_WM_STATE_TOGGLE)
-            c->isurgent = !c->isurgent;
-
-        /* execute hook */
-        hooks_property(c, "urgent");
+            client_seturgent(c, !c->isurgent);
     }
 }
 
diff --git a/property.c b/property.c
index b3002ed..bf08c28 100644
--- a/property.c
+++ b/property.c
@@ -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);
-    if(isurgent != c->isurgent)
-    {
-        c->isurgent = isurgent;
-        /* execute hook */
-        hooks_property(c, "urgent");
-    }
+    client_seturgent(c, isurgent);
     if(wmh.flags & XCB_WM_HINT_STATE &&
        wmh.initial_state == XCB_WM_STATE_WITHDRAWN)
         client_setborder(c, 0);
-- 
1.6.1.2

Attachment: signature.asc
Description: PGP signature

Reply via email to