changeset: 2117:e919d7f50631
user: Kris Maglione <jg_AT_suckless.org>
date: Sun Apr 22 01:29:35 2007 -0400
summary: Track a window's class rather than polling it on name changes.
diff -r 32c73fb5bde9 -r e919d7f50631 cmd/wmii/client.c
--- a/cmd/wmii/client.c Sun Apr 22 01:04:55 2007 -0400
+++ b/cmd/wmii/client.c Sun Apr 22 01:29:35 2007 -0400
@@ -10,9 +10,7 @@
#include "dat.h"
#include "fns.h"
-static void update_client_name(Client *c);
static Handlers handlers;
-
static char Ebadcmd[] = "bad command";
Rectangle gravclient(Client*, Rectangle);
@@ -47,6 +45,7 @@ create_client(XWindow w, XWindowAttribut
prop_client(c, xatom("WM_TRANSIENT_FOR"));
prop_client(c, xatom("WM_NORMAL_HINTS"));
prop_client(c, xatom("WM_HINTS"));
+ prop_client(c, xatom("WM_CLASS"));
prop_client(c, xatom("WM_NAME"));
prop_client(c, xatom("_MOTIF_WM_HINTS"));
@@ -385,35 +384,6 @@ clientname(Client *c) {
}
void
-update_class(Client *c) {
- char **class;
- int n;
-
- n = gettextlistproperty(&c->w, "WM_CLASS", &class);
- snprintf(c->props, sizeof(c->props), "%s:%s:%s",
- (n > 0 ? class[0] : "<nil>"),
- (n > 1 ? class[1] : "<nil>"),
- c->name);
- freestringlist(class);
-}
-
-static void
-update_client_name(Client *c) {
- char *str;
-
- c->name[0] = '\0';
-
- str = gettextproperty(&c->w, "_NET_WM_NAME)");
- if(str == nil)
- str = gettextproperty(&c->w, "WM_NAME");
- if(str)
- utfecpy(c->name, c->name+sizeof(c->name), str);
- free(str);
-
- update_class(c);
-}
-
-void
set_client_state(Client * c, int state) {
long data[] = { state, None };
changeprop(&c->w, "WM_STATE", "WM_STATE", data, nelem(data));
@@ -548,6 +518,36 @@ set_urgent(Client *c, Bool urgent, Bool
}
}
+void
+update_class(Client *c) {
+ char *str;
+
+ str = utfrune(c->props, L':');
+ if(str)
+ str = utfrune(str+1, L':');
+ if(str == nil) {
+ strcpy(c->props, "::");
+ str = c->props + 1;
+ }
+ utfecpy(str+1, c->props+sizeof(c->props), c->name);
+}
+
+static void
+update_client_name(Client *c) {
+ char *str;
+
+ c->name[0] = '\0';
+
+ str = gettextproperty(&c->w, "_NET_WM_NAME)");
+ if(str == nil)
+ str = gettextproperty(&c->w, "WM_NAME");
+ if(str)
+ utfecpy(c->name, c->name+sizeof(c->name), str);
+ free(str);
+
+ update_class(c);
+}
+
static void
updatemwm(Client *c) {
enum {
@@ -589,6 +589,8 @@ void
void
prop_client(Client *c, Atom a) {
XWMHints *wmh;
+ char **class;
+ int n;
if(a == xatom("WM_PROTOCOLS"))
c->proto = winprotocols(&c->w);
@@ -612,6 +614,14 @@ prop_client(Client *c, Atom a) {
XFree(wmh);
}
break;
+ case XA_WM_CLASS:
+ n = gettextlistproperty(&c->w, "WM_CLASS", &class);
+ snprintf(c->props, sizeof(c->props), "%s:%s:",
+ (n > 0 ? class[0] : "<nil>"),
+ (n > 1 ? class[1] : "<nil>"));
+ freestringlist(class);
+ update_class(c);
+ break;
case XA_WM_NAME:
wmname:
update_client_name(c);
Received on Fri Jun 01 2007 - 03:10:03 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:03 UTC