summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client.c96
-rw-r--r--dwm.h14
-rw-r--r--view.c (renamed from manage.c)74
3 files changed, 92 insertions, 92 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
diff --git a/dwm.h b/dwm.h
index 318ce9e..cca9984 100644
--- a/dwm.h
+++ b/dwm.h
@@ -99,8 +99,15 @@ 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 */
108extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
109extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
110extern Client *getclient(Window w); /* return client of w */
104extern void killclient(Arg *arg); /* kill c nicely */ 111extern void killclient(Arg *arg); /* kill c nicely */
105extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ 112extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
106extern void resize(Client *c, int x, int y, 113extern void resize(Client *c, int x, int y,
@@ -125,16 +132,9 @@ extern void sendevent(Window w, Atom a, long value); /* send synthetic event to
125extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ 132extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
126 133
127/* manage.c */ 134/* manage.c */
128extern void attach(Client *c); /* attaches c to global client list */
129extern void attachstack(Client *c); /* attaches client to stack */
130extern void compileregexps(void); /* initialize regexps of rules defined in config.h */ 135extern void compileregexps(void); /* initialize regexps of rules defined in config.h */
131extern void detach(Client *c); /* detaches c from global client list */
132extern void detachstack(Client *c); /* detaches client from stack */
133extern void dofloat(void); /* arranges all windows floating */ 136extern void dofloat(void); /* arranges all windows floating */
134extern void dotile(void); /* arranges all windows tiled */ 137extern void dotile(void); /* arranges all windows tiled */
135extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
136extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
137extern Client *getclient(Window w); /* return client of w */
138extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */ 138extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
139extern Bool isvisible(Client *c); /* returns True if client is visible */ 139extern Bool isvisible(Client *c); /* returns True if client is visible */
140extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ 140extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
diff --git a/manage.c b/view.c
index 9db139b..34aae58 100644
--- a/manage.c
+++ b/view.c
@@ -59,20 +59,6 @@ togglemax(Client *c) {
59/* extern */ 59/* extern */
60 60
61void 61void
62attach(Client *c) {
63 if(clients)
64 clients->prev = c;
65 c->next = clients;
66 clients = c;
67}
68
69void
70attachstack(Client *c) {
71 c->snext = stack;
72 stack = c;
73}
74
75void
76compileregexps(void) { 62compileregexps(void) {
77 unsigned int i; 63 unsigned int i;
78 regex_t *reg; 64 regex_t *reg;
@@ -100,24 +86,6 @@ compileregexps(void) {
100} 86}
101 87
102void 88void
103detach(Client *c) {
104 if(c->prev)
105 c->prev->next = c->next;
106 if(c->next)
107 c->next->prev = c->prev;
108 if(c == clients)
109 clients = c->next;
110 c->next = c->prev = NULL;
111}
112
113void
114detachstack(Client *c) {
115 Client **tc;
116 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
117 *tc = c->snext;
118}
119
120void
121dofloat(void) { 89dofloat(void) {
122 Client *c; 90 Client *c;
123 91
@@ -192,48 +160,6 @@ dotile(void) {
192} 160}
193 161
194void 162void
195focusnext(Arg *arg) {
196 Client *c;
197
198 if(!sel)
199 return;
200 for(c = sel->next; c && !isvisible(c); c = c->next);
201 if(!c)
202 for(c = clients; c && !isvisible(c); c = c->next);
203 if(c) {
204 focus(c);
205 restack();
206 }
207}
208
209void
210focusprev(Arg *arg) {
211 Client *c;
212
213 if(!sel)
214 return;
215 for(c = sel->prev; c && !isvisible(c); c = c->prev);
216 if(!c) {
217 for(c = clients; c && c->next; c = c->next);
218 for(; c && !isvisible(c); c = c->prev);
219 }
220 if(c) {
221 focus(c);
222 restack();
223 }
224}
225
226Client *
227getclient(Window w) {
228 Client *c;
229
230 for(c = clients; c; c = c->next)
231 if(c->win == w)
232 return c;
233 return NULL;
234}
235
236void
237incnmaster(Arg *arg) { 163incnmaster(Arg *arg) {
238 if((arrange == dofloat) || (nmaster + arg->i < 1) 164 if((arrange == dofloat) || (nmaster + arg->i < 1)
239 || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) 165 || (wah / (nmaster + arg->i) <= 2 * BORDERPX))