diff options
| -rw-r--r-- | client.c | 5 | ||||
| -rw-r--r-- | dwm.h | 17 | ||||
| -rw-r--r-- | event.c | 10 | ||||
| -rw-r--r-- | tag.c | 40 |
4 files changed, 40 insertions, 32 deletions
| @@ -247,8 +247,9 @@ manage(Window w, XWindowAttributes *wa) | |||
| 247 | GrabModeAsync, GrabModeSync, None, None); | 247 | GrabModeAsync, GrabModeSync, None, None); |
| 248 | 248 | ||
| 249 | if(!c->isfloat) | 249 | if(!c->isfloat) |
| 250 | c->isfloat = trans | 250 | c->isfloat = trans || (c->maxw && c->minw && |
| 251 | || ((c->maxw == c->minw) && (c->maxh == c->minh)); | 251 | (c->maxw == c->minw) && (c->maxh == c->minh)); |
| 252 | |||
| 252 | 253 | ||
| 253 | setgeom(c); | 254 | setgeom(c); |
| 254 | settitle(c); | 255 | settitle(c); |
| @@ -30,8 +30,6 @@ typedef struct Client Client; | |||
| 30 | typedef enum Corner Corner; | 30 | typedef enum Corner Corner; |
| 31 | typedef struct DC DC; | 31 | typedef struct DC DC; |
| 32 | typedef struct Fnt Fnt; | 32 | typedef struct Fnt Fnt; |
| 33 | typedef struct Key Key; | ||
| 34 | typedef struct Rule Rule; | ||
| 35 | 33 | ||
| 36 | union Arg { | 34 | union Arg { |
| 37 | const char **argv; | 35 | const char **argv; |
| @@ -84,20 +82,6 @@ struct Client { | |||
| 84 | Window title; | 82 | Window title; |
| 85 | }; | 83 | }; |
| 86 | 84 | ||
| 87 | struct Rule { | ||
| 88 | const char *class; | ||
| 89 | const char *instance; | ||
| 90 | char *tags[TLast]; | ||
| 91 | Bool isfloat; | ||
| 92 | }; | ||
| 93 | |||
| 94 | struct Key { | ||
| 95 | unsigned long mod; | ||
| 96 | KeySym keysym; | ||
| 97 | void (*func)(Arg *arg); | ||
| 98 | Arg arg; | ||
| 99 | }; | ||
| 100 | |||
| 101 | extern char *tags[TLast], stext[1024]; | 85 | extern char *tags[TLast], stext[1024]; |
| 102 | extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; | 86 | extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; |
| 103 | extern void (*handler[LASTEvent])(XEvent *); | 87 | extern void (*handler[LASTEvent])(XEvent *); |
| @@ -108,7 +92,6 @@ extern Client *clients, *sel; | |||
| 108 | extern Cursor cursor[CurLast]; | 92 | extern Cursor cursor[CurLast]; |
| 109 | extern DC dc; | 93 | extern DC dc; |
| 110 | extern Display *dpy; | 94 | extern Display *dpy; |
| 111 | extern Key key[]; | ||
| 112 | extern Window root, barwin; | 95 | extern Window root, barwin; |
| 113 | 96 | ||
| 114 | /* client.c */ | 97 | /* client.c */ |
| @@ -12,6 +12,14 @@ | |||
| 12 | #define MouseMask (ButtonMask | PointerMotionMask) | 12 | #define MouseMask (ButtonMask | PointerMotionMask) |
| 13 | 13 | ||
| 14 | /* CUSTOMIZE */ | 14 | /* CUSTOMIZE */ |
| 15 | |||
| 16 | typedef struct { | ||
| 17 | unsigned long mod; | ||
| 18 | KeySym keysym; | ||
| 19 | void (*func)(Arg *arg); | ||
| 20 | Arg arg; | ||
| 21 | } Key; | ||
| 22 | |||
| 15 | const char *browse[] = { "firefox", NULL }; | 23 | const char *browse[] = { "firefox", NULL }; |
| 16 | const char *gimp[] = { "gimp", NULL }; | 24 | const char *gimp[] = { "gimp", NULL }; |
| 17 | const char *term[] = { | 25 | const char *term[] = { |
| @@ -20,7 +28,7 @@ const char *term[] = { | |||
| 20 | }; | 28 | }; |
| 21 | const char *xlock[] = { "xlock", NULL }; | 29 | const char *xlock[] = { "xlock", NULL }; |
| 22 | 30 | ||
| 23 | Key key[] = { | 31 | static Key key[] = { |
| 24 | /* modifier key function arguments */ | 32 | /* modifier key function arguments */ |
| 25 | { ControlMask, XK_0, appendtag, { .i = Tscratch } }, | 33 | { ControlMask, XK_0, appendtag, { .i = Tscratch } }, |
| 26 | { ControlMask, XK_1, appendtag, { .i = Tdev } }, | 34 | { ControlMask, XK_1, appendtag, { .i = Tdev } }, |
| @@ -4,15 +4,25 @@ | |||
| 4 | */ | 4 | */ |
| 5 | #include "dwm.h" | 5 | #include "dwm.h" |
| 6 | 6 | ||
| 7 | #include <regex.h> | ||
| 8 | #include <stdio.h> | ||
| 7 | #include <string.h> | 9 | #include <string.h> |
| 10 | #include <sys/types.h> | ||
| 8 | #include <X11/Xutil.h> | 11 | #include <X11/Xutil.h> |
| 9 | 12 | ||
| 10 | /* static */ | 13 | /* static */ |
| 11 | 14 | ||
| 15 | typedef struct { | ||
| 16 | const char *pattern; | ||
| 17 | char *tags[TLast]; | ||
| 18 | Bool isfloat; | ||
| 19 | } Rule; | ||
| 20 | |||
| 12 | /* CUSTOMIZE */ | 21 | /* CUSTOMIZE */ |
| 13 | static Rule rule[] = { | 22 | static Rule rule[] = { |
| 14 | /* class instance tags isfloat */ | 23 | /* class instance tags isfloat */ |
| 15 | { "Firefox-bin", "firefox-bin", { [Twww] = "www" }, False }, | 24 | { "Firefox.*", { [Twww] = "www" }, False }, |
| 25 | { "Gimp.*", { 0 }, True}, | ||
| 16 | }; | 26 | }; |
| 17 | 27 | ||
| 18 | /* extern */ | 28 | /* extern */ |
| @@ -164,10 +174,13 @@ replacetag(Arg *arg) | |||
| 164 | void | 174 | void |
| 165 | settags(Client *c) | 175 | settags(Client *c) |
| 166 | { | 176 | { |
| 167 | XClassHint ch; | 177 | char classinst[256]; |
| 168 | static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0; | 178 | static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0; |
| 169 | unsigned int i, j; | 179 | unsigned int i, j; |
| 180 | regex_t regex; | ||
| 181 | regmatch_t tmp; | ||
| 170 | Bool matched = False; | 182 | Bool matched = False; |
| 183 | XClassHint ch; | ||
| 171 | 184 | ||
| 172 | if(!len) { | 185 | if(!len) { |
| 173 | c->tags[tsel] = tags[tsel]; | 186 | c->tags[tsel] = tags[tsel]; |
| @@ -175,24 +188,27 @@ settags(Client *c) | |||
| 175 | } | 188 | } |
| 176 | 189 | ||
| 177 | if(XGetClassHint(dpy, c->win, &ch)) { | 190 | if(XGetClassHint(dpy, c->win, &ch)) { |
| 178 | if(ch.res_class && ch.res_name) { | 191 | snprintf(classinst, sizeof(classinst), "%s:%s", |
| 179 | for(i = 0; i < len; i++) | 192 | ch.res_class ? ch.res_class : "", |
| 180 | if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) | 193 | ch.res_name ? ch.res_name : ""); |
| 181 | && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) | 194 | for(i = 0; !matched && i < len; i++) { |
| 182 | { | 195 | if(!regcomp(®ex, rule[i].pattern, 0)) { |
| 183 | for(j = 0; j < TLast; j++) | 196 | if(!regexec(®ex, classinst, 1, &tmp, 0)) { |
| 197 | for(j = 0; j < TLast; j++) { | ||
| 198 | if(rule[i].tags[j]) | ||
| 199 | matched = True; | ||
| 184 | c->tags[j] = rule[i].tags[j]; | 200 | c->tags[j] = rule[i].tags[j]; |
| 201 | } | ||
| 185 | c->isfloat = rule[i].isfloat; | 202 | c->isfloat = rule[i].isfloat; |
| 186 | matched = True; | ||
| 187 | break; | ||
| 188 | } | 203 | } |
| 204 | regfree(®ex); | ||
| 205 | } | ||
| 189 | } | 206 | } |
| 190 | if(ch.res_class) | 207 | if(ch.res_class) |
| 191 | XFree(ch.res_class); | 208 | XFree(ch.res_class); |
| 192 | if(ch.res_name) | 209 | if(ch.res_name) |
| 193 | XFree(ch.res_name); | 210 | XFree(ch.res_name); |
| 194 | } | 211 | } |
| 195 | |||
| 196 | if(!matched) | 212 | if(!matched) |
| 197 | c->tags[tsel] = tags[tsel]; | 213 | c->tags[tsel] = tags[tsel]; |
| 198 | } | 214 | } |
