summaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-22 07:59:13 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-22 07:59:13 +0100
commit352cae4380713949d3800ebcda7aff3bb5ab9efc (patch)
treedd301143a6777dacb09b90d6d27d16aeb19056fc /layout.c
parentjust ignore the FD_ISSET check in main.c of xfd, just call XPending (which do... (diff)
downloaddwm-352cae4380713949d3800ebcda7aff3bb5ab9efc.tar.gz
dwm-352cae4380713949d3800ebcda7aff3bb5ab9efc.zip
several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH
Diffstat (limited to '')
-rw-r--r--layout.c92
1 files changed, 64 insertions, 28 deletions
diff --git a/layout.c b/layout.c
index e5f635c..6a65599 100644
--- a/layout.c
+++ b/layout.c
@@ -3,14 +3,14 @@
3 */ 3 */
4#include "dwm.h" 4#include "dwm.h"
5 5
6unsigned int master = MASTER;
7unsigned int nmaster = NMASTER;
8unsigned int blw = 0; 6unsigned int blw = 0;
9Layout *lt = NULL; 7Layout *lt = NULL;
10 8
11/* static */ 9/* static */
12 10
13static unsigned int nlayouts = 0; 11static unsigned int nlayouts = 0;
12static unsigned int masterw = MASTERWIDTH;
13static unsigned int nmaster = NMASTER;
14 14
15static void 15static void
16tile(void) { 16tile(void) {
@@ -21,7 +21,7 @@ tile(void) {
21 n++; 21 n++;
22 /* window geoms */ 22 /* window geoms */
23 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); 23 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
24 mw = (n > nmaster) ? (waw * master) / 1000 : waw; 24 mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
25 th = (n > nmaster) ? wah / (n - nmaster) : 0; 25 th = (n > nmaster) ? wah / (n - nmaster) : 0;
26 tw = waw - mw; 26 tw = waw - mw;
27 27
@@ -69,7 +69,7 @@ LAYOUTS
69/* extern */ 69/* extern */
70 70
71void 71void
72focusnext(Arg *arg) { 72focusnext(Arg arg) {
73 Client *c; 73 Client *c;
74 74
75 if(!sel) 75 if(!sel)
@@ -84,7 +84,7 @@ focusnext(Arg *arg) {
84} 84}
85 85
86void 86void
87focusprev(Arg *arg) { 87focusprev(Arg arg) {
88 Client *c; 88 Client *c;
89 89
90 if(!sel) 90 if(!sel)
@@ -101,11 +101,26 @@ focusprev(Arg *arg) {
101} 101}
102 102
103void 103void
104incnmaster(Arg *arg) { 104incmasterw(Arg arg) {
105 if((lt->arrange != tile) || (nmaster + arg->i < 1) 105 if(lt->arrange != tile)
106 || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) 106 return;
107 if(arg.i == 0)
108 masterw = MASTERWIDTH;
109 else {
110 if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX
111 || waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX)
112 return;
113 masterw += arg.i;
114 }
115 lt->arrange();
116}
117
118void
119incnmaster(Arg arg) {
120 if((lt->arrange != tile) || (nmaster + arg.i < 1)
121 || (wah / (nmaster + arg.i) <= 2 * BORDERPX))
107 return; 122 return;
108 nmaster += arg->i; 123 nmaster += arg.i;
109 if(sel) 124 if(sel)
110 lt->arrange(); 125 lt->arrange();
111 else 126 else
@@ -132,21 +147,6 @@ nexttiled(Client *c) {
132} 147}
133 148
134void 149void
135resizemaster(Arg *arg) {
136 if(lt->arrange != tile)
137 return;
138 if(arg->i == 0)
139 master = MASTER;
140 else {
141 if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
142 || waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
143 return;
144 master += arg->i;
145 }
146 lt->arrange();
147}
148
149void
150restack(void) { 150restack(void) {
151 Client *c; 151 Client *c;
152 XEvent ev; 152 XEvent ev;
@@ -170,10 +170,10 @@ restack(void) {
170} 170}
171 171
172void 172void
173setlayout(Arg *arg) { 173setlayout(Arg arg) {
174 unsigned int i; 174 unsigned int i;
175 175
176 if(arg->i == -1) { 176 if(arg.i == -1) {
177 for(i = 0; i < nlayouts && lt != &layout[i]; i++); 177 for(i = 0; i < nlayouts && lt != &layout[i]; i++);
178 if(i == nlayouts - 1) 178 if(i == nlayouts - 1)
179 lt = &layout[0]; 179 lt = &layout[0];
@@ -181,9 +181,9 @@ setlayout(Arg *arg) {
181 lt = &layout[++i]; 181 lt = &layout[++i];
182 } 182 }
183 else { 183 else {
184 if(arg->i < 0 || arg->i >= nlayouts) 184 if(arg.i < 0 || arg.i >= nlayouts)
185 return; 185 return;
186 lt = &layout[arg->i]; 186 lt = &layout[arg.i];
187 } 187 }
188 if(sel) 188 if(sel)
189 lt->arrange(); 189 lt->arrange();
@@ -192,6 +192,24 @@ setlayout(Arg *arg) {
192} 192}
193 193
194void 194void
195togglemax(Arg arg) {
196 XEvent ev;
197
198 if(!sel || !sel->isversatile || sel->isfixed || lt->arrange != versatile)
199 return;
200 if((sel->ismax = !sel->ismax)) {
201 sel->rx = sel->x;
202 sel->ry = sel->y;
203 sel->rw = sel->w;
204 sel->rh = sel->h;
205 resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
206 }
207 else
208 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
209 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
210}
211
212void
195versatile(void) { 213versatile(void) {
196 Client *c; 214 Client *c;
197 215
@@ -213,3 +231,21 @@ versatile(void) {
213 } 231 }
214 restack(); 232 restack();
215} 233}
234
235void
236zoom(Arg arg) {
237 unsigned int n;
238 Client *c;
239
240 if(!sel || lt->arrange != tile || sel->isversatile)
241 return;
242 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
243 n++;
244 if((c = sel) == nexttiled(clients))
245 if(!(c = nexttiled(c->next)))
246 return;
247 detach(c);
248 attach(c);
249 focus(c);
250 lt->arrange();
251}