[hackers] [wmii] Show indication when clients are wedged. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Fri, 4 Jun 2010 01:48:13 +0000 (UTC)

changeset: 2697:fe8a99d89597
user: Kris Maglione <kris_AT_suckless.org>
date: Thu Jun 03 17:08:50 2010 -0400
files: cmd/wmii/ewmh.c cmd/wmii/fns.h cmd/wmii/frame.c
description:
Show indication when clients are wedged.

diff -r c26d9fd20d55 -r fe8a99d89597 cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Thu Jun 03 10:57:34 2010 -0400
+++ b/cmd/wmii/ewmh.c Thu Jun 03 17:08:50 2010 -0400
@@ -76,13 +76,19 @@
         changeprop_long(&scr.root, Net("SUPPORTED"), "ATOM", supported, nelem(supported));
 }
 
+inline bool
+ewmh_responsive_p(Client *c) {
+ return c->w.ewmh.ping == 0 || nsec() / 1000000 - c->w.ewmh.ping < PingTime;
+}
+
 void
 ewmh_checkresponsive(Client *c) {
 
- if(c->w.ewmh.ping > 0 && nsec() / 1000000 - c->w.ewmh.ping > PingTime) {
- event("Unresponsive %#C\n", c);
- c->dead++;
- }
+ if(!ewmh_responsive_p(c))
+ if(!c->dead)
+ frame_draw(c->sel);
+ else if(c->dead++ == 1)
+ event("Unresponsive %#C\n", c);
 }
 
 static void
@@ -97,7 +103,7 @@
         mod = count % PingPartition;
         for(i=0, c=client; c; c=c->next, i++)
                 if(c->proto & ProtoPing) {
- if(c->dead == 1)
+ if(!ewmh_responsive_p(c))
                                 ewmh_checkresponsive(c);
                         if(i % PingPartition == mod)
                                 sendmessage(&c->w, "WM_PROTOCOLS", NET("WM_PING"), time, c->w.xid, 0, 0);
@@ -407,6 +413,7 @@
 
 static bool
 event_root_clientmessage(Window *w, void *aux, XClientMessageEvent *e) {
+ Client *c;
         View *v;
         ulong *l;
         ulong msg;
@@ -433,11 +440,14 @@
                 if(l[0] == NET("WM_PING")) {
                         if(e->window != scr.root.xid)
                                 return false;
- if(!(w = findwin(l[2])))
+ if(!(c = win2client(l[2])))
                                 return false;
- w->ewmh.ping = nsec() / 1000000;
- w->ewmh.lag = (w->ewmh.ping & 0xffffffff) - (l[1] & 0xffffffff);
- Dprint(DEwmh, "\twindow=%W lag=%,uld\n", w, w->ewmh.lag);
+ i = ewmh_responsive_p(c);
+ c->w.ewmh.ping = nsec() / 1000000;
+ c->w.ewmh.lag = (c->w.ewmh.ping & 0xffffffff) - (l[1] & 0xffffffff);
+ if(i == false)
+ frame_draw(c->sel);
+ Dprint(DEwmh, "\twindow=%W lag=%,uld\n", &c->w, c->w.ewmh.lag);
                         return false;
                 }
                 return false;
diff -r c26d9fd20d55 -r fe8a99d89597 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Thu Jun 03 10:57:34 2010 -0400
+++ b/cmd/wmii/fns.h Thu Jun 03 17:08:50 2010 -0400
@@ -145,6 +145,7 @@
 void ewmh_initclient(Client*);
 bool ewmh_prop(Client*, Atom);
 long ewmh_protocols(Window*);
+bool ewmh_responsive_p(Client*);
 void ewmh_updateclient(Client*);
 void ewmh_updateclientlist(void);
 void ewmh_updateclients(void);
diff -r c26d9fd20d55 -r fe8a99d89597 cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Thu Jun 03 10:57:34 2010 -0400
+++ b/cmd/wmii/frame.c Thu Jun 03 17:08:50 2010 -0400
@@ -428,9 +428,7 @@
         uint w;
         int n, m;
 
- if(f->view != selview)
- return;
- if(f->area == nil) /* Blech. */
+ if(f == nil || f->view != selview || f->area == nil)
                 return;
 
         c = f->client;
@@ -503,8 +501,9 @@
         }else /* Make sure floating clients have room for their indicators. */
         if(c->floating)
                 r.max.x -= Dx(f->grabbox);
- w = drawstring(img, def.font, r, West,
- c->name, col->fg);
+ if(!ewmh_responsive_p(c))
+ r.min.x += drawstring(img, def.font, r, West, "(wedged) ", col->fg);
+ w = drawstring(img, def.font, r, West, c->name, col->fg);
 
         /* Draw inner border on floating clients. */
         if(f->area->floating) {
Received on Fri Jun 04 2010 - 01:48:13 UTC

This archive was generated by hypermail 2.2.0 : Fri Jun 04 2010 - 02:00:08 UTC