diff options
| author | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-15 17:00:56 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-15 17:00:56 +0200 |
| commit | adaa28a6e600f636f5e86244ccef69e98419ba1a (patch) | |
| tree | a7373162dabedbc0edf809559781489eca5a3fbb /tag.c | |
| parent | rearranged several stuff (diff) | |
| download | dwm-adaa28a6e600f636f5e86244ccef69e98419ba1a.tar.gz dwm-adaa28a6e600f636f5e86244ccef69e98419ba1a.zip | |
proceeded with cleaning up, sorting functions, etc
Diffstat (limited to '')
| -rw-r--r-- | tag.c | 118 |
1 files changed, 63 insertions, 55 deletions
| @@ -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 | |||
| 12 | char *tags[TLast] = { | ||
| 13 | [Tscratch] = "scratch", | ||
| 14 | [Tdev] = "dev", | ||
| 15 | [Twww] = "www", | ||
| 16 | [Twork] = "work", | ||
| 17 | }; | ||
| 13 | 18 | ||
| 14 | static Rule rule[] = { | 19 | static 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 | ||
| 19 | void (*arrange)(Arg *) = dotile; | 24 | /********** CUSTOMIZE **********/ |
| 20 | 25 | ||
| 21 | Client * | 26 | /* extern functions */ |
| 22 | getnext(Client *c) | 27 | |
| 23 | { | 28 | void (*arrange)(Arg *) = dotile; |
| 24 | for(; c && !c->tags[tsel]; c = c->next); | ||
| 25 | return c; | ||
| 26 | } | ||
| 27 | 29 | ||
| 28 | void | 30 | void |
| 29 | settags(Client *c) | 31 | appendtag(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 | |||
| 64 | void | ||
| 65 | view(Arg *arg) | ||
| 66 | { | ||
| 67 | tsel = arg->i; | ||
| 68 | arrange(NULL); | 37 | arrange(NULL); |
| 69 | drawall(); | ||
| 70 | } | 38 | } |
| 71 | 39 | ||
| 72 | void | 40 | void |
| @@ -147,14 +115,11 @@ dotile(Arg *arg) | |||
| 147 | drawall(); | 115 | drawall(); |
| 148 | } | 116 | } |
| 149 | 117 | ||
| 150 | void | 118 | Client * |
| 151 | appendtag(Arg *arg) | 119 | getnext(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 | ||
| 160 | void | 125 | void |
| @@ -169,3 +134,46 @@ replacetag(Arg *arg) | |||
| 169 | appendtag(arg); | 134 | appendtag(arg); |
| 170 | } | 135 | } |
| 171 | 136 | ||
| 137 | void | ||
| 138 | settags(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 | |||
| 173 | void | ||
| 174 | view(Arg *arg) | ||
| 175 | { | ||
| 176 | tsel = arg->i; | ||
| 177 | arrange(NULL); | ||
| 178 | drawall(); | ||
| 179 | } | ||
