summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-05-14 11:54:30 +0200
committerAnselm R. Garbe <arg@suckless.org>2007-05-14 11:54:30 +0200
commitab3d6a7dfe76d9857f2fc621034359a2a0bf09df (patch)
tree9738e466d2ea2b0e1107084b159f8a1b93f271af
parentsmall fix of fix (diff)
downloaddwm-ab3d6a7dfe76d9857f2fc621034359a2a0bf09df.tar.gz
dwm-ab3d6a7dfe76d9857f2fc621034359a2a0bf09df.zip
applied dfenze cleanups, fixed some comments in dwm.h
Diffstat (limited to '')
-rw-r--r--client.c14
-rw-r--r--dwm.h9
-rw-r--r--event.c3
-rw-r--r--layout.c15
4 files changed, 20 insertions, 21 deletions
diff --git a/client.c b/client.c
index 3db14f5..72e5c32 100644
--- a/client.c
+++ b/client.c
@@ -153,6 +153,14 @@ focus(Client *c) {
153} 153}
154 154
155void 155void
156focustopvisible(void) {
157 Client *c;
158
159 for(c = stack; c && !isvisible(c); c = c->snext);
160 focus(c);
161}
162
163void
156killclient(const char *arg) { 164killclient(const char *arg) {
157 XEvent ev; 165 XEvent ev;
158 166
@@ -391,10 +399,8 @@ unmanage(Client *c) {
391 XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */ 399 XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
392 detach(c); 400 detach(c);
393 detachstack(c); 401 detachstack(c);
394 if(sel == c) { 402 if(sel == c)
395 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); 403 focustopvisible();
396 focus(nc);
397 }
398 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 404 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
399 setclientstate(c, WithdrawnState); 405 setclientstate(c, WithdrawnState);
400 free(c->tags); 406 free(c->tags);
diff --git a/dwm.h b/dwm.h
index 9e4cf45..ed5a304 100644
--- a/dwm.h
+++ b/dwm.h
@@ -100,11 +100,12 @@ void attach(Client *c); /* attaches c to global client list */
100void configure(Client *c); /* send synthetic configure event */ 100void configure(Client *c); /* send synthetic configure event */
101void detach(Client *c); /* detaches c from global client list */ 101void detach(Client *c); /* detaches c from global client list */
102void focus(Client *c); /* focus c, c may be NULL */ 102void focus(Client *c); /* focus c, c may be NULL */
103void killclient(const char *arg); /* kill c nicely */ 103void focustopvisible(void); /* focus top visible window on stack */
104void killclient(const char *arg); /* kill sel nicely */
104void manage(Window w, XWindowAttributes *wa); /* manage new client */ 105void manage(Window w, XWindowAttributes *wa); /* manage new client */
105void resize(Client *c, int x, int y, 106void resize(Client *c, int x, int y,
106 int w, int h, Bool sizehints); /* resize with given coordinates c*/ 107 int w, int h, Bool sizehints); /* resize with given coordinates c*/
107void togglefloating(const char *arg); /* toggles focused client between floating/tiled state */ 108void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
108void updatesizehints(Client *c); /* update the size hint variables of c */ 109void updatesizehints(Client *c); /* update the size hint variables of c */
109void updatetitle(Client *c); /* update the name of c */ 110void updatetitle(Client *c); /* update the name of c */
110void unmanage(Client *c); /* destroy c */ 111void unmanage(Client *c); /* destroy c */
@@ -137,8 +138,8 @@ int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
137void compileregs(void); /* initialize regexps of rules defined in config.h */ 138void compileregs(void); /* initialize regexps of rules defined in config.h */
138Bool isvisible(Client *c); /* returns True if client is visible */ 139Bool isvisible(Client *c); /* returns True if client is visible */
139void settags(Client *c, Client *trans); /* sets tags of c */ 140void settags(Client *c, Client *trans); /* sets tags of c */
140void tag(const char *arg); /* tags c with arg's index */ 141void tag(const char *arg); /* tags sel with arg's index */
141void toggletag(const char *arg); /* toggles c tags with arg's index */ 142void toggletag(const char *arg); /* toggles sel tags with arg's index */
142void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */ 143void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */
143void view(const char *arg); /* views the tag with arg's index */ 144void view(const char *arg); /* views the tag with arg's index */
144 145
diff --git a/event.c b/event.c
index 12746f6..4c0e4e7 100644
--- a/event.c
+++ b/event.c
@@ -247,8 +247,7 @@ enternotify(XEvent *e) {
247 focus(c); 247 focus(c);
248 else if(ev->window == root) { 248 else if(ev->window == root) {
249 selscreen = True; 249 selscreen = True;
250 for(c = stack; c && !isvisible(c); c = c->snext); 250 focustopvisible();
251 focus(c);
252 } 251 }
253} 252}
254 253
diff --git a/layout.c b/layout.c
index 259f489..04835a8 100644
--- a/layout.c
+++ b/layout.c
@@ -61,10 +61,8 @@ tile(void) {
61 c->isbanned = True; 61 c->isbanned = True;
62 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 62 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
63 } 63 }
64 if(!sel || !isvisible(sel)) { 64 if(!sel || !isvisible(sel))
65 for(c = stack; c && !isvisible(c); c = c->snext); 65 focustopvisible();
66 focus(c);
67 }
68 restack(); 66 restack();
69} 67}
70 68
@@ -88,10 +86,8 @@ floating(void) {
88 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 86 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
89 } 87 }
90 } 88 }
91 if(!sel || !isvisible(sel)) { 89 if(!sel || !isvisible(sel))
92 for(c = stack; c && !isvisible(c); c = c->snext); 90 focustopvisible();
93 focus(c);
94 }
95 restack(); 91 restack();
96} 92}
97 93
@@ -241,13 +237,10 @@ togglemax(const char *arg) {
241 237
242void 238void
243zoom(const char *arg) { 239zoom(const char *arg) {
244 unsigned int n;
245 Client *c; 240 Client *c;
246 241
247 if(!sel || lt->arrange != tile || sel->isfloating) 242 if(!sel || lt->arrange != tile || sel->isfloating)
248 return; 243 return;
249 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
250 n++;
251 if((c = sel) == nexttiled(clients)) 244 if((c = sel) == nexttiled(clients))
252 if(!(c = nexttiled(c->next))) 245 if(!(c = nexttiled(c->next)))
253 return; 246 return;