summaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-20 10:49:53 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-20 10:49:53 +0100
commit8012fcf3334148d2b39646fd372a7514cc74c250 (patch)
tree157855dd25044e50f7696eb57655c88c6069ac2e /layout.c
parentusing eprint instead of fputs (diff)
downloaddwm-8012fcf3334148d2b39646fd372a7514cc74c250.tar.gz
dwm-8012fcf3334148d2b39646fd372a7514cc74c250.zip
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Diffstat (limited to '')
-rw-r--r--layout.c (renamed from screen.c)143
1 files changed, 0 insertions, 143 deletions
diff --git a/screen.c b/layout.c
index 8abe3d7..d754afb 100644
--- a/screen.c
+++ b/layout.c
@@ -2,12 +2,6 @@
2 * See LICENSE file for license details. 2 * See LICENSE file for license details.
3 */ 3 */
4#include "dwm.h" 4#include "dwm.h"
5#include <regex.h>
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9#include <sys/types.h>
10#include <X11/Xutil.h>
11 5
12unsigned int master = MASTER; 6unsigned int master = MASTER;
13unsigned int nmaster = NMASTER; 7unsigned int nmaster = NMASTER;
@@ -16,22 +10,6 @@ Layout *lt = NULL;
16 10
17/* static */ 11/* static */
18 12
19typedef struct {
20 const char *prop;
21 const char *tags;
22 Bool isversatile;
23} Rule;
24
25typedef struct {
26 regex_t *propregex;
27 regex_t *tagregex;
28} Regs;
29
30TAGS
31RULES
32
33static Regs *regs = NULL;
34static unsigned int nrules = 0;
35static unsigned int nlayouts = 0; 13static unsigned int nlayouts = 0;
36 14
37static void 15static void
@@ -91,33 +69,6 @@ LAYOUTS
91/* extern */ 69/* extern */
92 70
93void 71void
94compileregs(void) {
95 unsigned int i;
96 regex_t *reg;
97
98 if(regs)
99 return;
100 nrules = sizeof rule / sizeof rule[0];
101 regs = emallocz(nrules * sizeof(Regs));
102 for(i = 0; i < nrules; i++) {
103 if(rule[i].prop) {
104 reg = emallocz(sizeof(regex_t));
105 if(regcomp(reg, rule[i].prop, REG_EXTENDED))
106 free(reg);
107 else
108 regs[i].propregex = reg;
109 }
110 if(rule[i].tags) {
111 reg = emallocz(sizeof(regex_t));
112 if(regcomp(reg, rule[i].tags, REG_EXTENDED))
113 free(reg);
114 else
115 regs[i].tagregex = reg;
116 }
117 }
118}
119
120void
121incnmaster(Arg *arg) { 72incnmaster(Arg *arg) {
122 if((lt->arrange != tile) || (nmaster + arg->i < 1) 73 if((lt->arrange != tile) || (nmaster + arg->i < 1)
123 || (wah / (nmaster + arg->i) <= 2 * BORDERPX)) 74 || (wah / (nmaster + arg->i) <= 2 * BORDERPX))
@@ -142,16 +93,6 @@ initlayouts(void) {
142 } 93 }
143} 94}
144 95
145Bool
146isvisible(Client *c) {
147 unsigned int i;
148
149 for(i = 0; i < ntags; i++)
150 if(c->tags[i] && seltag[i])
151 return True;
152 return False;
153}
154
155void 96void
156resizemaster(Arg *arg) { 97resizemaster(Arg *arg) {
157 if(lt->arrange != tile) 98 if(lt->arrange != tile)
@@ -213,68 +154,6 @@ setlayout(Arg *arg) {
213} 154}
214 155
215void 156void
216settags(Client *c, Client *trans) {
217 char prop[512];
218 unsigned int i, j;
219 regmatch_t tmp;
220 Bool matched = trans != NULL;
221 XClassHint ch = { 0 };
222
223 if(matched)
224 for(i = 0; i < ntags; i++)
225 c->tags[i] = trans->tags[i];
226 else {
227 XGetClassHint(dpy, c->win, &ch);
228 snprintf(prop, sizeof prop, "%s:%s:%s",
229 ch.res_class ? ch.res_class : "",
230 ch.res_name ? ch.res_name : "", c->name);
231 for(i = 0; i < nrules; i++)
232 if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
233 c->isversatile = rule[i].isversatile;
234 for(j = 0; regs[i].tagregex && j < ntags; j++) {
235 if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
236 matched = True;
237 c->tags[j] = True;
238 }
239 }
240 }
241 if(ch.res_class)
242 XFree(ch.res_class);
243 if(ch.res_name)
244 XFree(ch.res_name);
245 }
246 if(!matched)
247 for(i = 0; i < ntags; i++)
248 c->tags[i] = seltag[i];
249}
250
251void
252tag(Arg *arg) {
253 unsigned int i;
254
255 if(!sel)
256 return;
257 for(i = 0; i < ntags; i++)
258 sel->tags[i] = (arg->i == -1) ? True : False;
259 if(arg->i >= 0 && arg->i < ntags)
260 sel->tags[arg->i] = True;
261 lt->arrange();
262}
263
264void
265toggletag(Arg *arg) {
266 unsigned int i;
267
268 if(!sel)
269 return;
270 sel->tags[arg->i] = !sel->tags[arg->i];
271 for(i = 0; i < ntags && !sel->tags[i]; i++);
272 if(i == ntags)
273 sel->tags[arg->i] = True;
274 lt->arrange();
275}
276
277void
278toggleversatile(Arg *arg) { 157toggleversatile(Arg *arg) {
279 if(!sel || lt->arrange == versatile) 158 if(!sel || lt->arrange == versatile)
280 return; 159 return;
@@ -283,17 +162,6 @@ toggleversatile(Arg *arg) {
283} 162}
284 163
285void 164void
286toggleview(Arg *arg) {
287 unsigned int i;
288
289 seltag[arg->i] = !seltag[arg->i];
290 for(i = 0; i < ntags && !seltag[i]; i++);
291 if(i == ntags)
292 seltag[arg->i] = True; /* cannot toggle last view */
293 lt->arrange();
294}
295
296void
297versatile(void) { 165versatile(void) {
298 Client *c; 166 Client *c;
299 167
@@ -315,14 +183,3 @@ versatile(void) {
315 } 183 }
316 restack(); 184 restack();
317} 185}
318
319void
320view(Arg *arg) {
321 unsigned int i;
322
323 for(i = 0; i < ntags; i++)
324 seltag[i] = (arg->i == -1) ? True : False;
325 if(arg->i >= 0 && arg->i < ntags)
326 seltag[arg->i] = True;
327 lt->arrange();
328}