summaryrefslogtreecommitdiffstats
path: root/screen.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--screen.c48
1 files changed, 7 insertions, 41 deletions
diff --git a/screen.c b/screen.c
index ec8637f..b534766 100644
--- a/screen.c
+++ b/screen.c
@@ -3,8 +3,6 @@
3#include <regex.h> 3#include <regex.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <stdlib.h> 5#include <stdlib.h>
6#include <string.h>
7#include <X11/Xatom.h>
8#include <X11/Xutil.h> 6#include <X11/Xutil.h>
9 7
10/* static */ 8/* static */
@@ -28,7 +26,6 @@ typedef struct {
28TAGS 26TAGS
29RULES 27RULES
30 28
31static char buf[512];
32static unsigned int nrules = 0; 29static unsigned int nrules = 0;
33static unsigned int nlayouts = 0; 30static unsigned int nlayouts = 0;
34static unsigned int ltidx = 0; /* default */ 31static unsigned int ltidx = 0; /* default */
@@ -53,19 +50,6 @@ floating(void) { /* default floating layout */
53 resize(c, c->x, c->y, c->w, c->h, True); 50 resize(c, c->x, c->y, c->w, c->h, True);
54} 51}
55 52
56static void
57setdwmprops(void) {
58 unsigned int i;
59
60 for(i = 0; i < ntags && i < sizeof buf - 1; i++)
61 buf[i] = seltags[i] ? '1' : '0';
62 if(i < sizeof buf - 1)
63 buf[i++] = (char)ltidx + '0';
64 buf[i] = '\0';
65 XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
66 PropModeReplace, (unsigned char *)buf, i);
67}
68
69LAYOUTS 53LAYOUTS
70 54
71/* extern */ 55/* extern */
@@ -74,6 +58,7 @@ unsigned int blw = 0;
74 58
75void 59void
76applyrules(Client *c) { 60applyrules(Client *c) {
61 static char buf[512];
77 unsigned int i, j; 62 unsigned int i, j;
78 regmatch_t tmp; 63 regmatch_t tmp;
79 Bool matched = False; 64 Bool matched = False;
@@ -215,20 +200,6 @@ isvisible(Client *c) {
215 return False; 200 return False;
216} 201}
217 202
218void
219getdwmprops(void) {
220 unsigned int i;
221
222 if(gettextprop(root, dwmprops, buf, sizeof buf)) {
223 for(i = 0; i < ntags && i < sizeof buf - 1 && buf[i] != '\0'; i++)
224 seltags[i] = buf[i] == '1';
225 if(i < sizeof buf - 1 && buf[i] != '\0') {
226 if((unsigned int)(buf[i] - '0') < nlayouts)
227 ltidx = buf[i] - '0';
228 }
229 }
230}
231
232Client * 203Client *
233nexttiled(Client *c) { 204nexttiled(Client *c) {
234 for(; c && (c->isfloating || !isvisible(c)); c = c->next); 205 for(; c && (c->isfloating || !isvisible(c)); c = c->next);
@@ -266,15 +237,17 @@ restack(void) {
266 237
267void 238void
268setlayout(const char *arg) { 239setlayout(const char *arg) {
269 int i; 240 unsigned int i;
270 241
271 if(!arg) { 242 if(!arg) {
272 if(++ltidx == nlayouts) 243 if(++ltidx == nlayouts)
273 ltidx = 0;; 244 ltidx = 0;;
274 } 245 }
275 else { 246 else {
276 i = atoi(arg); 247 for(i = 0; i < nlayouts; i++)
277 if(i < 0 || i >= nlayouts) 248 if(arg == layouts[i].symbol)
249 break;
250 if(i == nlayouts)
278 return; 251 return;
279 ltidx = i; 252 ltidx = i;
280 } 253 }
@@ -282,7 +255,6 @@ setlayout(const char *arg) {
282 arrange(); 255 arrange();
283 else 256 else
284 drawstatus(); 257 drawstatus();
285 setdwmprops();
286} 258}
287 259
288void 260void
@@ -296,7 +268,6 @@ tag(const char *arg) {
296 i = idxoftag(arg); 268 i = idxoftag(arg);
297 if(i >= 0 && i < ntags) 269 if(i >= 0 && i < ntags)
298 sel->tags[i] = True; 270 sel->tags[i] = True;
299 setprops(sel);
300 arrange(); 271 arrange();
301} 272}
302 273
@@ -315,10 +286,8 @@ togglefloating(const char *arg) {
315 if(!sel || isfloating()) 286 if(!sel || isfloating())
316 return; 287 return;
317 sel->isfloating = !sel->isfloating; 288 sel->isfloating = !sel->isfloating;
318 if(sel->isfloating) { 289 if(sel->isfloating)
319 resize(sel, sel->x, sel->y, sel->w, sel->h, True); 290 resize(sel, sel->x, sel->y, sel->w, sel->h, True);
320 setprops(sel);
321 }
322 arrange(); 291 arrange();
323} 292}
324 293
@@ -352,7 +321,6 @@ toggletag(const char *arg) {
352 for(j = 0; j < ntags && !sel->tags[j]; j++); 321 for(j = 0; j < ntags && !sel->tags[j]; j++);
353 if(j == ntags) 322 if(j == ntags)
354 sel->tags[i] = True; 323 sel->tags[i] = True;
355 setprops(sel);
356 arrange(); 324 arrange();
357} 325}
358 326
@@ -365,7 +333,6 @@ toggleview(const char *arg) {
365 for(j = 0; j < ntags && !seltags[j]; j++); 333 for(j = 0; j < ntags && !seltags[j]; j++);
366 if(j == ntags) 334 if(j == ntags)
367 seltags[i] = True; /* cannot toggle last view */ 335 seltags[i] = True; /* cannot toggle last view */
368 setdwmprops();
369 arrange(); 336 arrange();
370} 337}
371 338
@@ -404,6 +371,5 @@ view(const char *arg) {
404 i = idxoftag(arg); 371 i = idxoftag(arg);
405 if(i >= 0 && i < ntags) 372 if(i >= 0 && i < ntags)
406 seltags[i] = True; 373 seltags[i] = True;
407 setdwmprops();
408 arrange(); 374 arrange();
409} 375}