summaryrefslogtreecommitdiffstats
path: root/tag.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-08-15 19:27:32 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-08-15 19:27:32 +0200
commit10d13f01ff764ba0e875adf5d2b83c49aa08d148 (patch)
treecad3a1162879cdf53d3a6ac7f97a025d4a65ff40 /tag.c
parentfix of resize (thanks Sander for the hint!) (diff)
downloaddwm-10d13f01ff764ba0e875adf5d2b83c49aa08d148.tar.gz
dwm-10d13f01ff764ba0e875adf5d2b83c49aa08d148.zip
fififi
Diffstat (limited to '')
-rw-r--r--tag.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/tag.c b/tag.c
index a532761..cb1a2c4 100644
--- a/tag.c
+++ b/tag.c
@@ -28,14 +28,15 @@ static unsigned int nrules = 0;
28static char prop[512]; 28static char prop[512];
29 29
30static void 30static void
31persisttags(Client *c) 31persistconfig(Client *c) {
32{
33 unsigned int i; 32 unsigned int i;
34 33
35 for(i = 0; i < ntags && i < sizeof prop - 1; i++) 34 for(i = 0; i < ntags && i < sizeof prop - 1; i++)
36 prop[i] = c->tags[i] ? '+' : '-'; 35 prop[i] = c->tags[i] ? '1' : '0';
36 if(i < sizeof prop - 1)
37 prop[i++] = c->isfloating ? '1' : '0';
37 prop[i] = '\0'; 38 prop[i] = '\0';
38 XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8, 39 XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
39 PropModeReplace, (unsigned char *)prop, i); 40 PropModeReplace, (unsigned char *)prop, i);
40} 41}
41 42
@@ -93,14 +94,16 @@ settags(Client *c, Client *trans) {
93 else { 94 else {
94 /* check if window has set a property */ 95 /* check if window has set a property */
95 name.nitems = 0; 96 name.nitems = 0;
96 XGetTextProperty(dpy, c->win, &name, dwmtags); 97 XGetTextProperty(dpy, c->win, &name, dwmconfig);
97 if(name.nitems && name.encoding == XA_STRING) { 98 if(name.nitems && name.encoding == XA_STRING) {
98 strncpy(prop, (char *)name.value, sizeof prop - 1); 99 strncpy(prop, (char *)name.value, sizeof prop - 1);
99 prop[sizeof prop - 1] = '\0'; 100 prop[sizeof prop - 1] = '\0';
100 XFree(name.value); 101 XFree(name.value);
101 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) 102 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
102 if((c->tags[i] = prop[i] == '+')) 103 if((c->tags[i] = prop[i] == '1'))
103 matched = True; 104 matched = True;
105 if(i < sizeof prop - 1 && prop[i] != '\0')
106 c->isfloating = prop[i] == '1';
104 } 107 }
105 } 108 }
106 if(!matched) { 109 if(!matched) {
@@ -127,7 +130,7 @@ settags(Client *c, Client *trans) {
127 if(!matched) 130 if(!matched)
128 for(i = 0; i < ntags; i++) 131 for(i = 0; i < ntags; i++)
129 c->tags[i] = seltag[i]; 132 c->tags[i] = seltag[i];
130 persisttags(c); 133 persistconfig(c);
131} 134}
132 135
133void 136void
@@ -142,7 +145,17 @@ tag(const char *arg) {
142 if(i >= 0 && i < ntags) 145 if(i >= 0 && i < ntags)
143 sel->tags[i] = True; 146 sel->tags[i] = True;
144 if(sel) 147 if(sel)
145 persisttags(sel); 148 persistconfig(sel);
149 arrange();
150}
151
152void
153togglefloating(const char *arg) {
154 if(!sel || isfloating())
155 return;
156 sel->isfloating = !sel->isfloating;
157 if(sel->isfloating)
158 resize(sel, sel->x, sel->y, sel->w, sel->h, True);
146 arrange(); 159 arrange();
147} 160}
148 161
@@ -158,7 +171,7 @@ toggletag(const char *arg) {
158 if(j == ntags) 171 if(j == ntags)
159 sel->tags[i] = True; 172 sel->tags[i] = True;
160 if(sel) 173 if(sel)
161 persisttags(sel); 174 persistconfig(sel);
162 arrange(); 175 arrange();
163} 176}
164 177