[hackers] [dwm] added some new convenience functions

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Mon Feb 19 13:42:51 2007

changeset: 771:05946fa53085
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Mon Feb 19 13:42:39 2007 +0100
summary: added some new convenience functions

diff -r 5280cbb5bbd4 -r 05946fa53085 client.c
--- a/client.c Mon Feb 19 13:17:49 2007 +0100
+++ b/client.c Mon Feb 19 13:42:39 2007 +0100
@@ -10,13 +10,6 @@
 /* static */
 
 static void
-detachstack(Client *c) {
- Client **tc;
- for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
- *tc = c->snext;
-}
-
-static void
 grabbuttons(Client *c, Bool focused) {
         XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
 
@@ -66,6 +59,20 @@ xerrordummy(Display *dsply, XErrorEvent
 }
 
 /* extern */
+
+void
+attach(Client *c) {
+ if(clients)
+ clients->prev = c;
+ c->next = clients;
+ clients = c;
+}
+
+void
+attachstack(Client *c) {
+ c->snext = stack;
+ stack = c;
+}
 
 void
 configure(Client *c) {
@@ -86,6 +93,24 @@ configure(Client *c) {
 }
 
 void
+detach(Client *c) {
+ if(c->prev)
+ c->prev->next = c->next;
+ if(c->next)
+ c->next->prev = c->prev;
+ if(c == clients)
+ clients = c->next;
+ c->next = c->prev = NULL;
+}
+
+void
+detachstack(Client *c) {
+ Client **tc;
+ for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
+ *tc = c->snext;
+}
+
+void
 focus(Client *c) {
         if(c && !isvisible(c))
                 return;
@@ -95,8 +120,7 @@ focus(Client *c) {
         }
         if(c) {
                 detachstack(c);
- c->snext = stack;
- stack = c;
+ attachstack(c);
                 grabbuttons(c, True);
         }
         sel = c;
@@ -189,11 +213,8 @@ manage(Window w, XWindowAttributes *wa)
         settags(c, t);
         if(!c->isfloat)
                 c->isfloat = (t != 0) || c->isfixed;
- if(clients)
- clients->prev = c;
- c->next = clients;
- c->snext = stack;
- stack = clients = c;
+ attach(c);
+ attachstack(c);
         c->isbanned = True;
         XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
         XMapWindow(dpy, c->win);
diff -r 5280cbb5bbd4 -r 05946fa53085 dwm.h
--- a/dwm.h Mon Feb 19 13:17:49 2007 +0100
+++ b/dwm.h Mon Feb 19 13:42:39 2007 +0100
@@ -99,7 +99,11 @@ extern Window root, barwin;
 extern Window root, barwin;
 
 /* client.c */
+extern void attach(Client *c); /* attaches c to global client list */
+extern void attachstack(Client *c); /* attaches client to stack */
 extern void configure(Client *c); /* send synthetic configure event */
+extern void detach(Client *c); /* detaches c from global client list */
+extern void detachstack(Client *c); /* detaches client from stack */
 extern void focus(Client *c); /* focus c, c may be NULL */
 extern Client *getclient(Window w); /* return client of w */
 extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
@@ -144,7 +148,6 @@ extern void spawn(Arg *arg); /* forks
 extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
 
 /* view.c */
-extern void detach(Client *c); /* detaches c from global client list */
 extern void dofloat(void); /* arranges all windows floating */
 extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
 extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
diff -r 5280cbb5bbd4 -r 05946fa53085 tile.c
--- a/tile.c Mon Feb 19 13:17:49 2007 +0100
+++ b/tile.c Mon Feb 19 13:42:39 2007 +0100
@@ -125,10 +125,7 @@ zoom(Arg *arg) {
                 if(!(c = nextmanaged(c->next)))
                         return;
         detach(c);
- if(clients)
- clients->prev = c;
- c->next = clients;
- clients = c;
+ attach(c);
         focus(c);
         arrange();
 }
diff -r 5280cbb5bbd4 -r 05946fa53085 view.c
--- a/view.c Mon Feb 19 13:17:49 2007 +0100
+++ b/view.c Mon Feb 19 13:42:39 2007 +0100
@@ -6,17 +6,6 @@
 /* extern */
 
 void (*arrange)(void) = DEFMODE;
-
-void
-detach(Client *c) {
- if(c->prev)
- c->prev->next = c->next;
- if(c->next)
- c->next->prev = c->prev;
- if(c == clients)
- clients = c->next;
- c->next = c->prev = NULL;
-}
 
 void
 dofloat(void) {
Received on Mon Feb 19 2007 - 13:42:51 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:27 UTC