Mercurial > dwm-meillo
annotate tag.c @ 454:ffb462fb7903
small change to comments, renamed two set* functions in client.c into update*
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Mon, 11 Sep 2006 10:00:56 +0200 |
parents | 785bad5f21dd |
children | 9d23330a5268 |
rev | line source |
---|---|
75 | 1 /* |
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | |
3 * See LICENSE file for license details. | |
4 */ | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
5 #include "dwm.h" |
114 | 6 #include <regex.h> |
7 #include <stdio.h> | |
191 | 8 #include <stdlib.h> |
75 | 9 #include <string.h> |
114 | 10 #include <sys/types.h> |
75 | 11 #include <X11/Xutil.h> |
12 | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
13 |
114 | 14 typedef struct { |
191 | 15 const char *clpattern; |
16 const char *tpattern; | |
114 | 17 Bool isfloat; |
18 } Rule; | |
19 | |
191 | 20 typedef struct { |
21 regex_t *clregex; | |
22 regex_t *tregex; | |
23 } RReg; | |
24 | |
25 /* static */ | |
26 | |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
144
diff
changeset
|
27 TAGS |
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
144
diff
changeset
|
28 RULES |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
29 |
191 | 30 static RReg *rreg = NULL; |
31 static unsigned int len = 0; | |
32 | |
125 | 33 /* extern */ |
34 | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
35 Client * |
142
9b9deafa0508
committed a patch which fixes the hints of Jukka
arg@10ksloc.org
parents:
138
diff
changeset
|
36 getnext(Client *c) |
93
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
37 { |
261
d6fd632d861c
implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents:
240
diff
changeset
|
38 for(; c && !isvisible(c); c = c->next); |
93
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
39 return c; |
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
40 } |
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
41 |
127
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
42 Client * |
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
43 getprev(Client *c) |
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
44 { |
261
d6fd632d861c
implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents:
240
diff
changeset
|
45 for(; c && !isvisible(c); c = c->prev); |
127
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
46 return c; |
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
47 } |
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
48 |
93
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
49 void |
191 | 50 initrregs() |
51 { | |
52 unsigned int i; | |
53 regex_t *reg; | |
54 | |
55 if(rreg) | |
56 return; | |
57 len = sizeof(rule) / sizeof(rule[0]); | |
58 rreg = emallocz(len * sizeof(RReg)); | |
59 | |
60 for(i = 0; i < len; i++) { | |
61 if(rule[i].clpattern) { | |
62 reg = emallocz(sizeof(regex_t)); | |
63 if(regcomp(reg, rule[i].clpattern, 0)) | |
64 free(reg); | |
65 else | |
66 rreg[i].clregex = reg; | |
67 } | |
68 if(rule[i].tpattern) { | |
69 reg = emallocz(sizeof(regex_t)); | |
70 if(regcomp(reg, rule[i].tpattern, 0)) | |
71 free(reg); | |
72 else | |
73 rreg[i].tregex = reg; | |
74 } | |
75 } | |
76 } | |
77 | |
270
dacd3f3c5823
implemented restack behavior (floats are on top in tiled mode)
Anselm R.Garbe <arg@10ksloc.org>
parents:
267
diff
changeset
|
78 void |
431
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
79 settags(Client *c, Client *trans) |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
80 { |
336
2a65e8b3d21a
implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
81 char prop[512]; |
191 | 82 unsigned int i, j; |
114 | 83 regmatch_t tmp; |
431
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
84 Bool matched = trans != NULL; |
114 | 85 XClassHint ch; |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
86 |
431
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
87 if(matched) { |
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
88 for(i = 0; i < ntags; i++) |
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
89 c->tags[i] = trans->tags[i]; |
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
90 } |
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
91 else if(XGetClassHint(dpy, c->win, &ch)) { |
336
2a65e8b3d21a
implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
92 snprintf(prop, sizeof(prop), "%s:%s:%s", |
114 | 93 ch.res_class ? ch.res_class : "", |
336
2a65e8b3d21a
implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
94 ch.res_name ? ch.res_name : "", c->name); |
191 | 95 for(i = 0; !matched && i < len; i++) |
336
2a65e8b3d21a
implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
96 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) { |
191 | 97 c->isfloat = rule[i].isfloat; |
98 for(j = 0; rreg[i].tregex && j < ntags; j++) { | |
99 if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) { | |
100 matched = True; | |
101 c->tags[j] = True; | |
102 } | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
103 } |
114 | 104 } |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
105 if(ch.res_class) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
106 XFree(ch.res_class); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
107 if(ch.res_name) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
108 XFree(ch.res_name); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
109 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
110 if(!matched) |
261
d6fd632d861c
implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents:
240
diff
changeset
|
111 for(i = 0; i < ntags; i++) |
262
d659a2dce2b5
implemented viewextend and added M-S-C-n shortcuts for extending the current view... updated man page (works great!) nice feature
Anselm R.Garbe <arg@10ksloc.org>
parents:
261
diff
changeset
|
112 c->tags[i] = seltag[i]; |
441
785bad5f21dd
does this preserve z order for anthony?
Anselm R. Garbe <arg@10kloc.org>
parents:
440
diff
changeset
|
113 for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++); |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
114 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
115 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
116 void |
284
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
117 tag(Arg *arg) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
118 { |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
119 unsigned int i; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
120 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
121 if(!sel) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
122 return; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
123 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
124 for(i = 0; i < ntags; i++) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
125 sel->tags[i] = False; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
126 sel->tags[arg->i] = True; |
441
785bad5f21dd
does this preserve z order for anthony?
Anselm R. Garbe <arg@10kloc.org>
parents:
440
diff
changeset
|
127 sel->weight = arg->i; |
393
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
384
diff
changeset
|
128 arrange(NULL); |
284
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
129 } |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
130 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
131 void |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
132 toggletag(Arg *arg) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
133 { |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
134 unsigned int i; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
135 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
136 if(!sel) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
137 return; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
138 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
139 sel->tags[arg->i] = !sel->tags[arg->i]; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
140 for(i = 0; i < ntags && !sel->tags[i]; i++); |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
141 if(i == ntags) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
142 sel->tags[arg->i] = True; |
441
785bad5f21dd
does this preserve z order for anthony?
Anselm R. Garbe <arg@10kloc.org>
parents:
440
diff
changeset
|
143 sel->weight = (i == ntags) ? arg->i : i; |
393
6786cd59468f
applied sanders patch to remove unnecessary commit()
Anselm R. Garbe <arg@10kloc.org>
parents:
384
diff
changeset
|
144 arrange(NULL); |
284
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
145 } |