author | Anselm R. Garbe <garbeam@gmail.com> |
Fri, 17 Aug 2007 21:12:55 +0200 | |
changeset 960 | b5f856fcef4c |
parent 958 | 8b502be8b8e0 |
child 963 | 7416c26a14db |
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> |
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
6 |
#include <string.h> |
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
7 |
#include <X11/Xatom.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; |
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
|
15 |
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
|
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; |
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
28 |
static char prop[512]; |
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
|
29 |
|
950 | 30 |
static void |
953 | 31 |
persistconfig(Client *c) { |
950 | 32 |
unsigned int i; |
33 |
||
34 |
for(i = 0; i < ntags && i < sizeof prop - 1; i++) |
|
953 | 35 |
prop[i] = c->tags[i] ? '1' : '0'; |
36 |
if(i < sizeof prop - 1) |
|
37 |
prop[i++] = c->isfloating ? '1' : '0'; |
|
950 | 38 |
prop[i] = '\0'; |
953 | 39 |
XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8, |
950 | 40 |
PropModeReplace, (unsigned char *)prop, i); |
41 |
} |
|
42 |
||
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
43 |
static unsigned int |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
44 |
idxoftag(const char *tag) { |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
45 |
unsigned int i; |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
46 |
|
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
47 |
for(i = 0; i < ntags; i++) |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
48 |
if(tags[i] == tag) |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
49 |
return i; |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
50 |
return 0; |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
51 |
} |
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
52 |
|
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
|
53 |
/* 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
|
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 |
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
|
56 |
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
|
57 |
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
|
58 |
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
|
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 |
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
|
61 |
return; |
958 | 62 |
nrules = sizeof rules / sizeof rules[0]; |
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
|
63 |
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
|
64 |
for(i = 0; i < nrules; i++) { |
958 | 65 |
if(rules[i].prop) { |
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
|
66 |
reg = emallocz(sizeof(regex_t)); |
958 | 67 |
if(regcomp(reg, rules[i].prop, REG_EXTENDED)) |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
} |
958 | 72 |
if(rules[i].tags) { |
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
|
73 |
reg = emallocz(sizeof(regex_t)); |
958 | 74 |
if(regcomp(reg, rules[i].tags, REG_EXTENDED)) |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
} |
48e7c3b45250
split screen.c 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 |
} |
48e7c3b45250
split screen.c 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 |
} |
48e7c3b45250
split screen.c 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 |
|
48e7c3b45250
split screen.c 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 |
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
|
83 |
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
|
84 |
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
|
85 |
|
48e7c3b45250
split screen.c 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 |
for(i = 0; i < ntags; i++) |
960
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
958
diff
changeset
|
87 |
if(c->tags[i] && seltags[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
|
88 |
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
|
89 |
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
|
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 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
XClassHint ch = { 0 }; |
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
98 |
XTextProperty name; |
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
|
99 |
|
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
100 |
if(matched) { |
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
|
101 |
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
|
102 |
c->tags[i] = trans->tags[i]; |
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
103 |
} |
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
|
104 |
else { |
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
105 |
/* check if window has set a property */ |
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
106 |
name.nitems = 0; |
953 | 107 |
XGetTextProperty(dpy, c->win, &name, dwmconfig); |
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
108 |
if(name.nitems && name.encoding == XA_STRING) { |
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
109 |
strncpy(prop, (char *)name.value, sizeof prop - 1); |
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
110 |
prop[sizeof prop - 1] = '\0'; |
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
111 |
XFree(name.value); |
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
112 |
for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) |
953 | 113 |
if((c->tags[i] = prop[i] == '1')) |
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
114 |
matched = True; |
953 | 115 |
if(i < sizeof prop - 1 && prop[i] != '\0') |
116 |
c->isfloating = prop[i] == '1'; |
|
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
117 |
} |
950 | 118 |
} |
119 |
if(!matched) { |
|
949
99ee5c370f94
tags should be persistent now during X server run
Anselm R. Garbe <garbeam@gmail.com>
parents:
946
diff
changeset
|
120 |
/* rule matching */ |
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
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
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
|
126 |
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { |
958 | 127 |
c->isfloating = rules[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
|
128 |
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
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
} |
48e7c3b45250
split screen.c 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 |
} |
48e7c3b45250
split screen.c 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 |
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
|
136 |
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
|
137 |
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
|
138 |
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
|
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 |
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
|
141 |
for(i = 0; i < ntags; i++) |
960
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
958
diff
changeset
|
142 |
c->tags[i] = seltags[i]; |
953 | 143 |
persistconfig(c); |
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
|
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 |
|
48e7c3b45250
split screen.c 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 |
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
|
147 |
tag(const char *arg) { |
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
148 |
unsigned 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
|
149 |
|
48e7c3b45250
split screen.c 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 |
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
|
151 |
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
|
152 |
for(i = 0; i < ntags; i++) |
827 | 153 |
sel->tags[i] = arg == NULL; |
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
154 |
i = idxoftag(arg); |
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
|
155 |
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
|
156 |
sel->tags[i] = True; |
954
18381a2cda42
fixed _DWM_CONFIG persistation, fixed the client disapperance bug during restarts
Anselm R. Garbe <garbeam@gmail.com>
parents:
953
diff
changeset
|
157 |
persistconfig(sel); |
953 | 158 |
arrange(); |
159 |
} |
|
160 |
||
161 |
void |
|
162 |
togglefloating(const char *arg) { |
|
163 |
if(!sel || isfloating()) |
|
164 |
return; |
|
165 |
sel->isfloating = !sel->isfloating; |
|
954
18381a2cda42
fixed _DWM_CONFIG persistation, fixed the client disapperance bug during restarts
Anselm R. Garbe <garbeam@gmail.com>
parents:
953
diff
changeset
|
166 |
if(sel->isfloating) { |
953 | 167 |
resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
954
18381a2cda42
fixed _DWM_CONFIG persistation, fixed the client disapperance bug during restarts
Anselm R. Garbe <garbeam@gmail.com>
parents:
953
diff
changeset
|
168 |
persistconfig(sel); |
18381a2cda42
fixed _DWM_CONFIG persistation, fixed the client disapperance bug during restarts
Anselm R. Garbe <garbeam@gmail.com>
parents:
953
diff
changeset
|
169 |
} |
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
941
diff
changeset
|
170 |
arrange(); |
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
|
171 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
172 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
173 |
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
|
174 |
toggletag(const char *arg) { |
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
175 |
unsigned 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
|
176 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
177 |
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
|
178 |
return; |
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
179 |
i = idxoftag(arg); |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
sel->tags[i] = True; |
954
18381a2cda42
fixed _DWM_CONFIG persistation, fixed the client disapperance bug during restarts
Anselm R. Garbe <garbeam@gmail.com>
parents:
953
diff
changeset
|
184 |
persistconfig(sel); |
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
941
diff
changeset
|
185 |
arrange(); |
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
|
186 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
187 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
188 |
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
|
189 |
toggleview(const char *arg) { |
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
190 |
unsigned 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
|
191 |
|
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
192 |
i = idxoftag(arg); |
960
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
958
diff
changeset
|
193 |
seltags[i] = !seltags[i]; |
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
958
diff
changeset
|
194 |
for(j = 0; j < ntags && !seltags[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
|
195 |
if(j == ntags) |
960
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
958
diff
changeset
|
196 |
seltags[i] = True; /* cannot toggle last view */ |
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
941
diff
changeset
|
197 |
arrange(); |
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
|
198 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
199 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
200 |
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
|
201 |
view(const char *arg) { |
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
202 |
unsigned 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
|
203 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
204 |
for(i = 0; i < ntags; i++) |
960
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
958
diff
changeset
|
205 |
seltags[i] = arg == NULL; |
956
484245788760
made tag/view/toggle{tag,view} work on pointer to tags-array, there was the need to define Key key[] not static to do this. split focusclient into focusnext/prev, fixed config.*.h's
Anselm R. Garbe <garbeam@gmail.com>
parents:
954
diff
changeset
|
206 |
i = idxoftag(arg); |
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
|
207 |
if(i >= 0 && i < ntags) |
960
b5f856fcef4c
renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents:
958
diff
changeset
|
208 |
seltags[i] = True; |
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
941
diff
changeset
|
209 |
arrange(); |
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
|
210 |
} |