Re: Notification on urgency flag patch

Eoin McLoughlin <eoinmcl-fLipR/[email protected]>
Newsgroups gmane.comp.window-managers.ratpoison.devel
Message-ID <[email protected]>
On Wed, Nov 18, 2009 at 11:13:06AM +0000, Eoin McLoughlin wrote:
> I've attached a simple patch which adds functionality for detecting when

I suppose _actually_ attaching the patch helps :)

Eoin

_______________________________________________
Ratpoison-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/ratpoison-devel
rp_urgent.diff (text/x-diff, 1.8 KB)
diff --git a/src/events.c b/src/events.c
index d973639..df65b6e 100644
--- a/src/events.c
+++ b/src/events.c
@@ -640,6 +640,21 @@ property_notify (XEvent *ev)
             win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for);
             break;
 
+          case XA_WM_HINTS:
+            PRINT_DEBUG (("Additional hints\n"));
+
+            if (has_urgency_flag (win))
+              {
+                rp_group *g = groups_find_group_by_window (win);
+                rp_window_elem *elem = group_find_window (&g->mapped_windows, win);
+                char* commandStr =  xsprintf ("echo Window %i/%i (%s) wants attention",
+                                               g->number, elem->number, win->wm_name);
+
+                command (0, commandStr);
+                free (commandStr);
+              }
+            break;
+
           default:
             PRINT_DEBUG (("Unhandled property notify event: %ld\n", ev->xproperty.atom));
             break;
diff --git a/src/manage.c b/src/manage.c
index 8aaec31..07a7104 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -929,3 +929,14 @@ hide_others (rp_window *win)
       hide_window (cur);
     }
 }
+
+/* Return non-zero if window hints have urgency flag set */
+int
+has_urgency_flag (rp_window *win)
+{          
+  XWMHints *hints = XGetWMHints (dpy, win->w);
+  int has_urgency = (hints->flags & XUrgencyHint) == XUrgencyHint;
+
+  XFree (hints);
+  return has_urgency;
+}          
diff --git a/src/manage.h b/src/manage.h
index 6d5f1f5..2e21d21 100644
--- a/src/manage.h
+++ b/src/manage.h
@@ -56,5 +56,6 @@ void unhide_all_windows (void);
 void unhide_window_below (rp_window *win);
 void withdraw_window (rp_window *win);
 void hide_others (rp_window *win);
+int has_urgency_flag (rp_window *win);
 
 #endif /* ! _RATPOISION_MANAGE_H */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.