aewl
diff tag.c @ 76:4bd49f404f10
proceeded with cleaning up, sorting functions, etc
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Sat, 15 Jul 2006 17:00:56 +0200 |
parents | f08271b7cb20 |
children | 8125f908c80c |
line diff
1.1 --- a/tag.c Sat Jul 15 16:30:50 2006 +0200 1.2 +++ b/tag.c Sat Jul 15 17:00:56 2006 +0200 1.3 @@ -2,71 +2,39 @@ 1.4 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 1.5 * See LICENSE file for license details. 1.6 */ 1.7 +#include "dwm.h" 1.8 1.9 -#include <stdlib.h> 1.10 -#include <stdio.h> 1.11 #include <string.h> 1.12 -#include <X11/Xatom.h> 1.13 #include <X11/Xutil.h> 1.14 1.15 -#include "dwm.h" 1.16 +/********** CUSTOMIZE **********/ 1.17 + 1.18 +char *tags[TLast] = { 1.19 + [Tscratch] = "scratch", 1.20 + [Tdev] = "dev", 1.21 + [Twww] = "www", 1.22 + [Twork] = "work", 1.23 +}; 1.24 1.25 static Rule rule[] = { 1.26 /* class instance tags dofloat */ 1.27 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, 1.28 }; 1.29 1.30 +/********** CUSTOMIZE **********/ 1.31 + 1.32 +/* extern functions */ 1.33 + 1.34 void (*arrange)(Arg *) = dotile; 1.35 1.36 -Client * 1.37 -getnext(Client *c) 1.38 +void 1.39 +appendtag(Arg *arg) 1.40 { 1.41 - for(; c && !c->tags[tsel]; c = c->next); 1.42 - return c; 1.43 -} 1.44 + if(!sel) 1.45 + return; 1.46 1.47 -void 1.48 -settags(Client *c) 1.49 -{ 1.50 - XClassHint ch; 1.51 - static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0; 1.52 - unsigned int i, j; 1.53 - Bool matched = False; 1.54 - 1.55 - if(!len) { 1.56 - c->tags[tsel] = tags[tsel]; 1.57 - return; 1.58 - } 1.59 - 1.60 - if(XGetClassHint(dpy, c->win, &ch)) { 1.61 - if(ch.res_class && ch.res_name) { 1.62 - for(i = 0; i < len; i++) 1.63 - if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) 1.64 - && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) 1.65 - { 1.66 - for(j = 0; j < TLast; j++) 1.67 - c->tags[j] = rule[i].tags[j]; 1.68 - c->dofloat = rule[i].dofloat; 1.69 - matched = True; 1.70 - break; 1.71 - } 1.72 - } 1.73 - if(ch.res_class) 1.74 - XFree(ch.res_class); 1.75 - if(ch.res_name) 1.76 - XFree(ch.res_name); 1.77 - } 1.78 - 1.79 - if(!matched) 1.80 - c->tags[tsel] = tags[tsel]; 1.81 -} 1.82 - 1.83 -void 1.84 -view(Arg *arg) 1.85 -{ 1.86 - tsel = arg->i; 1.87 + sel->tags[arg->i] = tags[arg->i]; 1.88 arrange(NULL); 1.89 - drawall(); 1.90 } 1.91 1.92 void 1.93 @@ -147,14 +115,11 @@ 1.94 drawall(); 1.95 } 1.96 1.97 -void 1.98 -appendtag(Arg *arg) 1.99 +Client * 1.100 +getnext(Client *c) 1.101 { 1.102 - if(!sel) 1.103 - return; 1.104 - 1.105 - sel->tags[arg->i] = tags[arg->i]; 1.106 - arrange(NULL); 1.107 + for(; c && !c->tags[tsel]; c = c->next); 1.108 + return c; 1.109 } 1.110 1.111 void 1.112 @@ -169,3 +134,46 @@ 1.113 appendtag(arg); 1.114 } 1.115 1.116 +void 1.117 +settags(Client *c) 1.118 +{ 1.119 + XClassHint ch; 1.120 + static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0; 1.121 + unsigned int i, j; 1.122 + Bool matched = False; 1.123 + 1.124 + if(!len) { 1.125 + c->tags[tsel] = tags[tsel]; 1.126 + return; 1.127 + } 1.128 + 1.129 + if(XGetClassHint(dpy, c->win, &ch)) { 1.130 + if(ch.res_class && ch.res_name) { 1.131 + for(i = 0; i < len; i++) 1.132 + if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) 1.133 + && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) 1.134 + { 1.135 + for(j = 0; j < TLast; j++) 1.136 + c->tags[j] = rule[i].tags[j]; 1.137 + c->dofloat = rule[i].dofloat; 1.138 + matched = True; 1.139 + break; 1.140 + } 1.141 + } 1.142 + if(ch.res_class) 1.143 + XFree(ch.res_class); 1.144 + if(ch.res_name) 1.145 + XFree(ch.res_name); 1.146 + } 1.147 + 1.148 + if(!matched) 1.149 + c->tags[tsel] = tags[tsel]; 1.150 +} 1.151 + 1.152 +void 1.153 +view(Arg *arg) 1.154 +{ 1.155 + tsel = arg->i; 1.156 + arrange(NULL); 1.157 + drawall(); 1.158 +}