[hackers] [wmii] Cache property change values to cut down on noise. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Thu, 24 Jun 2010 15:04:20 +0000 (UTC)

changeset: 2742:b69ff38fcfd3
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Thu Jun 24 11:03:52 2010 -0400
files: cmd/wmii/client.c cmd/wmii/dat.h cmd/wmii/ewmh.c
description:
Cache property change values to cut down on noise.

diff -r a4cc538b2fb8 -r b69ff38fcfd3 cmd/wmii/client.c
--- a/cmd/wmii/client.c Thu Jun 24 10:39:42 2010 -0400
+++ b/cmd/wmii/client.c Thu Jun 24 11:03:52 2010 -0400
@@ -631,7 +631,6 @@
                 return;
 
         event("Fullscreen %#C %s\n", c, (fullscreen ? "on" : "off"));
- ewmh_updatestate(c);
 
         c->fullscreen = -1;
         if(!fullscreen)
@@ -666,6 +665,7 @@
                 if((f = c->sel))
                         view_update(f->view);
         }
+ ewmh_updatestate(c);
 }
 
 void
diff -r a4cc538b2fb8 -r b69ff38fcfd3 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Thu Jun 24 10:39:42 2010 -0400
+++ b/cmd/wmii/dat.h Thu Jun 24 11:03:52 2010 -0400
@@ -50,6 +50,14 @@
         ISqueeze,
 };
 
+enum {
+ PDesktop,
+ PExtents,
+ PMonitors = PExtents + 4,
+ PState = PMonitors + 4,
+ PLast = PState + 3
+};
+
 enum ClientPermission {
         PermActivate = 1<<0,
 };
@@ -177,6 +185,8 @@
         char name[256];
         char props[512];
         char tags[256];
+ char proplen[PLast];
+ long propcache[PLast];
         long permission;
         long proto;
         int border;
diff -r a4cc538b2fb8 -r b69ff38fcfd3 cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Thu Jun 24 10:39:42 2010 -0400
+++ b/cmd/wmii/ewmh.c Thu Jun 24 11:03:52 2010 -0400
@@ -14,6 +14,20 @@
 static Handlers client_handlers;
 static Handlers root_handlers;
 
+static void
+clientprop_long(Client *c, int cache, char *prop, char *type, long *data, int l) {
+ if(l != c->proplen[cache] || memcmp(&c->propcache[cache], data, l * sizeof *data)) {
+ c->proplen[cache] = l;
+ memcpy(&c->propcache[cache], data, l * sizeof *data);
+ changeprop_long(&c->w, prop, type, data, l);
+ }
+}
+static void
+clientprop_del(Client *c, int cache, char *prop) {
+ c->proplen[cache] = 0;
+ delproperty(&c->w, prop);
+}
+
 void
 ewmh_init(void) {
         char myname[] = "wmii";
@@ -500,7 +514,7 @@
                 r.min.x, r.max.x,
                 r.min.y, r.max.y,
         };
- changeprop_long(&c->w, Net("FRAME_EXTENTS"), "CARDINAL",
+ clientprop_long(c, PExtents, Net("FRAME_EXTENTS"), "CARDINAL",
                         extents, nelem(extents));
 }
 
@@ -523,17 +537,17 @@
                 state[i++] = STATE("DEMANDS_ATTENTION");
 
         if(i > 0)
- changeprop_long(&c->w, Net("WM_STATE"), "ATOM", state, i);
+ clientprop_long(c, PState, Net("WM_STATE"), "ATOM", state, i);
         else
- delproperty(&c->w, Net("WM_STATE"));
+ clientprop_del(c, PState, Net("WM_STATE"));
 
         if(c->fullscreen >= 0)
- changeprop_long(&c->w, Net("WM_FULLSCREEN_MONITORS"), "CARDINAL",
+ clientprop_long(c, PMonitors, Net("WM_FULLSCREEN_MONITORS"), "CARDINAL",
                                 (long[]) { c->fullscreen, c->fullscreen,
                                            c->fullscreen, c->fullscreen },
                                 4);
         else
- delproperty(&c->w, Net("WM_FULLSCREEN_MONITORS"));
+ clientprop_del(c, PMonitors, Net("WM_FULLSCREEN_MONITORS"));
 }
 
 /* Views */
@@ -587,7 +601,7 @@
         i = -1;
         if(c->sel)
                 i = viewidx(c->sel->view);
- changeprop_long(&c->w, Net("WM_DESKTOP"), "CARDINAL", &i, 1);
+ clientprop_long(c, PDesktop, Net("WM_DESKTOP"), "CARDINAL", &i, 1);
 }
 
 void
Received on Thu Jun 24 2010 - 15:04:20 UTC

This archive was generated by hypermail 2.2.0 : Thu Jun 24 2010 - 15:12:05 UTC