summaryrefslogtreecommitdiffstats
path: root/tag.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-15 17:00:56 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-15 17:00:56 +0200
commitadaa28a6e600f636f5e86244ccef69e98419ba1a (patch)
treea7373162dabedbc0edf809559781489eca5a3fbb /tag.c
parentrearranged several stuff (diff)
downloaddwm-adaa28a6e600f636f5e86244ccef69e98419ba1a.tar.gz
dwm-adaa28a6e600f636f5e86244ccef69e98419ba1a.zip
proceeded with cleaning up, sorting functions, etc
Diffstat (limited to '')
-rw-r--r--tag.c118
1 files changed, 63 insertions, 55 deletions
diff --git a/tag.c b/tag.c
index 0861128..8951dd8 100644
--- a/tag.c
+++ b/tag.c
@@ -2,71 +2,39 @@
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5#include "dwm.h"
5 6
6#include <stdlib.h>
7#include <stdio.h>
8#include <string.h> 7#include <string.h>
9#include <X11/Xatom.h>
10#include <X11/Xutil.h> 8#include <X11/Xutil.h>
11 9
12#include "dwm.h" 10/********** CUSTOMIZE **********/
11
12char *tags[TLast] = {
13 [Tscratch] = "scratch",
14 [Tdev] = "dev",
15 [Twww] = "www",
16 [Twork] = "work",
17};
13 18
14static Rule rule[] = { 19static Rule rule[] = {
15 /* class instance tags dofloat */ 20 /* class instance tags dofloat */
16 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, 21 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False },
17}; 22};
18 23
19void (*arrange)(Arg *) = dotile; 24/********** CUSTOMIZE **********/
20 25
21Client * 26/* extern functions */
22getnext(Client *c) 27
23{ 28void (*arrange)(Arg *) = dotile;
24 for(; c && !c->tags[tsel]; c = c->next);
25 return c;
26}
27 29
28void 30void
29settags(Client *c) 31appendtag(Arg *arg)
30{ 32{
31 XClassHint ch; 33 if(!sel)
32 static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
33 unsigned int i, j;
34 Bool matched = False;
35
36 if(!len) {
37 c->tags[tsel] = tags[tsel];
38 return; 34 return;
39 }
40
41 if(XGetClassHint(dpy, c->win, &ch)) {
42 if(ch.res_class && ch.res_name) {
43 for(i = 0; i < len; i++)
44 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class))
45 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance)))
46 {
47 for(j = 0; j < TLast; j++)
48 c->tags[j] = rule[i].tags[j];
49 c->dofloat = rule[i].dofloat;
50 matched = True;
51 break;
52 }
53 }
54 if(ch.res_class)
55 XFree(ch.res_class);
56 if(ch.res_name)
57 XFree(ch.res_name);
58 }
59 35
60 if(!matched) 36 sel->tags[arg->i] = tags[arg->i];
61 c->tags[tsel] = tags[tsel];
62}
63
64void
65view(Arg *arg)
66{
67 tsel = arg->i;
68 arrange(NULL); 37 arrange(NULL);
69 drawall();
70} 38}
71 39
72void 40void
@@ -147,14 +115,11 @@ dotile(Arg *arg)
147 drawall(); 115 drawall();
148} 116}
149 117
150void 118Client *
151appendtag(Arg *arg) 119getnext(Client *c)
152{ 120{
153 if(!sel) 121 for(; c && !c->tags[tsel]; c = c->next);
154 return; 122 return c;
155
156 sel->tags[arg->i] = tags[arg->i];
157 arrange(NULL);
158} 123}
159 124
160void 125void
@@ -169,3 +134,46 @@ replacetag(Arg *arg)
169 appendtag(arg); 134 appendtag(arg);
170} 135}
171 136
137void
138settags(Client *c)
139{
140 XClassHint ch;
141 static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
142 unsigned int i, j;
143 Bool matched = False;
144
145 if(!len) {
146 c->tags[tsel] = tags[tsel];
147 return;
148 }
149
150 if(XGetClassHint(dpy, c->win, &ch)) {
151 if(ch.res_class && ch.res_name) {
152 for(i = 0; i < len; i++)
153 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class))
154 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance)))
155 {
156 for(j = 0; j < TLast; j++)
157 c->tags[j] = rule[i].tags[j];
158 c->dofloat = rule[i].dofloat;
159 matched = True;
160 break;
161 }
162 }
163 if(ch.res_class)
164 XFree(ch.res_class);
165 if(ch.res_name)
166 XFree(ch.res_name);
167 }
168
169 if(!matched)
170 c->tags[tsel] = tags[tsel];
171}
172
173void
174view(Arg *arg)
175{
176 tsel = arg->i;
177 arrange(NULL);
178 drawall();
179}