From e1b6e37e22a4b6ccd370138eb5ee0a09f4b0d266 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <fourdan.olivier@wanadoo.fr>
Date: Fri, 3 Oct 2008 20:46:16 +0000
Subject: [PATCH] Rework the blinking of windows to make it less boring and
 hopefully more noticeable

(Old svn revision: 28024)
---
 src/client.c | 22 +++++++++++++++++++---
 src/client.h |  7 ++++++-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/client.c b/src/client.c
index 4baa1220b..b075ade58 100644
--- a/src/client.c
+++ b/src/client.c
@@ -345,13 +345,25 @@ urgent_cb (gpointer data)
 {
     Client *c;
 
-    TRACE ("entering urgent_cb");
+    TRACE ("entering urgent_cb, iteration %i", c->blink_iterations);
 
     c = (Client *) data;
     if (c != clientGetFocus ())
     {
-        FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE);
-        frameQueueDraw (c, FALSE);
+        c->blink_iterations++;
+        if (c->blink_iterations < (2 * MAX_BLINK_ITERATIONS + 1))
+        {
+            FLAG_TOGGLE (c->xfwm_flags, XFWM_FLAG_SEEN_ACTIVE);
+            frameQueueDraw (c, FALSE);
+        }
+        else if (c->blink_iterations > (8 * MAX_BLINK_ITERATIONS))
+        {
+            c->blink_iterations = 0;
+        }        
+    }
+    else if (c->blink_iterations)
+    {
+        c->blink_iterations = 0;
     }
     return (TRUE);
 }
@@ -372,6 +384,7 @@ clientUpdateUrgency (Client *c)
     FLAG_UNSET (c->wm_flags, WM_FLAG_URGENT);
 
     c->blink_timeout_id = 0;
+    c->blink_iterations = 0;
     if ((c->wmhints) && (c->wmhints->flags & XUrgencyHint))
     {
         FLAG_SET (c->wm_flags, WM_FLAG_URGENT);
@@ -1639,6 +1652,9 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture)
     c->opacity_applied = c->opacity;
     c->opacity_flags = 0;
 
+    /* Keep count of blinking iterations */
+    c->blink_iterations = 0;
+
     if (getOpacityLock (display_info, c->window))
     {
         FLAG_SET (c->xfwm_flags, XFWM_FLAG_OPACITY_LOCKED);
diff --git a/src/client.h b/src/client.h
index 9dcbe1bed..c15285c8c 100644
--- a/src/client.h
+++ b/src/client.h
@@ -102,13 +102,17 @@
 #endif
 
 #ifndef CLIENT_BLINK_TIMEOUT
-#define CLIENT_BLINK_TIMEOUT            500 /* ms */
+#define CLIENT_BLINK_TIMEOUT            200  /* ms */
 #endif
 
 #ifndef CLIENT_PING_TIMEOUT
 #define CLIENT_PING_TIMEOUT             3000 /* ms */
 #endif
 
+#ifndef MAX_BLINK_ITERATIONS
+#define MAX_BLINK_ITERATIONS            5
+#endif
+
 #define XFWM_FLAG_HAS_BORDER            (1L<<0)
 #define XFWM_FLAG_HAS_MENU              (1L<<1)
 #define XFWM_FLAG_HAS_MAXIMIZE          (1L<<2)
@@ -286,6 +290,7 @@ struct _Client
     int previous_height;
     int initial_layer;
     int ncmap;
+    int blink_iterations;
     int button_status[BUTTON_COUNT];
     int struts[STRUTS_SIZE];
     gchar *hostname;
-- 
GitLab