[Xfce4-commits] <xfwm4:master> Do not set the "demand attention" flag when the window is alredy focused, refactor the code bit.

Olivier Fourdan noreply at xfce.org
Thu Oct 1 10:12:02 CEST 2009


Updating branch refs/heads/master
         to de1fc1c3d1ddd561dca46fbf219060a5e553d446 (commit)
       from 7688f3288ff34157281cd531bc8b490edfed1adb (commit)

commit de1fc1c3d1ddd561dca46fbf219060a5e553d446
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Thu Oct 1 09:33:18 2009 +0200

    Do not set the "demand attention" flag when the window is alredy focused, refactor the code bit.

 src/events.c |   28 +---------------------------
 src/netwm.c  |   43 +++++++++++++++++++++++++++++++++++++++++++
 src/netwm.h  |    3 +++
 3 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/src/events.c b/src/events.c
index 792086d..f0148f7 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1993,34 +1993,8 @@ handleClientMessage (DisplayInfo *display_info, XClientMessageEvent * ev)
         }
         else if ((ev->message_type == display_info->atoms[NET_ACTIVE_WINDOW]) && (ev->format == 32))
         {
-            gboolean source_is_application;
-            guint32 ev_time;
-
-            ev_time = myDisplayGetTime (display_info, (guint32) ev->data.l[1]);
-            source_is_application = (ev->data.l[0] == 1);
-
             TRACE ("client \"%s\" (0x%lx) has received a NET_ACTIVE_WINDOW event", c->name, c->window);
-            if (source_is_application)
-            {
-                guint32 current = myDisplayGetLastUserTime (display_info);
-
-                TRACE ("Time of event received is %u, current XServer time is %u", (guint32) ev_time, (guint32) current);
-                if ((screen_info->params->prevent_focus_stealing) && TIMESTAMP_IS_BEFORE((guint32) ev_time, (guint32) current))
-                {
-                    TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
-                    FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
-                    clientSetNetState (c);
-                }
-                else
-                {
-                    clientActivate (c, ev_time, source_is_application);
-                }
-            }
-            else
-            {
-                /* The request is either from a pager or an older client, use the most accurate timestamp */
-                clientActivate (c, getXServerTime (display_info), source_is_application);
-            }
+            clientHandleNetActiveWindow (c, (guint32) ev->data.l[1], (gboolean) (ev->data.l[0] == 1));
         }
         else if (ev->message_type == display_info->atoms[NET_REQUEST_FRAME_EXTENTS])
         {
diff --git a/src/netwm.c b/src/netwm.c
index d29bf64..e9cf071 100644
--- a/src/netwm.c
+++ b/src/netwm.c
@@ -1362,6 +1362,49 @@ clientSetNetActiveWindow (ScreenInfo *screen_info, Client *c, guint32 timestamp)
                      PropModeReplace, (unsigned char *) data, 2);
 }
 
+void
+clientHandleNetActiveWindow (Client *c, guint32 timestamp, gboolean source_is_application)
+{
+    DisplayInfo *display_info;
+    ScreenInfo *screen_info;
+    guint32 ev_time, current_time;
+    Client *focused;
+
+    g_return_if_fail (c != NULL);
+    TRACE ("entering clientHandleNetActiveWindow");
+
+    screen_info = c->screen_info;
+    display_info = screen_info->display_info;
+    ev_time = myDisplayGetTime (display_info, timestamp);
+
+    if (source_is_application)
+    {
+        current_time = myDisplayGetLastUserTime (display_info);
+
+        TRACE ("Time of event received is %u, current XServer time is %u", (guint32) ev_time, (guint32) current_time);
+        if ((screen_info->params->prevent_focus_stealing) && TIMESTAMP_IS_BEFORE((guint32) ev_time, (guint32) current_time))
+        {
+            focused = clientGetFocus ();
+            /* We do not want to set the demand attention flag if the window is focused though */
+            if (c != focused)
+            {
+                TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" (0x%lx)", c->name, c->window);
+                FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
+                clientSetNetState (c);
+            }
+        }
+        else
+        {
+            clientActivate (c, ev_time, source_is_application);
+        }
+    }
+    else
+    {
+        /* The request is either from a pager or an older client, use the most accurate timestamp */
+        clientActivate (c, getXServerTime (display_info), source_is_application);
+    }
+}
+
 static gboolean
 ping_timeout_cb (gpointer data)
 {
diff --git a/src/netwm.h b/src/netwm.h
index 351ad77..7b54be4 100644
--- a/src/netwm.h
+++ b/src/netwm.h
@@ -55,6 +55,9 @@ void                     clientUpdateLayerState                 (Client *);
 void                     clientSetNetActiveWindow               (ScreenInfo *,
                                                                  Client *,
                                                                  guint32);
+void                     clientHandleNetActiveWindow            (Client *,
+                                                                 guint32,
+                                                                 gboolean);
 void                     clientRemoveNetWMPing                  (Client *);
 gboolean                 clientSendNetWMPing                    (Client *,
                                                                  guint32);



More information about the Xfce4-commits mailing list