[wmii] x11-window-id for clients patch

From: Daniel Waeber <_wabu_AT_web.de>
Date: Sun, 21 Jan 2007 12:19:09 +0100

Because of the great idea form Denis to use the X11's IDs in the wmii
file system, I implemented it. Now you have all the freedem to do
everyting you want with your clients, eg. setting the transparency using
transset-df.
Hope you like it.

Regards
        wabu

diff -r f8e25d315eed client.c
--- a/client.c Tue Jan 16 23:01:53 2007 +0100
+++ b/client.c Sun Jan 21 11:54:54 2007 +0100
@@ -15,14 +15,6 @@ Client *
 Client *
 sel_client() {
         return screen->sel && screen->sel->sel->sel ? screen->sel->sel->sel->client : NULL;
-}
-
-int
-idx_of_client(Client *c) {
- Client *cl;
- int i = 0;
- for(cl=client; cl && cl != c; cl=cl->next, i++);
- return cl ? i : -1;
 }
 
 Client *
@@ -81,10 +73,7 @@ create_client(Window w, XWindowAttribute
         Client **t, *c = (Client *) ixp_emallocz(sizeof(Client));
         XSetWindowAttributes fwa;
         long msize;
- unsigned int i;
- static unsigned int id = 1;
-
- c->id = id++;
+
         c->win = w;
         c->rect.x = wa->x;
         c->rect.y = wa->y;
@@ -117,10 +106,10 @@ create_client(Window w, XWindowAttribute
                         CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
         c->gc = XCreateGC(blz.dpy, c->framewin, 0, 0);
         XSync(blz.dpy, False);
- for(t=&client, i=0; *t; t=&(*t)->next, i++);
+ for(t=&client; *t; t=&(*t)->next);
         c->next = *t; /* *t == NULL */
         *t = c;
- write_event("CreateClient %d\n", i);
+ write_event("CreateClient %d\n", c->win);
         return c;
 }
 
@@ -180,7 +169,7 @@ focus_client(Client *c, Bool restack) {
                 if(a_i) write_event("ColumnFocus %d\n", a_i);
                 else write_event("FocusFloating\n");
         }
- write_event("ClientFocus %d\n", idx_of_client(c));
+ write_event("ClientFocus %d\n", c->win);
 }
 
 void
@@ -375,7 +364,6 @@ destroy_client(Client *c) {
 destroy_client(Client *c) {
         char *dummy = NULL;
         Client **tc;
- uint i = idx_of_client(c);
 
         XGrabServer(blz.dpy);
         XSetErrorHandler(dummy_error_handler);
@@ -397,7 +385,7 @@ destroy_client(Client *c) {
         XSetErrorHandler(wmii_error_handler);
         XUngrabServer(blz.dpy);
         flush_masked_events(EnterWindowMask);
- write_event("DestroyClient %d\n", i);
+ write_event("DestroyClient %d\n", c->win);
 }
 
 void
diff -r f8e25d315eed event.c
--- a/event.c Tue Jan 16 23:01:53 2007 +0100
+++ b/event.c Sun Jan 21 11:45:09 2007 +0100
@@ -74,7 +74,7 @@ buttonrelease(XEvent *e) {
                         }
         }
         else if((f = frame_of_win(ev->window)))
- write_event("ClientClick %d %d\n", idx_of_client(f->client), ev->button);
+ write_event("ClientClick %d %d\n", f->client->win, ev->button);
 }
 
 static void
diff -r f8e25d315eed fs.c
--- a/fs.c Tue Jan 16 23:01:53 2007 +0100
+++ b/fs.c Sun Jan 21 11:44:44 2007 +0100
@@ -257,6 +257,7 @@ message_root(char *message)
                 free(def.font.fontstr);
                 def.font.fontstr = ixp_estrdup(message);
                 loadfont(&blz, &def.font);
+ resize_bar(screen);
         }
         else if(!strncmp(message, "border ", 7)) {
                 message += 7;
@@ -365,7 +366,7 @@ lookup_file(FileId *parent, char *name)
         Client *c;
         View *v;
         Bar *b;
- unsigned int i, id;
+ unsigned int id;
 
         if(!(parent->tab.perm & P9DMDIR))
                 return NULL;
@@ -383,8 +384,8 @@ lookup_file(FileId *parent, char *name)
                                                 *last = file;
                                                 last = &file->next;
                                                 file->content.client = c;
- file->id = c->id;
- file->index = idx_of_client(c);
+ file->id = c->win;
+ file->index = c->win;
                                                 file->tab = *dir;
                                                 file->tab.name = ixp_estrdup("sel");
                                         }if(name) goto LastItem;
@@ -393,17 +394,16 @@ lookup_file(FileId *parent, char *name)
                                         id = (unsigned int)strtol(name, &name, 10);
                                         if(*name) goto NextItem;
                                 }
- i=0;
- for(c=client; c; c=c->next, i++) {
- if(!name || i == id) {
+ for(c=client; c; c=c->next) {
+ if(!name || c->win == id) {
                                                 file = get_file();
                                                 *last = file;
                                                 last = &file->next;
                                                 file->content.client = c;
- file->id = c->id;
+ file->id = c->win;
                                                 file->tab = *dir;
                                                 file->tab.name = ixp_emallocz(16);
- snprintf(file->tab.name, 16, "%d", i);
+ snprintf(file->tab.name, 16, "%d", c->win);
                                                 if(name) goto LastItem;
                                         }
                                 }
diff -r f8e25d315eed view.c
--- a/view.c Tue Jan 16 23:01:53 2007 +0100
+++ b/view.c Sun Jan 21 11:42:53 2007 +0100
@@ -287,12 +287,12 @@ view_index(View *v) {
                         XRectangle *r = &f->rect;
                         if(a->floating)
                                 n = snprintf(&buffer[buf_i], len, "~ %d %d %d %d %d %s\n",
- idx_of_client(f->client),
+ f->client->win,
                                                 r->x, r->y, r->width, r->height,
                                                 f->client->props);
                         else
                                 n = snprintf(&buffer[buf_i], len, "%d %d %d %d %s\n",
- a_i, idx_of_client(f->client), r->y,
+ a_i, f->client->win, r->y,
                                                 r->height, f->client->props);
                         if(len - n < 0)
                                 return (unsigned char *)buffer;
diff -r f8e25d315eed wmii.h
--- a/wmii.h Tue Jan 16 23:01:53 2007 +0100
+++ b/wmii.h Sun Jan 21 11:55:06 2007 +0100
@@ -135,7 +135,6 @@ struct Client {
         char name[256];
         char tags[256];
         char props[512];
- unsigned short id;
         unsigned int border;
         int proto;
         Bool floating;
@@ -280,7 +279,6 @@ extern Client *sel_client();
 extern Client *sel_client();
 extern Frame *frame_of_win(Window w);
 extern Client *client_of_win(Window w);
-extern int idx_of_client(Client *c);
 extern void update_client_grab(Client *c, Bool is_sel);
 extern void apply_rules(Client *c);
 extern void apply_tags(Client *c, const char *tags);

Received on Sun Jan 21 2007 - 12:20:37 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:19:31 UTC