author | Anselm R. Garbe <arg@suckless.org> |
Wed, 30 May 2007 12:19:28 +0200 | |
changeset 910 | c13cb8c6b7a5 |
parent 909 | 8a8b7a413e66 |
child 924 | 5b1caaa31aba |
permissions | -rw-r--r-- |
910
c13cb8c6b7a5
referred to LICENSE file
Anselm R. Garbe <arg@suckless.org>
parents:
909
diff
changeset
|
1 |
/* See LICENSE file for copyright and license details. */ |
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
|
2 |
#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
|
3 |
#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
|
4 |
#include <stdio.h> |
791 | 5 |
#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
|
6 |
#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
|
7 |
|
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 |
/* 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
|
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 |
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
|
11 |
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
|
12 |
const char *tags; |
837
123231b9eb87
renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents:
830
diff
changeset
|
13 |
Bool isfloating; |
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
|
14 |
} 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
|
15 |
|
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 |
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
|
17 |
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
|
18 |
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
|
19 |
} 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
|
20 |
|
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 |
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
|
22 |
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
|
23 |
|
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 |
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
|
25 |
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
|
26 |
|
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 |
/* 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
|
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 |
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
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
|
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 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
} |
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 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
} |
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 |
} |
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 |
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
|
57 |
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
|
58 |
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
|
59 |
|
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 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
} |
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 |
|
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 |
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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
|
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 |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { |
837
123231b9eb87
renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents:
830
diff
changeset
|
84 |
c->isfloating = rule[i].isfloating; |
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
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
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
|
89 |
} |
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 |
} |
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 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
} |
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 |
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
|
98 |
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
|
99 |
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
|
100 |
} |
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 |
|
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 |
void |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
103 |
tag(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
104 |
int i; |
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
|
105 |
|
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 |
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
|
107 |
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
|
108 |
for(i = 0; i < ntags; i++) |
827 | 109 |
sel->tags[i] = arg == NULL; |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
110 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
111 |
if(i >= 0 && i < ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
112 |
sel->tags[i] = True; |
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
|
113 |
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
|
114 |
} |
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 |
void |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
117 |
toggletag(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
118 |
int i, j; |
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
|
119 |
|
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 |
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
|
121 |
return; |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
122 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
123 |
sel->tags[i] = !sel->tags[i]; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
124 |
for(j = 0; j < ntags && !sel->tags[j]; j++); |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
125 |
if(j == ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
126 |
sel->tags[i] = True; |
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
|
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 |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
131 |
toggleview(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
132 |
int i, j; |
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
|
133 |
|
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
134 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
135 |
seltag[i] = !seltag[i]; |
826 | 136 |
for(j = 0; j < ntags && !seltag[j]; j++); |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
137 |
if(j == ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
138 |
seltag[i] = True; /* cannot toggle last view */ |
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
|
139 |
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
|
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 |
|
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 |
void |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
143 |
view(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
144 |
int i; |
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
|
145 |
|
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 |
for(i = 0; i < ntags; i++) |
827 | 147 |
seltag[i] = arg == NULL; |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
148 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
149 |
if(i >= 0 && i < ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
150 |
seltag[i] = True; |
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
|
151 |
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
|
152 |
} |