summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorarg@suckless.org <unknown>2007-09-17 16:42:37 +0200
committerarg@suckless.org <unknown>2007-09-17 16:42:37 +0200
commitfe2775a15ba2d4900788c57194da2bad3d19cfaf (patch)
treea668f514f4169a26568a8c5d209f3fb510e2b177 /dwm.c
parentthere might be envs which need Xlib.h (diff)
downloaddwm-fe2775a15ba2d4900788c57194da2bad3d19cfaf.tar.gz
dwm-fe2775a15ba2d4900788c57194da2bad3d19cfaf.zip
made all stuff non-static - so you can choose wether to use dwm the static or the extern way when extending it
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c361
1 files changed, 179 insertions, 182 deletions
diff --git a/dwm.c b/dwm.c
index 2602ed2..726e797 100644
--- a/dwm.c
+++ b/dwm.c
@@ -21,10 +21,7 @@
21 * creates a small title window, which is resized whenever the (_NET_)WM_NAME 21 * creates a small title window, which is resized whenever the (_NET_)WM_NAME
22 * properties are updated or the client is moved/resized. 22 * properties are updated or the client is moved/resized.
23 * 23 *
24 * Keys and tagging rules are organized as arrays and defined in the config.h 24 * Keys and tagging rules are organized as arrays and defined in config.h.
25 * file. These arrays are kept static in event.o and tag.o respectively,
26 * because no other part of dwm needs access to them. The current layout is
27 * represented by the lt pointer.
28 * 25 *
29 * To understand everything else, start reading main(). 26 * To understand everything else, start reading main().
30 */ 27 */
@@ -114,96 +111,96 @@ typedef struct {
114} Regs; 111} Regs;
115 112
116/* forward declarations */ 113/* forward declarations */
117static void applyrules(Client *c); 114void applyrules(Client *c);
118static void arrange(void); 115void arrange(void);
119static void attach(Client *c); 116void attach(Client *c);
120static void attachstack(Client *c); 117void attachstack(Client *c);
121static void ban(Client *c); 118void ban(Client *c);
122static void buttonpress(XEvent *e); 119void buttonpress(XEvent *e);
123static void checkotherwm(void); 120void checkotherwm(void);
124static void cleanup(void); 121void cleanup(void);
125static void compileregs(void); 122void compileregs(void);
126static void configure(Client *c); 123void configure(Client *c);
127static void configurenotify(XEvent *e); 124void configurenotify(XEvent *e);
128static void configurerequest(XEvent *e); 125void configurerequest(XEvent *e);
129static void destroynotify(XEvent *e); 126void destroynotify(XEvent *e);
130static void detach(Client *c); 127void detach(Client *c);
131static void detachstack(Client *c); 128void detachstack(Client *c);
132static void drawbar(void); 129void drawbar(void);
133static void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]); 130void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
134static void drawtext(const char *text, unsigned long col[ColLast]); 131void drawtext(const char *text, unsigned long col[ColLast]);
135static void *emallocz(unsigned int size); 132void *emallocz(unsigned int size);
136static void enternotify(XEvent *e); 133void enternotify(XEvent *e);
137static void eprint(const char *errstr, ...); 134void eprint(const char *errstr, ...);
138static void expose(XEvent *e); 135void expose(XEvent *e);
139static void floating(void); /* default floating layout */ 136void floating(void); /* default floating layout */
140static void focus(Client *c); 137void focus(Client *c);
141static void focusnext(const char *arg); 138void focusnext(const char *arg);
142static void focusprev(const char *arg); 139void focusprev(const char *arg);
143static Client *getclient(Window w); 140Client *getclient(Window w);
144static unsigned long getcolor(const char *colstr); 141unsigned long getcolor(const char *colstr);
145static long getstate(Window w); 142long getstate(Window w);
146static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); 143Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
147static void grabbuttons(Client *c, Bool focused); 144void grabbuttons(Client *c, Bool focused);
148static unsigned int idxoftag(const char *tag); 145unsigned int idxoftag(const char *tag);
149static void initfont(const char *fontstr); 146void initfont(const char *fontstr);
150static Bool isarrange(void (*func)()); 147Bool isarrange(void (*func)());
151static Bool isoccupied(unsigned int t); 148Bool isoccupied(unsigned int t);
152static Bool isprotodel(Client *c); 149Bool isprotodel(Client *c);
153static Bool isvisible(Client *c); 150Bool isvisible(Client *c);
154static void keypress(XEvent *e); 151void keypress(XEvent *e);
155static void killclient(const char *arg); 152void killclient(const char *arg);
156static void leavenotify(XEvent *e); 153void leavenotify(XEvent *e);
157static void manage(Window w, XWindowAttributes *wa); 154void manage(Window w, XWindowAttributes *wa);
158static void mappingnotify(XEvent *e); 155void mappingnotify(XEvent *e);
159static void maprequest(XEvent *e); 156void maprequest(XEvent *e);
160static void movemouse(Client *c); 157void movemouse(Client *c);
161static Client *nexttiled(Client *c); 158Client *nexttiled(Client *c);
162static void propertynotify(XEvent *e); 159void propertynotify(XEvent *e);
163static void quit(const char *arg); 160void quit(const char *arg);
164static void resize(Client *c, int x, int y, int w, int h, Bool sizehints); 161void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
165static void resizemouse(Client *c); 162void resizemouse(Client *c);
166static void restack(void); 163void restack(void);
167static void run(void); 164void run(void);
168static void scan(void); 165void scan(void);
169static void setclientstate(Client *c, long state); 166void setclientstate(Client *c, long state);
170static void setlayout(const char *arg); 167void setlayout(const char *arg);
171static void setmwfact(const char *arg); 168void setmwfact(const char *arg);
172static void setup(void); 169void setup(void);
173static void spawn(const char *arg); 170void spawn(const char *arg);
174static void tag(const char *arg); 171void tag(const char *arg);
175static unsigned int textnw(const char *text, unsigned int len); 172unsigned int textnw(const char *text, unsigned int len);
176static unsigned int textw(const char *text); 173unsigned int textw(const char *text);
177static void tile(void); 174void tile(void);
178static void togglebar(const char *arg); 175void togglebar(const char *arg);
179static void togglefloating(const char *arg); 176void togglefloating(const char *arg);
180static void togglemax(const char *arg); 177void togglemax(const char *arg);
181static void toggletag(const char *arg); 178void toggletag(const char *arg);
182static void toggleview(const char *arg); 179void toggleview(const char *arg);
183static void unban(Client *c); 180void unban(Client *c);
184static void unmanage(Client *c); 181void unmanage(Client *c);
185static void unmapnotify(XEvent *e); 182void unmapnotify(XEvent *e);
186static void updatebarpos(void); 183void updatebarpos(void);
187static void updatesizehints(Client *c); 184void updatesizehints(Client *c);
188static void updatetitle(Client *c); 185void updatetitle(Client *c);
189static void view(const char *arg); 186void view(const char *arg);
190static int xerror(Display *dpy, XErrorEvent *ee); 187int xerror(Display *dpy, XErrorEvent *ee);
191static int xerrordummy(Display *dsply, XErrorEvent *ee); 188int xerrordummy(Display *dsply, XErrorEvent *ee);
192static int xerrorstart(Display *dsply, XErrorEvent *ee); 189int xerrorstart(Display *dsply, XErrorEvent *ee);
193static void zoom(const char *arg); 190void zoom(const char *arg);
194 191
195/* variables */ 192/* variables */
196static char stext[256]; 193char stext[256];
197static double mwfact; 194double mwfact;
198static int screen, sx, sy, sw, sh, wax, way, waw, wah; 195int screen, sx, sy, sw, sh, wax, way, waw, wah;
199static int (*xerrorxlib)(Display *, XErrorEvent *); 196int (*xerrorxlib)(Display *, XErrorEvent *);
200static unsigned int bh, bpos, ntags; 197unsigned int bh, bpos, ntags;
201static unsigned int blw = 0; 198unsigned int blw = 0;
202static unsigned int ltidx = 0; /* default */ 199unsigned int ltidx = 0; /* default */
203static unsigned int nlayouts = 0; 200unsigned int nlayouts = 0;
204static unsigned int nrules = 0; 201unsigned int nrules = 0;
205static unsigned int numlockmask = 0; 202unsigned int numlockmask = 0;
206static void (*handler[LASTEvent]) (XEvent *) = { 203void (*handler[LASTEvent]) (XEvent *) = {
207 [ButtonPress] = buttonpress, 204 [ButtonPress] = buttonpress,
208 [ConfigureRequest] = configurerequest, 205 [ConfigureRequest] = configurerequest,
209 [ConfigureNotify] = configurenotify, 206 [ConfigureNotify] = configurenotify,
@@ -217,25 +214,25 @@ static void (*handler[LASTEvent]) (XEvent *) = {
217 [PropertyNotify] = propertynotify, 214 [PropertyNotify] = propertynotify,
218 [UnmapNotify] = unmapnotify 215 [UnmapNotify] = unmapnotify
219}; 216};
220static Atom wmatom[WMLast], netatom[NetLast]; 217Atom wmatom[WMLast], netatom[NetLast];
221static Bool otherwm, readin; 218Bool otherwm, readin;
222static Bool running = True; 219Bool running = True;
223static Bool *seltags; 220Bool *seltags;
224static Bool selscreen = True; 221Bool selscreen = True;
225static Client *clients = NULL; 222Client *clients = NULL;
226static Client *sel = NULL; 223Client *sel = NULL;
227static Client *stack = NULL; 224Client *stack = NULL;
228static Cursor cursor[CurLast]; 225Cursor cursor[CurLast];
229static Display *dpy; 226Display *dpy;
230static DC dc = {0}; 227DC dc = {0};
231static Window barwin, root; 228Window barwin, root;
232static Regs *regs = NULL; 229Regs *regs = NULL;
233 230
234/* configuration, allows nested code to access above variables */ 231/* configuration, allows nested code to access above variables */
235#include "config.h" 232#include "config.h"
236 233
237/* functions*/ 234/* functions*/
238static void 235void
239applyrules(Client *c) { 236applyrules(Client *c) {
240 static char buf[512]; 237 static char buf[512];
241 unsigned int i, j; 238 unsigned int i, j;
@@ -267,7 +264,7 @@ applyrules(Client *c) {
267 c->tags[i] = seltags[i]; 264 c->tags[i] = seltags[i];
268} 265}
269 266
270static void 267void
271arrange(void) { 268arrange(void) {
272 Client *c; 269 Client *c;
273 270
@@ -281,7 +278,7 @@ arrange(void) {
281 restack(); 278 restack();
282} 279}
283 280
284static void 281void
285attach(Client *c) { 282attach(Client *c) {
286 if(clients) 283 if(clients)
287 clients->prev = c; 284 clients->prev = c;
@@ -289,13 +286,13 @@ attach(Client *c) {
289 clients = c; 286 clients = c;
290} 287}
291 288
292static void 289void
293attachstack(Client *c) { 290attachstack(Client *c) {
294 c->snext = stack; 291 c->snext = stack;
295 stack = c; 292 stack = c;
296} 293}
297 294
298static void 295void
299ban(Client *c) { 296ban(Client *c) {
300 if(c->isbanned) 297 if(c->isbanned)
301 return; 298 return;
@@ -303,7 +300,7 @@ ban(Client *c) {
303 c->isbanned = True; 300 c->isbanned = True;
304} 301}
305 302
306static void 303void
307buttonpress(XEvent *e) { 304buttonpress(XEvent *e) {
308 unsigned int i, x; 305 unsigned int i, x;
309 Client *c; 306 Client *c;
@@ -359,7 +356,7 @@ buttonpress(XEvent *e) {
359 } 356 }
360} 357}
361 358
362static void 359void
363checkotherwm(void) { 360checkotherwm(void) {
364 otherwm = False; 361 otherwm = False;
365 XSetErrorHandler(xerrorstart); 362 XSetErrorHandler(xerrorstart);
@@ -375,7 +372,7 @@ checkotherwm(void) {
375 XSync(dpy, False); 372 XSync(dpy, False);
376} 373}
377 374
378static void 375void
379cleanup(void) { 376cleanup(void) {
380 close(STDIN_FILENO); 377 close(STDIN_FILENO);
381 while(stack) { 378 while(stack) {
@@ -398,7 +395,7 @@ cleanup(void) {
398 free(seltags); 395 free(seltags);
399} 396}
400 397
401static void 398void
402compileregs(void) { 399compileregs(void) {
403 unsigned int i; 400 unsigned int i;
404 regex_t *reg; 401 regex_t *reg;
@@ -425,7 +422,7 @@ compileregs(void) {
425 } 422 }
426} 423}
427 424
428static void 425void
429configure(Client *c) { 426configure(Client *c) {
430 XConfigureEvent ce; 427 XConfigureEvent ce;
431 428
@@ -443,7 +440,7 @@ configure(Client *c) {
443 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); 440 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
444} 441}
445 442
446static void 443void
447configurenotify(XEvent *e) { 444configurenotify(XEvent *e) {
448 XConfigureEvent *ev = &e->xconfigure; 445 XConfigureEvent *ev = &e->xconfigure;
449 446
@@ -458,7 +455,7 @@ configurenotify(XEvent *e) {
458 } 455 }
459} 456}
460 457
461static void 458void
462configurerequest(XEvent *e) { 459configurerequest(XEvent *e) {
463 Client *c; 460 Client *c;
464 XConfigureRequestEvent *ev = &e->xconfigurerequest; 461 XConfigureRequestEvent *ev = &e->xconfigurerequest;
@@ -503,7 +500,7 @@ configurerequest(XEvent *e) {
503 XSync(dpy, False); 500 XSync(dpy, False);
504} 501}
505 502
506static void 503void
507destroynotify(XEvent *e) { 504destroynotify(XEvent *e) {
508 Client *c; 505 Client *c;
509 XDestroyWindowEvent *ev = &e->xdestroywindow; 506 XDestroyWindowEvent *ev = &e->xdestroywindow;
@@ -512,7 +509,7 @@ destroynotify(XEvent *e) {
512 unmanage(c); 509 unmanage(c);
513} 510}
514 511
515static void 512void
516detach(Client *c) { 513detach(Client *c) {
517 if(c->prev) 514 if(c->prev)
518 c->prev->next = c->next; 515 c->prev->next = c->next;
@@ -523,7 +520,7 @@ detach(Client *c) {
523 c->next = c->prev = NULL; 520 c->next = c->prev = NULL;
524} 521}
525 522
526static void 523void
527detachstack(Client *c) { 524detachstack(Client *c) {
528 Client **tc; 525 Client **tc;
529 526
@@ -531,7 +528,7 @@ detachstack(Client *c) {
531 *tc = c->snext; 528 *tc = c->snext;
532} 529}
533 530
534static void 531void
535drawbar(void) { 532drawbar(void) {
536 int i, x; 533 int i, x;
537 534
@@ -571,7 +568,7 @@ drawbar(void) {
571 XSync(dpy, False); 568 XSync(dpy, False);
572} 569}
573 570
574static void 571void
575drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) { 572drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
576 int x; 573 int x;
577 XGCValues gcv; 574 XGCValues gcv;
@@ -592,7 +589,7 @@ drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
592 } 589 }
593} 590}
594 591
595static void 592void
596drawtext(const char *text, unsigned long col[ColLast]) { 593drawtext(const char *text, unsigned long col[ColLast]) {
597 int x, y, w, h; 594 int x, y, w, h;
598 static char buf[256]; 595 static char buf[256];
@@ -632,7 +629,7 @@ drawtext(const char *text, unsigned long col[ColLast]) {
632 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); 629 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
633} 630}
634 631
635static void * 632void *
636emallocz(unsigned int size) { 633emallocz(unsigned int size) {
637 void *res = calloc(1, size); 634 void *res = calloc(1, size);
638 635
@@ -641,7 +638,7 @@ emallocz(unsigned int size) {
641 return res; 638 return res;
642} 639}
643 640
644static void 641void
645enternotify(XEvent *e) { 642enternotify(XEvent *e) {
646 Client *c; 643 Client *c;
647 XCrossingEvent *ev = &e->xcrossing; 644 XCrossingEvent *ev = &e->xcrossing;
@@ -656,7 +653,7 @@ enternotify(XEvent *e) {
656 } 653 }
657} 654}
658 655
659static void 656void
660eprint(const char *errstr, ...) { 657eprint(const char *errstr, ...) {
661 va_list ap; 658 va_list ap;
662 659
@@ -666,7 +663,7 @@ eprint(const char *errstr, ...) {
666 exit(EXIT_FAILURE); 663 exit(EXIT_FAILURE);
667} 664}
668 665
669static void 666void
670expose(XEvent *e) { 667expose(XEvent *e) {
671 XExposeEvent *ev = &e->xexpose; 668 XExposeEvent *ev = &e->xexpose;
672 669
@@ -676,7 +673,7 @@ expose(XEvent *e) {
676 } 673 }
677} 674}
678 675
679static void 676void
680floating(void) { /* default floating layout */ 677floating(void) { /* default floating layout */
681 Client *c; 678 Client *c;
682 679
@@ -685,7 +682,7 @@ floating(void) { /* default floating layout */
685 resize(c, c->x, c->y, c->w, c->h, True); 682 resize(c, c->x, c->y, c->w, c->h, True);
686} 683}
687 684
688static void 685void
689focus(Client *c) { 686focus(Client *c) {
690 if((!c && selscreen) || (c && !isvisible(c))) 687 if((!c && selscreen) || (c && !isvisible(c)))
691 for(c = stack; c && !isvisible(c); c = c->snext); 688 for(c = stack; c && !isvisible(c); c = c->snext);
@@ -710,7 +707,7 @@ focus(Client *c) {
710 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 707 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
711} 708}
712 709
713static void 710void
714focusnext(const char *arg) { 711focusnext(const char *arg) {
715 Client *c; 712 Client *c;
716 713
@@ -725,7 +722,7 @@ focusnext(const char *arg) {
725 } 722 }
726} 723}
727 724
728static void 725void
729focusprev(const char *arg) { 726focusprev(const char *arg) {
730 Client *c; 727 Client *c;
731 728
@@ -742,7 +739,7 @@ focusprev(const char *arg) {
742 } 739 }
743} 740}
744 741
745static Client * 742Client *
746getclient(Window w) { 743getclient(Window w) {
747 Client *c; 744 Client *c;
748 745
@@ -750,7 +747,7 @@ getclient(Window w) {
750 return c; 747 return c;
751} 748}
752 749
753static unsigned long 750unsigned long
754getcolor(const char *colstr) { 751getcolor(const char *colstr) {
755 Colormap cmap = DefaultColormap(dpy, screen); 752 Colormap cmap = DefaultColormap(dpy, screen);
756 XColor color; 753 XColor color;
@@ -760,7 +757,7 @@ getcolor(const char *colstr) {
760 return color.pixel; 757 return color.pixel;
761} 758}
762 759
763static long 760long
764getstate(Window w) { 761getstate(Window w) {
765 int format, status; 762 int format, status;
766 long result = -1; 763 long result = -1;
@@ -778,7 +775,7 @@ getstate(Window w) {
778 return result; 775 return result;
779} 776}
780 777
781static Bool 778Bool
782gettextprop(Window w, Atom atom, char *text, unsigned int size) { 779gettextprop(Window w, Atom atom, char *text, unsigned int size) {
783 char **list = NULL; 780 char **list = NULL;
784 int n; 781 int n;
@@ -805,7 +802,7 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
805 return True; 802 return True;
806} 803}
807 804
808static void 805void
809grabbuttons(Client *c, Bool focused) { 806grabbuttons(Client *c, Bool focused) {
810 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 807 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
811 808
@@ -842,7 +839,7 @@ grabbuttons(Client *c, Bool focused) {
842 GrabModeAsync, GrabModeSync, None, None); 839 GrabModeAsync, GrabModeSync, None, None);
843} 840}
844 841
845static unsigned int 842unsigned int
846idxoftag(const char *tag) { 843idxoftag(const char *tag) {
847 unsigned int i; 844 unsigned int i;
848 845
@@ -852,7 +849,7 @@ idxoftag(const char *tag) {
852 return 0; 849 return 0;
853} 850}
854 851
855static void 852void
856initfont(const char *fontstr) { 853initfont(const char *fontstr) {
857 char *def, **missing; 854 char *def, **missing;
858 int i, n; 855 int i, n;
@@ -894,13 +891,13 @@ initfont(const char *fontstr) {
894 dc.font.height = dc.font.ascent + dc.font.descent; 891 dc.font.height = dc.font.ascent + dc.font.descent;
895} 892}
896 893
897static Bool 894Bool
898isarrange(void (*func)()) 895isarrange(void (*func)())
899{ 896{
900 return func == layouts[ltidx].arrange; 897 return func == layouts[ltidx].arrange;
901} 898}
902 899
903static Bool 900Bool
904isoccupied(unsigned int t) { 901isoccupied(unsigned int t) {
905 Client *c; 902 Client *c;
906 903
@@ -910,7 +907,7 @@ isoccupied(unsigned int t) {
910 return False; 907 return False;
911} 908}
912 909
913static Bool 910Bool
914isprotodel(Client *c) { 911isprotodel(Client *c) {
915 int i, n; 912 int i, n;
916 Atom *protocols; 913 Atom *protocols;
@@ -925,7 +922,7 @@ isprotodel(Client *c) {
925 return ret; 922 return ret;
926} 923}
927 924
928static Bool 925Bool
929isvisible(Client *c) { 926isvisible(Client *c) {
930 unsigned int i; 927 unsigned int i;
931 928
@@ -935,7 +932,7 @@ isvisible(Client *c) {
935 return False; 932 return False;
936} 933}
937 934
938static void 935void
939keypress(XEvent *e) { 936keypress(XEvent *e) {
940 KEYS 937 KEYS
941 unsigned int len = sizeof keys / sizeof keys[0]; 938 unsigned int len = sizeof keys / sizeof keys[0];
@@ -970,7 +967,7 @@ keypress(XEvent *e) {
970 } 967 }
971} 968}
972 969
973static void 970void
974killclient(const char *arg) { 971killclient(const char *arg) {
975 XEvent ev; 972 XEvent ev;
976 973
@@ -989,7 +986,7 @@ killclient(const char *arg) {
989 XKillClient(dpy, sel->win); 986 XKillClient(dpy, sel->win);
990} 987}
991 988
992static void 989void
993leavenotify(XEvent *e) { 990leavenotify(XEvent *e) {
994 XCrossingEvent *ev = &e->xcrossing; 991 XCrossingEvent *ev = &e->xcrossing;
995 992
@@ -999,7 +996,7 @@ leavenotify(XEvent *e) {
999 } 996 }
1000} 997}
1001 998
1002static void 999void
1003manage(Window w, XWindowAttributes *wa) { 1000manage(Window w, XWindowAttributes *wa) {
1004 unsigned int i; 1001 unsigned int i;
1005 Client *c, *t = NULL; 1002 Client *c, *t = NULL;
@@ -1057,7 +1054,7 @@ manage(Window w, XWindowAttributes *wa) {
1057 arrange(); 1054 arrange();
1058} 1055}
1059 1056
1060static void 1057void
1061mappingnotify(XEvent *e) { 1058mappingnotify(XEvent *e) {
1062 XMappingEvent *ev = &e->xmapping; 1059 XMappingEvent *ev = &e->xmapping;
1063 1060
@@ -1066,7 +1063,7 @@ mappingnotify(XEvent *e) {
1066 keypress(NULL); 1063 keypress(NULL);
1067} 1064}
1068 1065
1069static void 1066void
1070maprequest(XEvent *e) { 1067maprequest(XEvent *e) {
1071 static XWindowAttributes wa; 1068 static XWindowAttributes wa;
1072 XMapRequestEvent *ev = &e->xmaprequest; 1069 XMapRequestEvent *ev = &e->xmaprequest;
@@ -1079,7 +1076,7 @@ maprequest(XEvent *e) {
1079 manage(ev->window, &wa); 1076 manage(ev->window, &wa);
1080} 1077}
1081 1078
1082static void 1079void
1083movemouse(Client *c) { 1080movemouse(Client *c) {
1084 int x1, y1, ocx, ocy, di, nx, ny; 1081 int x1, y1, ocx, ocy, di, nx, ny;
1085 unsigned int dui; 1082 unsigned int dui;
@@ -1122,13 +1119,13 @@ movemouse(Client *c) {
1122 } 1119 }
1123} 1120}
1124 1121
1125static Client * 1122Client *
1126nexttiled(Client *c) { 1123nexttiled(Client *c) {
1127 for(; c && (c->isfloating || !isvisible(c)); c = c->next); 1124 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
1128 return c; 1125 return c;
1129} 1126}
1130 1127
1131static void 1128void
1132propertynotify(XEvent *e) { 1129propertynotify(XEvent *e) {
1133 Client *c; 1130 Client *c;
1134 Window trans; 1131 Window trans;
@@ -1156,12 +1153,12 @@ propertynotify(XEvent *e) {
1156 } 1153 }
1157} 1154}
1158 1155
1159static void 1156void
1160quit(const char *arg) { 1157quit(const char *arg) {
1161 readin = running = False; 1158 readin = running = False;
1162} 1159}
1163 1160
1164static void 1161void
1165resize(Client *c, int x, int y, int w, int h, Bool sizehints) { 1162resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
1166 double dx, dy, max, min, ratio; 1163 double dx, dy, max, min, ratio;
1167 XWindowChanges wc; 1164 XWindowChanges wc;
@@ -1224,7 +1221,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
1224 } 1221 }
1225} 1222}
1226 1223
1227static void 1224void
1228resizemouse(Client *c) { 1225resizemouse(Client *c) {
1229 int ocx, ocy; 1226 int ocx, ocy;
1230 int nw, nh; 1227 int nw, nh;
@@ -1263,7 +1260,7 @@ resizemouse(Client *c) {
1263 } 1260 }
1264} 1261}
1265 1262
1266static void 1263void
1267restack(void) { 1264restack(void) {
1268 Client *c; 1265 Client *c;
1269 XEvent ev; 1266 XEvent ev;
@@ -1292,7 +1289,7 @@ restack(void) {
1292 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1289 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
1293} 1290}
1294 1291
1295static void 1292void
1296run(void) { 1293run(void) {
1297 char *p; 1294 char *p;
1298 int r, xfd; 1295 int r, xfd;
@@ -1340,7 +1337,7 @@ run(void) {
1340 } 1337 }
1341} 1338}
1342 1339
1343static void 1340void
1344scan(void) { 1341scan(void) {
1345 unsigned int i, num; 1342 unsigned int i, num;
1346 Window *wins, d1, d2; 1343 Window *wins, d1, d2;
@@ -1367,7 +1364,7 @@ scan(void) {
1367 XFree(wins); 1364 XFree(wins);
1368} 1365}
1369 1366
1370static void 1367void
1371setclientstate(Client *c, long state) { 1368setclientstate(Client *c, long state) {
1372 long data[] = {state, None}; 1369 long data[] = {state, None};
1373 1370
@@ -1375,7 +1372,7 @@ setclientstate(Client *c, long state) {
1375 PropModeReplace, (unsigned char *)data, 2); 1372 PropModeReplace, (unsigned char *)data, 2);
1376} 1373}
1377 1374
1378static void 1375void
1379setlayout(const char *arg) { 1376setlayout(const char *arg) {
1380 unsigned int i; 1377 unsigned int i;
1381 1378
@@ -1397,7 +1394,7 @@ setlayout(const char *arg) {
1397 drawbar(); 1394 drawbar();
1398} 1395}
1399 1396
1400static void 1397void
1401setmwfact(const char *arg) { 1398setmwfact(const char *arg) {
1402 double delta; 1399 double delta;
1403 1400
@@ -1419,7 +1416,7 @@ setmwfact(const char *arg) {
1419 arrange(); 1416 arrange();
1420} 1417}
1421 1418
1422static void 1419void
1423setup(void) { 1420setup(void) {
1424 unsigned int i, j, mask; 1421 unsigned int i, j, mask;
1425 Window w; 1422 Window w;
@@ -1513,7 +1510,7 @@ setup(void) {
1513 selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); 1510 selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
1514} 1511}
1515 1512
1516static void 1513void
1517spawn(const char *arg) { 1514spawn(const char *arg) {
1518 static char *shell = NULL; 1515 static char *shell = NULL;
1519 1516
@@ -1537,7 +1534,7 @@ spawn(const char *arg) {
1537 wait(0); 1534 wait(0);
1538} 1535}
1539 1536
1540static void 1537void
1541tag(const char *arg) { 1538tag(const char *arg) {
1542 unsigned int i; 1539 unsigned int i;
1543 1540
@@ -1551,7 +1548,7 @@ tag(const char *arg) {
1551 arrange(); 1548 arrange();
1552} 1549}
1553 1550
1554static unsigned int 1551unsigned int
1555textnw(const char *text, unsigned int len) { 1552textnw(const char *text, unsigned int len) {
1556 XRectangle r; 1553 XRectangle r;
1557 1554
@@ -1562,12 +1559,12 @@ textnw(const char *text, unsigned int len) {
1562 return XTextWidth(dc.font.xfont, text, len); 1559 return XTextWidth(dc.font.xfont, text, len);
1563} 1560}
1564 1561
1565static unsigned int 1562unsigned int
1566textw(const char *text) { 1563textw(const char *text) {
1567 return textnw(text, strlen(text)) + dc.font.height; 1564 return textnw(text, strlen(text)) + dc.font.height;
1568} 1565}
1569 1566
1570static void 1567void
1571tile(void) { 1568tile(void) {
1572 unsigned int i, n, nx, ny, nw, nh, mw, th; 1569 unsigned int i, n, nx, ny, nw, nh, mw, th;
1573 Client *c; 1570 Client *c;
@@ -1606,7 +1603,7 @@ tile(void) {
1606 } 1603 }
1607} 1604}
1608 1605
1609static void 1606void
1610togglebar(const char *arg) { 1607togglebar(const char *arg) {
1611 if(bpos == BarOff) 1608 if(bpos == BarOff)
1612 bpos = (BARPOS == BarOff) ? BarTop : BARPOS; 1609 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
@@ -1616,7 +1613,7 @@ togglebar(const char *arg) {
1616 arrange(); 1613 arrange();
1617} 1614}
1618 1615
1619static void 1616void
1620togglefloating(const char *arg) { 1617togglefloating(const char *arg) {
1621 if(!sel) 1618 if(!sel)
1622 return; 1619 return;
@@ -1626,7 +1623,7 @@ togglefloating(const char *arg) {
1626 arrange(); 1623 arrange();
1627} 1624}
1628 1625
1629static void 1626void
1630togglemax(const char *arg) { 1627togglemax(const char *arg) {
1631 XEvent ev; 1628 XEvent ev;
1632 1629
@@ -1645,7 +1642,7 @@ togglemax(const char *arg) {
1645 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1642 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
1646} 1643}
1647 1644
1648static void 1645void
1649toggletag(const char *arg) { 1646toggletag(const char *arg) {
1650 unsigned int i, j; 1647 unsigned int i, j;
1651 1648
@@ -1659,7 +1656,7 @@ toggletag(const char *arg) {
1659 arrange(); 1656 arrange();
1660} 1657}
1661 1658
1662static void 1659void
1663toggleview(const char *arg) { 1660toggleview(const char *arg) {
1664 unsigned int i, j; 1661 unsigned int i, j;
1665 1662
@@ -1671,7 +1668,7 @@ toggleview(const char *arg) {
1671 arrange(); 1668 arrange();
1672} 1669}
1673 1670
1674static void 1671void
1675unban(Client *c) { 1672unban(Client *c) {
1676 if(!c->isbanned) 1673 if(!c->isbanned)
1677 return; 1674 return;
@@ -1679,7 +1676,7 @@ unban(Client *c) {
1679 c->isbanned = False; 1676 c->isbanned = False;
1680} 1677}
1681 1678
1682static void 1679void
1683unmanage(Client *c) { 1680unmanage(Client *c) {
1684 XWindowChanges wc; 1681 XWindowChanges wc;
1685 1682
@@ -1702,7 +1699,7 @@ unmanage(Client *c) {
1702 arrange(); 1699 arrange();
1703} 1700}
1704 1701
1705static void 1702void
1706unmapnotify(XEvent *e) { 1703unmapnotify(XEvent *e) {
1707 Client *c; 1704 Client *c;
1708 XUnmapEvent *ev = &e->xunmap; 1705 XUnmapEvent *ev = &e->xunmap;
@@ -1711,7 +1708,7 @@ unmapnotify(XEvent *e) {
1711 unmanage(c); 1708 unmanage(c);
1712} 1709}
1713 1710
1714static void 1711void
1715updatebarpos(void) { 1712updatebarpos(void) {
1716 XEvent ev; 1713 XEvent ev;
1717 1714
@@ -1737,7 +1734,7 @@ updatebarpos(void) {
1737 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1734 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
1738} 1735}
1739 1736
1740static void 1737void
1741updatesizehints(Client *c) { 1738updatesizehints(Client *c) {
1742 long msize; 1739 long msize;
1743 XSizeHints size; 1740 XSizeHints size;
@@ -1789,7 +1786,7 @@ updatesizehints(Client *c) {
1789 && c->maxw == c->minw && c->maxh == c->minh); 1786 && c->maxw == c->minw && c->maxh == c->minh);
1790} 1787}
1791 1788
1792static void 1789void
1793updatetitle(Client *c) { 1790updatetitle(Client *c) {
1794 if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) 1791 if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
1795 gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name); 1792 gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
@@ -1798,7 +1795,7 @@ updatetitle(Client *c) {
1798/* There's no way to check accesses to destroyed windows, thus those cases are 1795/* There's no way to check accesses to destroyed windows, thus those cases are
1799 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs 1796 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
1800 * default error handler, which may call exit. */ 1797 * default error handler, which may call exit. */
1801static int 1798int
1802xerror(Display *dpy, XErrorEvent *ee) { 1799xerror(Display *dpy, XErrorEvent *ee) {
1803 if(ee->error_code == BadWindow 1800 if(ee->error_code == BadWindow
1804 || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) 1801 || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
@@ -1814,20 +1811,20 @@ xerror(Display *dpy, XErrorEvent *ee) {
1814 return xerrorxlib(dpy, ee); /* may call exit */ 1811 return xerrorxlib(dpy, ee); /* may call exit */
1815} 1812}
1816 1813
1817static int 1814int
1818xerrordummy(Display *dsply, XErrorEvent *ee) { 1815xerrordummy(Display *dsply, XErrorEvent *ee) {
1819 return 0; 1816 return 0;
1820} 1817}
1821 1818
1822/* Startup Error handler to check if another window manager 1819/* Startup Error handler to check if another window manager
1823 * is already running. */ 1820 * is already running. */
1824static int 1821int
1825xerrorstart(Display *dsply, XErrorEvent *ee) { 1822xerrorstart(Display *dsply, XErrorEvent *ee) {
1826 otherwm = True; 1823 otherwm = True;
1827 return -1; 1824 return -1;
1828} 1825}
1829 1826
1830static void 1827void
1831view(const char *arg) { 1828view(const char *arg) {
1832 unsigned int i; 1829 unsigned int i;
1833 1830
@@ -1839,7 +1836,7 @@ view(const char *arg) {
1839 arrange(); 1836 arrange();
1840} 1837}
1841 1838
1842static void 1839void
1843zoom(const char *arg) { 1840zoom(const char *arg) {
1844 Client *c; 1841 Client *c;
1845 1842