summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-06-11 09:12:06 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-06-11 09:12:06 +0100
commita8e0772c4d977fafb35c5ab9e29e322a9505b71a (patch)
tree5068a0b2244a88dbd58a2261feff7f757a5d441f
parentfinal version -- Gottox verified it using the test driver (diff)
downloaddwm-a8e0772c4d977fafb35c5ab9e29e322a9505b71a.tar.gz
dwm-a8e0772c4d977fafb35c5ab9e29e322a9505b71a.zip
applied anydot's patchset.diff
-rw-r--r--config.def.h70
-rw-r--r--config.mk4
-rw-r--r--dwm.c343
3 files changed, 206 insertions, 211 deletions
diff --git a/config.def.h b/config.def.h
index 83a8c18..af8f70f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -8,25 +8,25 @@
8#define SELBORDERCOLOR "#0066ff" 8#define SELBORDERCOLOR "#0066ff"
9#define SELBGCOLOR "#0066ff" 9#define SELBGCOLOR "#0066ff"
10#define SELFGCOLOR "#ffffff" 10#define SELFGCOLOR "#ffffff"
11unsigned int borderpx = 1; /* border pixel of windows */ 11static uint borderpx = 1; /* border pixel of windows */
12unsigned int snap = 32; /* snap pixel */ 12static uint snap = 32; /* snap pixel */
13Bool showbar = True; /* False means no bar */ 13static Bool showbar = True; /* False means no bar */
14Bool topbar = True; /* False means bottom bar */ 14static Bool topbar = True; /* False means bottom bar */
15 15
16/* tagging */ 16/* tagging */
17const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 17static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
18 18
19Rule rules[] = { 19static Rule rules[] = {
20 /* class instance title tags ref isfloating */ 20 /* class instance title tags ref isfloating */
21 { "Gimp", NULL, NULL, 0, True }, 21 { "Gimp", NULL, NULL, 0, True },
22 { "Firefox", NULL, NULL, 1 << 8, True }, 22 { "Firefox", NULL, NULL, 1 << 8, True },
23}; 23};
24 24
25/* layout(s) */ 25/* layout(s) */
26double mfact = 0.55; 26static float mfact = 0.55;
27Bool resizehints = False; /* False means respect size hints in tiled resizals */ 27static Bool resizehints = False; /* False means respect size hints in tiled resizals */
28 28
29Layout layouts[] = { 29static Layout layouts[] = {
30 /* symbol arrange function */ 30 /* symbol arrange function */
31 { "[]=", tile }, /* first entry is default */ 31 { "[]=", tile }, /* first entry is default */
32 { "><>", NULL }, /* no layout function means floating behavior */ 32 { "><>", NULL }, /* no layout function means floating behavior */
@@ -40,31 +40,31 @@ Layout layouts[] = {
40 { MODKEY|ShiftMask, KEY, tag, TAG }, \ 40 { MODKEY|ShiftMask, KEY, tag, TAG }, \
41 { MODKEY|ControlMask|ShiftMask, KEY, toggletag, TAG }, 41 { MODKEY|ControlMask|ShiftMask, KEY, toggletag, TAG },
42 42
43Key keys[] = { 43static Key keys[] = {
44 /* modifier key function argument */ 44 /* modifier key function argument */
45 { MODKEY, XK_p, spawn, (char *)"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" }, 45 { MODKEY, XK_p, spawn, {.c = "exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" }},
46 { MODKEY|ShiftMask, XK_Return, spawn, (char *)"exec uxterm" }, 46 { MODKEY|ShiftMask, XK_Return, spawn, {.c = "exec uxterm" }},
47 { MODKEY, XK_b, togglebar, NULL }, 47 { MODKEY, XK_b, togglebar, {0}},
48 { MODKEY, XK_j, focusnext, NULL }, 48 { MODKEY, XK_j, focusstack, {.i = +1 }},
49 { MODKEY, XK_k, focusprev, NULL }, 49 { MODKEY, XK_k, focusstack, {.i = -1 }},
50 { MODKEY, XK_h, setmfact, (double[]){-0.05} }, 50 { MODKEY, XK_h, setmfact, {.f = -0.05}},
51 { MODKEY, XK_l, setmfact, (double[]){+0.05} }, 51 { MODKEY, XK_l, setmfact, {.f = +0.05}},
52 { MODKEY, XK_m, togglemax, NULL }, 52 { MODKEY, XK_m, togglemax, {0}},
53 { MODKEY, XK_Return, zoom, NULL }, 53 { MODKEY, XK_Return, zoom, {0}},
54 { MODKEY, XK_Tab, view, NULL }, 54 { MODKEY, XK_Tab, view, {0}},
55 { MODKEY|ShiftMask, XK_c, killclient, NULL }, 55 { MODKEY|ShiftMask, XK_c, killclient, {0}},
56 { MODKEY, XK_space, togglelayout, NULL }, 56 { MODKEY, XK_space, togglelayout, {0}},
57 { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, 57 { MODKEY|ShiftMask, XK_space, togglefloating, {0}},
58 { MODKEY, XK_0, view, (uint[]){ ~0 } }, 58 { MODKEY, XK_0, view, {.ui = ~0 } },
59 { MODKEY|ShiftMask, XK_0, tag, (uint[]){ ~0 } }, 59 { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
60 TAGKEYS( XK_1, (uint[]){ 1 << 0} ) 60 TAGKEYS( XK_1, {.ui = 1 << 0} )
61 TAGKEYS( XK_2, (uint[]){ 1 << 1} ) 61 TAGKEYS( XK_2, {.ui = 1 << 1} )
62 TAGKEYS( XK_3, (uint[]){ 1 << 2} ) 62 TAGKEYS( XK_3, {.ui = 1 << 2} )
63 TAGKEYS( XK_4, (uint[]){ 1 << 3} ) 63 TAGKEYS( XK_4, {.ui = 1 << 3} )
64 TAGKEYS( XK_5, (uint[]){ 1 << 4} ) 64 TAGKEYS( XK_5, {.ui = 1 << 4} )
65 TAGKEYS( XK_6, (uint[]){ 1 << 5} ) 65 TAGKEYS( XK_6, {.ui = 1 << 5} )
66 TAGKEYS( XK_7, (uint[]){ 1 << 6} ) 66 TAGKEYS( XK_7, {.ui = 1 << 6} )
67 TAGKEYS( XK_8, (uint[]){ 1 << 7} ) 67 TAGKEYS( XK_8, {.ui = 1 << 7} )
68 TAGKEYS( XK_9, (uint[]){ 1 << 8} ) 68 TAGKEYS( XK_9, {.ui = 1 << 8} )
69 { MODKEY|ShiftMask, XK_q, quit, NULL }, 69 { MODKEY|ShiftMask, XK_q, quit, {0}},
70}; 70};
diff --git a/config.mk b/config.mk
index ede70af..f9fb298 100644
--- a/config.mk
+++ b/config.mk
@@ -22,8 +22,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
22CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} 22CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
23#CFLAGS = -Os ${INCS} ${CPPFLAGS} 23#CFLAGS = -Os ${INCS} ${CPPFLAGS}
24#LDFLAGS = -s ${LIBS} 24#LDFLAGS = -s ${LIBS}
25CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} ${CPPFLAGS} 25CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
26LDFLAGS = -g ${LIBS} 26LDFLAGS = -s ${LIBS}
27 27
28# Solaris 28# Solaris
29#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" 29#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
diff --git a/dwm.c b/dwm.c
index 92b1ff2..5b8747c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -68,12 +68,11 @@ struct Client {
68 char name[256]; 68 char name[256];
69 int x, y, w, h; 69 int x, y, w, h;
70 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 70 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
71 int minax, maxax, minay, maxay; 71 float mina, maxa;
72 int bw, oldbw; 72 int bw, oldbw;
73 Bool isbanned, isfixed, isfloating, ismoved, isurgent; 73 Bool isbanned, isfixed, isfloating, ismoved, isurgent;
74 uint tags; 74 uint tags;
75 Client *next; 75 Client *next;
76 Client *prev;
77 Client *snext; 76 Client *snext;
78 Window win; 77 Window win;
79}; 78};
@@ -93,11 +92,19 @@ typedef struct {
93 } font; 92 } font;
94} DC; /* draw context */ 93} DC; /* draw context */
95 94
95typedef union {
96 const char *c;
97 int i;
98 uint ui;
99 float f;
100 void *aux;
101} Arg;
102
96typedef struct { 103typedef struct {
97 uint mod; 104 uint mod;
98 KeySym keysym; 105 KeySym keysym;
99 void (*func)(const void *arg); 106 void (*func)(const Arg *);
100 const void *arg; 107 const Arg arg;
101} Key; 108} Key;
102 109
103typedef struct { 110typedef struct {
@@ -114,87 +121,86 @@ typedef struct {
114} Rule; 121} Rule;
115 122
116/* function declarations */ 123/* function declarations */
117void applyrules(Client *c); 124static void applyrules(Client *c);
118void arrange(void); 125static void arrange(void);
119void attach(Client *c); 126static void attach(Client *c);
120void attachstack(Client *c); 127static void attachstack(Client *c);
121void buttonpress(XEvent *e); 128static void buttonpress(XEvent *e);
122void checkotherwm(void); 129static void checkotherwm(void);
123void cleanup(void); 130static void cleanup(void);
124void configure(Client *c); 131static void configure(Client *c);
125void configurenotify(XEvent *e); 132static void configurenotify(XEvent *e);
126void configurerequest(XEvent *e); 133static void configurerequest(XEvent *e);
127void destroynotify(XEvent *e); 134static void destroynotify(XEvent *e);
128void detach(Client *c); 135static void detach(Client *c);
129void detachstack(Client *c); 136static void detachstack(Client *c);
130void drawbar(void); 137static void drawbar(void);
131void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]); 138static void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]);
132void drawtext(const char *text, ulong col[ColLast], Bool invert); 139static void drawtext(const char *text, ulong col[ColLast], Bool invert);
133void enternotify(XEvent *e); 140static void enternotify(XEvent *e);
134void eprint(const char *errstr, ...); 141static void eprint(const char *errstr, ...);
135void expose(XEvent *e); 142static void expose(XEvent *e);
136void focus(Client *c); 143static void focus(Client *c);
137void focusin(XEvent *e); 144static void focusin(XEvent *e);
138void focusnext(const void *arg); 145static void focusstack(const Arg *arg);
139void focusprev(const void *arg); 146static Client *getclient(Window w);
140Client *getclient(Window w); 147static ulong getcolor(const char *colstr);
141ulong getcolor(const char *colstr); 148static long getstate(Window w);
142long getstate(Window w); 149static Bool gettextprop(Window w, Atom atom, char *text, uint size);
143Bool gettextprop(Window w, Atom atom, char *text, uint size); 150static void grabbuttons(Client *c, Bool focused);
144void grabbuttons(Client *c, Bool focused); 151static void grabkeys(void);
145void grabkeys(void); 152static void initfont(const char *fontstr);
146void initfont(const char *fontstr); 153static Bool isoccupied(uint t);
147Bool isoccupied(uint t); 154static Bool isprotodel(Client *c);
148Bool isprotodel(Client *c); 155static Bool isurgent(uint t);
149Bool isurgent(uint t); 156static void keypress(XEvent *e);
150void keypress(XEvent *e); 157static void killclient(const Arg *arg);
151void killclient(const void *arg); 158static void manage(Window w, XWindowAttributes *wa);
152void manage(Window w, XWindowAttributes *wa); 159static void mappingnotify(XEvent *e);
153void mappingnotify(XEvent *e); 160static void maprequest(XEvent *e);
154void maprequest(XEvent *e); 161static void movemouse(Client *c);
155void movemouse(Client *c); 162static Client *nexttiled(Client *c);
156Client *nexttiled(Client *c); 163static void propertynotify(XEvent *e);
157void propertynotify(XEvent *e); 164static void quit(const Arg *arg);
158void quit(const void *arg); 165static void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
159void resize(Client *c, int x, int y, int w, int h, Bool sizehints); 166static void resizemouse(Client *c);
160void resizemouse(Client *c); 167static void restack(void);
161void restack(void); 168static void run(void);
162void run(void); 169static void scan(void);
163void scan(void); 170static void setclientstate(Client *c, long state);
164void setclientstate(Client *c, long state); 171static void setmfact(const Arg *arg);
165void setmfact(const void *arg); 172static void setup(void);
166void setup(void); 173static void spawn(const Arg *arg);
167void spawn(const void *arg); 174static void tag(const Arg *arg);
168void tag(const void *arg); 175static int textnw(const char *text, uint len);
169int textnw(const char *text, uint len); 176static void tile(void);
170void tile(void); 177static void togglebar(const Arg *arg);
171void togglebar(const void *arg); 178static void togglefloating(const Arg *arg);
172void togglefloating(const void *arg); 179static void togglelayout(const Arg *arg);
173void togglelayout(const void *arg); 180static void togglemax(const Arg *arg);
174void togglemax(const void *arg); 181static void toggletag(const Arg *arg);
175void toggletag(const void *arg); 182static void toggleview(const Arg *arg);
176void toggleview(const void *arg); 183static void unmanage(Client *c);
177void unmanage(Client *c); 184static void unmapnotify(XEvent *e);
178void unmapnotify(XEvent *e); 185static void updatebar(void);
179void updatebar(void); 186static void updategeom(void);
180void updategeom(void); 187static void updatesizehints(Client *c);
181void updatesizehints(Client *c); 188static void updatetitle(Client *c);
182void updatetitle(Client *c); 189static void updatewmhints(Client *c);
183void updatewmhints(Client *c); 190static void view(const Arg *arg);
184void view(const void *arg); 191static int xerror(Display *dpy, XErrorEvent *ee);
185int xerror(Display *dpy, XErrorEvent *ee); 192static int xerrordummy(Display *dpy, XErrorEvent *ee);
186int xerrordummy(Display *dpy, XErrorEvent *ee); 193static int xerrorstart(Display *dpy, XErrorEvent *ee);
187int xerrorstart(Display *dpy, XErrorEvent *ee); 194static void zoom(const Arg *arg);
188void zoom(const void *arg);
189 195
190/* variables */ 196/* variables */
191char stext[256]; 197static char stext[256];
192int screen, sx, sy, sw, sh; 198static int screen, sx, sy, sw, sh;
193int by, bh, blw, wx, wy, ww, wh; 199static int by, bh, blw, wx, wy, ww, wh;
194uint seltags = 0; 200static uint seltags = 0;
195int (*xerrorxlib)(Display *, XErrorEvent *); 201static int (*xerrorxlib)(Display *, XErrorEvent *);
196uint numlockmask = 0; 202static uint numlockmask = 0;
197void (*handler[LASTEvent]) (XEvent *) = { 203static void (*handler[LASTEvent]) (XEvent *) = {
198 [ButtonPress] = buttonpress, 204 [ButtonPress] = buttonpress,
199 [ConfigureRequest] = configurerequest, 205 [ConfigureRequest] = configurerequest,
200 [ConfigureNotify] = configurenotify, 206 [ConfigureNotify] = configurenotify,
@@ -208,24 +214,24 @@ void (*handler[LASTEvent]) (XEvent *) = {
208 [PropertyNotify] = propertynotify, 214 [PropertyNotify] = propertynotify,
209 [UnmapNotify] = unmapnotify 215 [UnmapNotify] = unmapnotify
210}; 216};
211Atom wmatom[WMLast], netatom[NetLast]; 217static Atom wmatom[WMLast], netatom[NetLast];
212Bool ismax = False; 218static Bool ismax = False;
213Bool otherwm, readin; 219static Bool otherwm, readin;
214Bool running = True; 220static Bool running = True;
215uint tagset[] = {1, 1}; /* after start, first tag is selected */ 221static uint tagset[] = {1, 1}; /* after start, first tag is selected */
216Client *clients = NULL; 222static Client *clients = NULL;
217Client *sel = NULL; 223static Client *sel = NULL;
218Client *stack = NULL; 224static Client *stack = NULL;
219Cursor cursor[CurLast]; 225static Cursor cursor[CurLast];
220Display *dpy; 226static Display *dpy;
221DC dc = {0}; 227static DC dc = {0};
222Layout layouts[]; 228static Window root, barwin;
223Layout *lt = layouts;
224Window root, barwin;
225 229
226/* configuration, allows nested code to access above variables */ 230/* configuration, allows nested code to access above variables */
227#include "config.h" 231#include "config.h"
228 232
233static Layout *lt = layouts;
234
229/* compile-time check if all tags fit into an uint bit array. */ 235/* compile-time check if all tags fit into an uint bit array. */
230struct NumTags { char limitexceeded[sizeof(uint) * 8 < LENGTH(tags) ? -1 : 1]; }; 236struct NumTags { char limitexceeded[sizeof(uint) * 8 < LENGTH(tags) ? -1 : 1]; };
231 237
@@ -282,8 +288,6 @@ arrange(void) {
282 288
283void 289void
284attach(Client *c) { 290attach(Client *c) {
285 if(clients)
286 clients->prev = c;
287 c->next = clients; 291 c->next = clients;
288 clients = c; 292 clients = c;
289} 293}
@@ -309,15 +313,15 @@ buttonpress(XEvent *e) {
309 mask = 1 << i; 313 mask = 1 << i;
310 if(ev->button == Button1) { 314 if(ev->button == Button1) {
311 if(ev->state & MODKEY) 315 if(ev->state & MODKEY)
312 tag(&mask); 316 tag((Arg*)&mask);
313 else 317 else
314 view(&mask); 318 view((Arg*)&mask);
315 } 319 }
316 else if(ev->button == Button3) { 320 else if(ev->button == Button3) {
317 if(ev->state & MODKEY) 321 if(ev->state & MODKEY)
318 toggletag(&mask); 322 toggletag((Arg*)&mask);
319 else 323 else
320 toggleview(&mask); 324 toggleview((Arg*)&mask);
321 } 325 }
322 return; 326 return;
323 } 327 }
@@ -359,8 +363,9 @@ checkotherwm(void) {
359 363
360void 364void
361cleanup(void) { 365cleanup(void) {
366 Arg a = {.i = ~0};
362 close(STDIN_FILENO); 367 close(STDIN_FILENO);
363 view((uint[]){~0}); 368 view(&a);
364 while(stack) 369 while(stack)
365 unmanage(stack); 370 unmanage(stack);
366 if(dc.font.set) 371 if(dc.font.set)
@@ -466,13 +471,16 @@ destroynotify(XEvent *e) {
466 471
467void 472void
468detach(Client *c) { 473detach(Client *c) {
469 if(c->prev) 474 Client *i;
470 c->prev->next = c->next; 475
471 if(c->next) 476 if (c != clients) {
472 c->next->prev = c->prev; 477 for(i = clients; i->next != c; i = i->next);
473 if(c == clients) 478 i->next = c->next;
479 }
480 else {
474 clients = c->next; 481 clients = c->next;
475 c->next = c->prev = NULL; 482 }
483 c->next = NULL;
476} 484}
477 485
478void 486void
@@ -640,30 +648,24 @@ focusin(XEvent *e) { /* there are some broken focus acquiring clients */
640} 648}
641 649
642void 650void
643focusnext(const void *arg) { 651focusstack(const Arg *arg) {
644 Client *c; 652 Client *c = NULL, *i;
645 653
646 if(!sel) 654 if(!sel)
647 return; 655 return;
648 for(c = sel->next; c && c->isbanned; c = c->next); 656 if (arg->i > 0) {
649 if(!c) 657 for(c = sel->next; c && c->isbanned; c = c->next);
650 for(c = clients; c && c->isbanned; c = c->next); 658 if(!c)
651 if(c) { 659 for(c = clients; c && c->isbanned; c = c->next);
652 focus(c);
653 restack();
654 } 660 }
655} 661 else {
656 662 for(i = clients; i != sel; i = i->next)
657void 663 if (!i->isbanned)
658focusprev(const void *arg) { 664 c = i;
659 Client *c; 665 if(!c)
660 666 for(; i; i = i->next)
661 if(!sel) 667 if (!i->isbanned)
662 return; 668 c = i;
663 for(c = sel->prev; c && c->isbanned; c = c->prev);
664 if(!c) {
665 for(c = clients; c && c->next; c = c->next);
666 for(; c && c->isbanned; c = c->prev);
667 } 669 }
668 if(c) { 670 if(c) {
669 focus(c); 671 focus(c);
@@ -866,11 +868,11 @@ keypress(XEvent *e) {
866 if(keysym == keys[i].keysym 868 if(keysym == keys[i].keysym
867 && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) 869 && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
868 && keys[i].func) 870 && keys[i].func)
869 keys[i].func(keys[i].arg); 871 keys[i].func(&(keys[i].arg));
870} 872}
871 873
872void 874void
873killclient(const void *arg) { 875killclient(const Arg *arg) {
874 XEvent ev; 876 XEvent ev;
875 877
876 if(!sel) 878 if(!sel)
@@ -1056,7 +1058,7 @@ propertynotify(XEvent *e) {
1056} 1058}
1057 1059
1058void 1060void
1059quit(const void *arg) { 1061quit(const Arg *arg) {
1060 readin = running = False; 1062 readin = running = False;
1061} 1063}
1062 1064
@@ -1074,12 +1076,11 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
1074 h -= c->baseh; 1076 h -= c->baseh;
1075 1077
1076 /* adjust for aspect limits */ 1078 /* adjust for aspect limits */
1077 if(c->minax != c->maxax && c->minay != c->maxay 1079 if(c->mina > 0 && c->maxa > 0) {
1078 && c->minax > 0 && c->maxax > 0 && c->minay > 0 && c->maxay > 0) { 1080 if(c->maxa < (float) w/h)
1079 if(w * c->maxay > h * c->maxax) 1081 w = h * c->maxa;
1080 w = h * c->maxax / c->maxay; 1082 else if(c->mina > (float) h/w)
1081 else if(w * c->minay < h * c->minax) 1083 h = w * c->mina;
1082 h = w * c->minay / c->minax;
1083 } 1084 }
1084 1085
1085 /* adjust for increment value */ 1086 /* adjust for increment value */
@@ -1295,15 +1296,15 @@ setclientstate(Client *c, long state) {
1295 1296
1296/* arg > 1.0 will set mfact absolutly */ 1297/* arg > 1.0 will set mfact absolutly */
1297void 1298void
1298setmfact(const void *arg) { 1299setmfact(const Arg *arg) {
1299 double d = *((double*) arg); 1300 float f;
1300 1301
1301 if(!d || !lt->arrange) 1302 if(!arg || !lt->arrange)
1302 return; 1303 return;
1303 d = d < 1.0 ? d + mfact : d - 1.0; 1304 f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0;
1304 if(d < 0.1 || d > 0.9) 1305 if(f < 0.1 || f > 0.9)
1305 return; 1306 return;
1306 mfact = d; 1307 mfact = f;
1307 arrange(); 1308 arrange();
1308} 1309}
1309 1310
@@ -1386,7 +1387,7 @@ setup(void) {
1386} 1387}
1387 1388
1388void 1389void
1389spawn(const void *arg) { 1390spawn(const Arg *arg) {
1390 static char *shell = NULL; 1391 static char *shell = NULL;
1391 1392
1392 if(!shell && !(shell = getenv("SHELL"))) 1393 if(!shell && !(shell = getenv("SHELL")))
@@ -1398,8 +1399,8 @@ spawn(const void *arg) {
1398 if(dpy) 1399 if(dpy)
1399 close(ConnectionNumber(dpy)); 1400 close(ConnectionNumber(dpy));
1400 setsid(); 1401 setsid();
1401 execl(shell, shell, "-c", (char *)arg, (char *)NULL); 1402 execl(shell, shell, "-c", arg->c, (char *)NULL);
1402 fprintf(stderr, "dwm: execl '%s -c %s'", shell, (char *)arg); 1403 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->c);
1403 perror(" failed"); 1404 perror(" failed");
1404 } 1405 }
1405 exit(0); 1406 exit(0);
@@ -1408,9 +1409,9 @@ spawn(const void *arg) {
1408} 1409}
1409 1410
1410void 1411void
1411tag(const void *arg) { 1412tag(const Arg *arg) {
1412 if(sel && *(int *)arg & TAGMASK) { 1413 if(sel && arg->ui & TAGMASK) {
1413 sel->tags = *(int *)arg & TAGMASK; 1414 sel->tags = arg->ui & TAGMASK;
1414 arrange(); 1415 arrange();
1415 } 1416 }
1416} 1417}
@@ -1461,7 +1462,7 @@ tile(void) {
1461} 1462}
1462 1463
1463void 1464void
1464togglebar(const void *arg) { 1465togglebar(const Arg *arg) {
1465 showbar = !showbar; 1466 showbar = !showbar;
1466 updategeom(); 1467 updategeom();
1467 updatebar(); 1468 updatebar();
@@ -1469,7 +1470,7 @@ togglebar(const void *arg) {
1469} 1470}
1470 1471
1471void 1472void
1472togglefloating(const void *arg) { 1473togglefloating(const Arg *arg) {
1473 if(!sel) 1474 if(!sel)
1474 return; 1475 return;
1475 sel->isfloating = !sel->isfloating || sel->isfixed; 1476 sel->isfloating = !sel->isfloating || sel->isfixed;
@@ -1479,16 +1480,16 @@ togglefloating(const void *arg) {
1479} 1480}
1480 1481
1481void 1482void
1482togglelayout(const void *arg) { 1483togglelayout(const Arg *arg) {
1483 uint i; 1484 uint i;
1484 1485
1485 if(!arg) { 1486 if(!arg->c) {
1486 if(++lt == &layouts[LENGTH(layouts)]) 1487 if(++lt == &layouts[LENGTH(layouts)])
1487 lt = &layouts[0]; 1488 lt = &layouts[0];
1488 } 1489 }
1489 else { 1490 else {
1490 for(i = 0; i < LENGTH(layouts); i++) 1491 for(i = 0; i < LENGTH(layouts); i++)
1491 if(!strcmp((char *)arg, layouts[i].symbol)) 1492 if(!strcmp(arg->c, layouts[i].symbol))
1492 break; 1493 break;
1493 if(i == LENGTH(layouts)) 1494 if(i == LENGTH(layouts))
1494 return; 1495 return;
@@ -1501,25 +1502,21 @@ togglelayout(const void *arg) {
1501} 1502}
1502 1503
1503void 1504void
1504togglemax(const void *arg) { 1505togglemax(const Arg *arg) {
1505 ismax = !ismax; 1506 ismax = !ismax;
1506 arrange(); 1507 arrange();
1507} 1508}
1508 1509
1509void 1510void
1510toggletag(const void *arg) { 1511toggletag(const Arg *arg) {
1511 if(sel && (sel->tags ^ ((*(int *)arg) & TAGMASK))) { 1512 if(sel && (sel->tags ^= (arg->ui & TAGMASK)))
1512 sel->tags ^= (*(int *)arg) & TAGMASK;
1513 arrange(); 1513 arrange();
1514 }
1515} 1514}
1516 1515
1517void 1516void
1518toggleview(const void *arg) { 1517toggleview(const Arg *arg) {
1519 if((tagset[seltags] ^ ((*(int *)arg) & TAGMASK))) { 1518 if((tagset[seltags] ^= (arg->ui & TAGMASK)))
1520 tagset[seltags] ^= (*(int *)arg) & TAGMASK;
1521 arrange(); 1519 arrange();
1522 }
1523} 1520}
1524 1521
1525void 1522void
@@ -1628,13 +1625,11 @@ updatesizehints(Client *c) {
1628 else 1625 else
1629 c->minw = c->minh = 0; 1626 c->minw = c->minh = 0;
1630 if(size.flags & PAspect) { 1627 if(size.flags & PAspect) {
1631 c->minax = size.min_aspect.x; 1628 c->mina = (float)size.min_aspect.y / (float)size.min_aspect.x;
1632 c->maxax = size.max_aspect.x; 1629 c->maxa = (float)size.max_aspect.x / (float)size.max_aspect.y;
1633 c->minay = size.min_aspect.y;
1634 c->maxay = size.max_aspect.y;
1635 } 1630 }
1636 else 1631 else
1637 c->minax = c->maxax = c->minay = c->maxay = 0; 1632 c->maxa = c->mina = 0.0;
1638 c->isfixed = (c->maxw && c->minw && c->maxh && c->minh 1633 c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
1639 && c->maxw == c->minw && c->maxh == c->minh); 1634 && c->maxw == c->minw && c->maxh == c->minh);
1640} 1635}
@@ -1659,10 +1654,10 @@ updatewmhints(Client *c) {
1659} 1654}
1660 1655
1661void 1656void
1662view(const void *arg) { 1657view(const Arg *arg) {
1663 seltags ^= 1; /* toggle sel tagset */ 1658 seltags ^= 1; /* toggle sel tagset */
1664 if(arg && (*(int *)arg & TAGMASK)) 1659 if(arg && (arg->ui & TAGMASK))
1665 tagset[seltags] = *(int *)arg & TAGMASK; 1660 tagset[seltags] = arg->i & TAGMASK;
1666 arrange(); 1661 arrange();
1667} 1662}
1668 1663
@@ -1700,7 +1695,7 @@ xerrorstart(Display *dpy, XErrorEvent *ee) {
1700} 1695}
1701 1696
1702void 1697void
1703zoom(const void *arg) { 1698zoom(const Arg *arg) {
1704 Client *c = sel; 1699 Client *c = sel;
1705 1700
1706 if(ismax || !lt->arrange || (sel && sel->isfloating)) 1701 if(ismax || !lt->arrange || (sel && sel->isfloating))