summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-19 14:57:32 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-19 14:57:32 +0100
commit64871a7045077bb2ec4cbcd62a74cabbe6b45096 (patch)
tree7e9d0fbab49039b32bf99924546edbe41392842e /client.c
parentrenamed Rule members, renamed RReg into Regexps (diff)
downloaddwm-64871a7045077bb2ec4cbcd62a74cabbe6b45096.tar.gz
dwm-64871a7045077bb2ec4cbcd62a74cabbe6b45096.zip
renamed manage.c to view.c
Diffstat (limited to '')
-rw-r--r--client.c96
1 files changed, 85 insertions, 11 deletions
diff --git a/client.c b/client.c
index e7a3864..45f2d19 100644
--- a/client.c
+++ b/client.c
@@ -46,6 +46,21 @@ grabbuttons(Client *c, Bool focused) {
46 GrabModeAsync, GrabModeSync, None, None); 46 GrabModeAsync, GrabModeSync, None, None);
47} 47}
48 48
49static Bool
50isprotodel(Client *c) {
51 int i, n;
52 Atom *protocols;
53 Bool ret = False;
54
55 if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
56 for(i = 0; !ret && i < n; i++)
57 if(protocols[i] == wmatom[WMDelete])
58 ret = True;
59 XFree(protocols);
60 }
61 return ret;
62}
63
49static void 64static void
50setclientstate(Client *c, long state) { 65setclientstate(Client *c, long state) {
51 long data[] = {state, None}; 66 long data[] = {state, None};
@@ -61,6 +76,20 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
61/* extern */ 76/* extern */
62 77
63void 78void
79attach(Client *c) {
80 if(clients)
81 clients->prev = c;
82 c->next = clients;
83 clients = c;
84}
85
86void
87attachstack(Client *c) {
88 c->snext = stack;
89 stack = c;
90}
91
92void
64configure(Client *c) { 93configure(Client *c) {
65 XConfigureEvent ce; 94 XConfigureEvent ce;
66 95
@@ -79,6 +108,24 @@ configure(Client *c) {
79} 108}
80 109
81void 110void
111detach(Client *c) {
112 if(c->prev)
113 c->prev->next = c->next;
114 if(c->next)
115 c->next->prev = c->prev;
116 if(c == clients)
117 clients = c->next;
118 c->next = c->prev = NULL;
119}
120
121void
122detachstack(Client *c) {
123 Client **tc;
124 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
125 *tc = c->snext;
126}
127
128void
82focus(Client *c) { 129focus(Client *c) {
83 if(c && !isvisible(c)) 130 if(c && !isvisible(c))
84 return; 131 return;
@@ -103,19 +150,46 @@ focus(Client *c) {
103 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 150 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
104} 151}
105 152
106Bool 153void
107isprotodel(Client *c) { 154focusnext(Arg *arg) {
108 int i, n; 155 Client *c;
109 Atom *protocols; 156
110 Bool ret = False; 157 if(!sel)
158 return;
159 for(c = sel->next; c && !isvisible(c); c = c->next);
160 if(!c)
161 for(c = clients; c && !isvisible(c); c = c->next);
162 if(c) {
163 focus(c);
164 restack();
165 }
166}
111 167
112 if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { 168void
113 for(i = 0; !ret && i < n; i++) 169focusprev(Arg *arg) {
114 if(protocols[i] == wmatom[WMDelete]) 170 Client *c;
115 ret = True; 171
116 XFree(protocols); 172 if(!sel)
173 return;
174 for(c = sel->prev; c && !isvisible(c); c = c->prev);
175 if(!c) {
176 for(c = clients; c && c->next; c = c->next);
177 for(; c && !isvisible(c); c = c->prev);
117 } 178 }
118 return ret; 179 if(c) {
180 focus(c);
181 restack();
182 }
183}
184
185Client *
186getclient(Window w) {
187 Client *c;
188
189 for(c = clients; c; c = c->next)
190 if(c->win == w)
191 return c;
192 return NULL;
119} 193}
120 194
121void 195void