author | Anselm R. Garbe <arg@suckless.org> |
Wed, 21 Feb 2007 21:36:54 +0100 | |
changeset 812 | 8992a53a0d6a |
parent 791 | 9ab130668f41 |
child 813 | 0ed770c96e51 |
permissions | -rw-r--r-- |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
1 |
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
2 |
* See LICENSE file for license details. |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
3 |
*/ |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
4 |
#include "dwm.h" |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
5 |
#include <regex.h> |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
6 |
#include <stdio.h> |
791 | 7 |
#include <stdlib.h> |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
8 |
#include <X11/Xutil.h> |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
9 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
10 |
/* static */ |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
11 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
12 |
typedef struct { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
13 |
const char *prop; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
14 |
const char *tags; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
15 |
Bool isversatile; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
16 |
} Rule; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
17 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
18 |
typedef struct { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
19 |
regex_t *propregex; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
20 |
regex_t *tagregex; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
21 |
} Regs; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
22 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
23 |
TAGS |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
24 |
RULES |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
25 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
26 |
static Regs *regs = NULL; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
27 |
static unsigned int nrules = 0; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
28 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
29 |
/* extern */ |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
30 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
31 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
32 |
compileregs(void) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
33 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
34 |
regex_t *reg; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
35 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
36 |
if(regs) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
37 |
return; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
38 |
nrules = sizeof rule / sizeof rule[0]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
39 |
regs = emallocz(nrules * sizeof(Regs)); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
40 |
for(i = 0; i < nrules; i++) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
41 |
if(rule[i].prop) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
42 |
reg = emallocz(sizeof(regex_t)); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
43 |
if(regcomp(reg, rule[i].prop, REG_EXTENDED)) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
44 |
free(reg); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
45 |
else |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
46 |
regs[i].propregex = reg; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
47 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
48 |
if(rule[i].tags) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
49 |
reg = emallocz(sizeof(regex_t)); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
50 |
if(regcomp(reg, rule[i].tags, REG_EXTENDED)) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
51 |
free(reg); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
52 |
else |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
53 |
regs[i].tagregex = reg; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
54 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
55 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
56 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
57 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
58 |
Bool |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
59 |
isvisible(Client *c) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
60 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
61 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
62 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
63 |
if(c->tags[i] && seltag[i]) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
64 |
return True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
65 |
return False; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
66 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
67 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
68 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
69 |
settags(Client *c, Client *trans) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
70 |
char prop[512]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
71 |
unsigned int i, j; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
72 |
regmatch_t tmp; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
73 |
Bool matched = trans != NULL; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
74 |
XClassHint ch = { 0 }; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
75 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
76 |
if(matched) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
77 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
78 |
c->tags[i] = trans->tags[i]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
79 |
else { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
80 |
XGetClassHint(dpy, c->win, &ch); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
81 |
snprintf(prop, sizeof prop, "%s:%s:%s", |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
82 |
ch.res_class ? ch.res_class : "", |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
83 |
ch.res_name ? ch.res_name : "", c->name); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
84 |
for(i = 0; i < nrules; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
85 |
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
86 |
c->isversatile = rule[i].isversatile; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
87 |
for(j = 0; regs[i].tagregex && j < ntags; j++) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
88 |
if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
89 |
matched = True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
90 |
c->tags[j] = True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
91 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
92 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
93 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
94 |
if(ch.res_class) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
95 |
XFree(ch.res_class); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
96 |
if(ch.res_name) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
97 |
XFree(ch.res_name); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
98 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
99 |
if(!matched) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
100 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
101 |
c->tags[i] = seltag[i]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
102 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
103 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
104 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
105 |
tag(Arg *arg) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
106 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
107 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
108 |
if(!sel) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
109 |
return; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
110 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
111 |
sel->tags[i] = (arg->i == -1) ? True : False; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
112 |
if(arg->i >= 0 && arg->i < ntags) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
113 |
sel->tags[arg->i] = True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
114 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
115 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
116 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
117 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
118 |
toggletag(Arg *arg) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
119 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
120 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
121 |
if(!sel) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
122 |
return; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
123 |
sel->tags[arg->i] = !sel->tags[arg->i]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
124 |
for(i = 0; i < ntags && !sel->tags[i]; i++); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
125 |
if(i == ntags) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
126 |
sel->tags[arg->i] = True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
127 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
128 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
129 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
130 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
131 |
toggleview(Arg *arg) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
132 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
133 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
134 |
seltag[arg->i] = !seltag[arg->i]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
135 |
for(i = 0; i < ntags && !seltag[i]; i++); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
136 |
if(i == ntags) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
137 |
seltag[arg->i] = True; /* cannot toggle last view */ |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
138 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
139 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
140 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
141 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
142 |
view(Arg *arg) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
143 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
144 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
145 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
146 |
seltag[i] = (arg->i == -1) ? True : False; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
147 |
if(arg->i >= 0 && arg->i < ntags) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
148 |
seltag[arg->i] = True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
149 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
150 |
} |