nmaster-ncol.c - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
nmaster-ncol.c (3474B) | |
--- | |
1 enum {MaxMon = 8}; | |
2 static int nmasters[MaxMon]; | |
3 static int initnm = 0; | |
4 | |
5 static void | |
6 initnmaster(void) { | |
7 int i; | |
8 | |
9 if(initnm) | |
10 return; | |
11 for(i = 0; i < MaxMon; i++) | |
12 nmasters[i] = nmaster; | |
13 initnm = 1; | |
14 } | |
15 | |
16 static void | |
17 incnmaster(const Arg *arg) { | |
18 if(!arg || !selmon->lt[selmon->sellt]->arrange || selmon->num >=… | |
19 return; | |
20 nmasters[selmon->num] += arg->i; | |
21 if(nmasters[selmon->num] < 0) | |
22 nmasters[selmon->num] = 0; | |
23 arrange(NULL); | |
24 } | |
25 | |
26 static void | |
27 setnmaster(const Arg *arg) { | |
28 if(!arg || !selmon->lt[selmon->sellt]->arrange || selmon->num >=… | |
29 return; | |
30 nmasters[selmon->num] = arg->i > 0 ? arg->i : 0; | |
31 arrange(NULL); | |
32 } | |
33 | |
34 static void | |
35 ntile(Monitor *m) { | |
36 int x, y, h, w, mw, nm; | |
37 unsigned int i, n; | |
38 Client *c; | |
39 | |
40 initnmaster(); | |
41 for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next),… | |
42 c = nexttiled(m->clients); | |
43 nm = m->num < MaxMon ? nmasters[m->num] : nmaster; | |
44 if(nm > n) | |
45 nm = n; | |
46 /* master */ | |
47 if(nm > 0) { | |
48 mw = m->mfact * m->ww; | |
49 h = m->wh / nm; | |
50 if(h < bh) | |
51 h = m->wh; | |
52 y = m->wy; | |
53 for(i = 0; i < nm; i++, c = nexttiled(c->next)) { | |
54 resize(c, m->wx, y, (n == nm ? m->ww : mw) - 2 *… | |
55 ((i + 1 == nm) ? m->wy + m->wh - y : h) -… | |
56 if(h != m->wh) | |
57 y = c->y + HEIGHT(c); | |
58 } | |
59 n -= nm; | |
60 } else | |
61 mw = 0; | |
62 if(n == 0) | |
63 return; | |
64 /* tile stack */ | |
65 x = m->wx + mw; | |
66 y = m->wy; | |
67 w = m->ww - mw; | |
68 h = m->wh / n; | |
69 if(h < bh) | |
70 h = m->wh; | |
71 for(i = 0; c; c = nexttiled(c->next), i++) { | |
72 resize(c, x, y, w - 2 * c->bw, | |
73 ((i + 1 == n) ? m->wy + m->wh - y : h) - 2 * c->b… | |
74 if(h != m->wh) | |
75 y = c->y + HEIGHT(c); | |
76 } | |
77 } | |
78 | |
79 static void | |
80 ncol(Monitor *m) { | |
81 int x, y, h, w, mw, nm; | |
82 unsigned int i, n; | |
83 Client *c; | |
84 | |
85 initnmaster(); | |
86 for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next),… | |
87 c = nexttiled(m->clients); | |
88 nm = m->num < MaxMon ? nmasters[m->num] : nmaster; | |
89 if(nm > n) | |
90 nm = n; | |
91 /* master */ | |
92 if(nm > 0) { | |
93 mw = (n == nm) ? m->ww : m->mfact * m->ww; | |
94 w = mw / nm; | |
95 x = m->wx; | |
96 for(i = 0; i < nm; i++, c = nexttiled(c->next)) { | |
97 resize(c, x, m->wy, w - 2 * c->bw, m->wh - 2 * c… | |
98 x = c->x + WIDTH(c); | |
99 } | |
100 n -= nm; | |
101 } else | |
102 mw = 0; | |
103 if(n == 0) | |
104 return; | |
105 /* tile stack */ | |
106 x = m->wx + mw; | |
107 y = m->wy; | |
108 w = m->ww - mw; | |
109 h = m->wh / n; | |
110 if(h < bh) | |
111 h = m->wh; | |
112 for(i = 0; c; c = nexttiled(c->next), i++) { | |
113 resize(c, x, y, w - 2 * c->bw, | |
114 ((i + 1 == n) ? m->wy + m->wh - y : h) - 2 * c->b… | |
115 if(h != m->wh) | |
116 y = c->y + HEIGHT(c); | |
117 } | |
118 } | |
119 | |
120 static void | |
121 nbstack(Monitor *m) { | |
122 int x, y, h, w, mh, nm; | |
123 unsigned int i, n; | |
124 Client *c; | |
125 | |
126 initnmaster(); | |
127 for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next),… | |
128 c = nexttiled(m->clients); | |
129 nm = m->num < MaxMon ? nmasters[m->num] : nmaster; | |
130 if(nm > n) | |
131 nm = n; | |
132 /* master */ | |
133 if(nm > 0) { | |
134 mh = m->mfact * m->wh; | |
135 w = m->ww / nm; | |
136 if(w < bh) | |
137 w = m->ww; | |
138 x = m->wx; | |
139 for(i = 0; i < nm; i++, c = nexttiled(c->next)) { | |
140 resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->… | |
141 (n == nm ? m->wh : mh) - 2 * c->bw, False… | |
142 if(w != m->ww) | |
143 x = c->x + WIDTH(c); | |
144 } | |
145 n -= nm; | |
146 } else | |
147 mh = 0; | |
148 if(n == 0) | |
149 return; | |
150 /* tile stack */ | |
151 x = m->wx; | |
152 y = m->wy + mh; | |
153 w = m->ww / n; | |
154 h = m->wh - mh; | |
155 if(w < bh) | |
156 w = m->ww; | |
157 for(i = 0; c; c = nexttiled(c->next), i++) { | |
158 resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) -… | |
159 h - 2 * c->bw, False); | |
160 if(w != m->ww) | |
161 x = c->x + WIDTH(c); | |
162 } | |
163 } |