commit ec18eb22e960272a122c8427540fc123af110619
parent 5a6c5c1b4d780ec80663a6b2101e4b53267d4067
Author: Kris Maglione <kris@suckless.org>
Date: Thu, 24 Jun 2010 11:03:52 -0400
Cache property change values to cut down on noise.
Diffstat:
3 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c
@@ -631,7 +631,6 @@ fullscreen(Client *c, int fullscreen, long screen) {
return;
event("Fullscreen %#C %s\n", c, (fullscreen ? "on" : "off"));
- ewmh_updatestate(c);
c->fullscreen = -1;
if(!fullscreen)
@@ -666,6 +665,7 @@ fullscreen(Client *c, int fullscreen, long screen) {
if((f = c->sel))
view_update(f->view);
}
+ ewmh_updatestate(c);
}
void
diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h
@@ -50,6 +50,14 @@ enum IncMode {
ISqueeze,
};
+enum {
+ PDesktop,
+ PExtents,
+ PMonitors = PExtents + 4,
+ PState = PMonitors + 4,
+ PLast = PState + 3
+};
+
enum ClientPermission {
PermActivate = 1<<0,
};
@@ -177,6 +185,8 @@ struct Client {
char name[256];
char props[512];
char tags[256];
+ char proplen[PLast];
+ long propcache[PLast];
long permission;
long proto;
int border;
diff --git a/cmd/wmii/ewmh.c b/cmd/wmii/ewmh.c
@@ -14,6 +14,20 @@ static void tick(long, void*);
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 @@ ewmh_framesize(Client *c) {
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 @@ ewmh_updatestate(Client *c) {
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 @@ ewmh_updateclient(Client *c) {
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