summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-19 13:42:39 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-19 13:42:39 +0100
commit30af19d4426ca32dc38318bbe87534cc44484998 (patch)
treec3d862223531f5b02e3cb6e31b7e9ee5d38193a6
parentsome more refactoring (diff)
downloaddwm-30af19d4426ca32dc38318bbe87534cc44484998.tar.gz
dwm-30af19d4426ca32dc38318bbe87534cc44484998.zip
added some new convenience functions
Diffstat (limited to '')
-rw-r--r--client.c49
-rw-r--r--dwm.h5
-rw-r--r--tile.c5
-rw-r--r--view.c11
4 files changed, 40 insertions, 30 deletions
diff --git a/client.c b/client.c
index 79cd698..9a30526 100644
--- a/client.c
+++ b/client.c
@@ -10,13 +10,6 @@
10/* static */ 10/* static */
11 11
12static void 12static void
13detachstack(Client *c) {
14 Client **tc;
15 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
16 *tc = c->snext;
17}
18
19static void
20grabbuttons(Client *c, Bool focused) { 13grabbuttons(Client *c, Bool focused) {
21 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 14 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
22 15
@@ -68,6 +61,20 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
68/* extern */ 61/* extern */
69 62
70void 63void
64attach(Client *c) {
65 if(clients)
66 clients->prev = c;
67 c->next = clients;
68 clients = c;
69}
70
71void
72attachstack(Client *c) {
73 c->snext = stack;
74 stack = c;
75}
76
77void
71configure(Client *c) { 78configure(Client *c) {
72 XConfigureEvent ce; 79 XConfigureEvent ce;
73 80
@@ -86,6 +93,24 @@ configure(Client *c) {
86} 93}
87 94
88void 95void
96detach(Client *c) {
97 if(c->prev)
98 c->prev->next = c->next;
99 if(c->next)
100 c->next->prev = c->prev;
101 if(c == clients)
102 clients = c->next;
103 c->next = c->prev = NULL;
104}
105
106void
107detachstack(Client *c) {
108 Client **tc;
109 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
110 *tc = c->snext;
111}
112
113void
89focus(Client *c) { 114focus(Client *c) {
90 if(c && !isvisible(c)) 115 if(c && !isvisible(c))
91 return; 116 return;
@@ -95,8 +120,7 @@ focus(Client *c) {
95 } 120 }
96 if(c) { 121 if(c) {
97 detachstack(c); 122 detachstack(c);
98 c->snext = stack; 123 attachstack(c);
99 stack = c;
100 grabbuttons(c, True); 124 grabbuttons(c, True);
101 } 125 }
102 sel = c; 126 sel = c;
@@ -189,11 +213,8 @@ manage(Window w, XWindowAttributes *wa) {
189 settags(c, t); 213 settags(c, t);
190 if(!c->isfloat) 214 if(!c->isfloat)
191 c->isfloat = (t != 0) || c->isfixed; 215 c->isfloat = (t != 0) || c->isfixed;
192 if(clients) 216 attach(c);
193 clients->prev = c; 217 attachstack(c);
194 c->next = clients;
195 c->snext = stack;
196 stack = clients = c;
197 c->isbanned = True; 218 c->isbanned = True;
198 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 219 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
199 XMapWindow(dpy, c->win); 220 XMapWindow(dpy, c->win);
diff --git a/dwm.h b/dwm.h
index c07229a..35950a6 100644
--- a/dwm.h
+++ b/dwm.h
@@ -99,7 +99,11 @@ extern Display *dpy;
99extern Window root, barwin; 99extern Window root, barwin;
100 100
101/* client.c */ 101/* client.c */
102extern void attach(Client *c); /* attaches c to global client list */
103extern void attachstack(Client *c); /* attaches client to stack */
102extern void configure(Client *c); /* send synthetic configure event */ 104extern void configure(Client *c); /* send synthetic configure event */
105extern void detach(Client *c); /* detaches c from global client list */
106extern void detachstack(Client *c); /* detaches client from stack */
103extern void focus(Client *c); /* focus c, c may be NULL */ 107extern void focus(Client *c); /* focus c, c may be NULL */
104extern Client *getclient(Window w); /* return client of w */ 108extern Client *getclient(Window w); /* return client of w */
105extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ 109extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
@@ -144,7 +148,6 @@ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 *
144extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ 148extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
145 149
146/* view.c */ 150/* view.c */
147extern void detach(Client *c); /* detaches c from global client list */
148extern void dofloat(void); /* arranges all windows floating */ 151extern void dofloat(void); /* arranges all windows floating */
149extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ 152extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
150extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ 153extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
diff --git a/tile.c b/tile.c
index fe25943..8075e55 100644
--- a/tile.c
+++ b/tile.c
@@ -125,10 +125,7 @@ zoom(Arg *arg) {
125 if(!(c = nextmanaged(c->next))) 125 if(!(c = nextmanaged(c->next)))
126 return; 126 return;
127 detach(c); 127 detach(c);
128 if(clients) 128 attach(c);
129 clients->prev = c;
130 c->next = clients;
131 clients = c;
132 focus(c); 129 focus(c);
133 arrange(); 130 arrange();
134} 131}
diff --git a/view.c b/view.c
index 72aa04e..cd07b94 100644
--- a/view.c
+++ b/view.c
@@ -8,17 +8,6 @@
8void (*arrange)(void) = DEFMODE; 8void (*arrange)(void) = DEFMODE;
9 9
10void 10void
11detach(Client *c) {
12 if(c->prev)
13 c->prev->next = c->next;
14 if(c->next)
15 c->next->prev = c->prev;
16 if(c == clients)
17 clients = c->next;
18 c->next = c->prev = NULL;
19}
20
21void
22dofloat(void) { 11dofloat(void) {
23 Client *c; 12 Client *c;
24 13