summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c5
-rw-r--r--dwm.h17
-rw-r--r--event.c10
-rw-r--r--tag.c40
4 files changed, 40 insertions, 32 deletions
diff --git a/client.c b/client.c
index ccd8100..aa96f4f 100644
--- a/client.c
+++ b/client.c
@@ -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);
diff --git a/dwm.h b/dwm.h
index f9f89dd..9670c68 100644
--- a/dwm.h
+++ b/dwm.h
@@ -30,8 +30,6 @@ typedef struct Client Client;
30typedef enum Corner Corner; 30typedef enum Corner Corner;
31typedef struct DC DC; 31typedef struct DC DC;
32typedef struct Fnt Fnt; 32typedef struct Fnt Fnt;
33typedef struct Key Key;
34typedef struct Rule Rule;
35 33
36union Arg { 34union 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
87struct Rule {
88 const char *class;
89 const char *instance;
90 char *tags[TLast];
91 Bool isfloat;
92};
93
94struct Key {
95 unsigned long mod;
96 KeySym keysym;
97 void (*func)(Arg *arg);
98 Arg arg;
99};
100
101extern char *tags[TLast], stext[1024]; 85extern char *tags[TLast], stext[1024];
102extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 86extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
103extern void (*handler[LASTEvent])(XEvent *); 87extern void (*handler[LASTEvent])(XEvent *);
@@ -108,7 +92,6 @@ extern Client *clients, *sel;
108extern Cursor cursor[CurLast]; 92extern Cursor cursor[CurLast];
109extern DC dc; 93extern DC dc;
110extern Display *dpy; 94extern Display *dpy;
111extern Key key[];
112extern Window root, barwin; 95extern Window root, barwin;
113 96
114/* client.c */ 97/* client.c */
diff --git a/event.c b/event.c
index f8ad44c..05f4ac5 100644
--- a/event.c
+++ b/event.c
@@ -12,6 +12,14 @@
12#define MouseMask (ButtonMask | PointerMotionMask) 12#define MouseMask (ButtonMask | PointerMotionMask)
13 13
14/* CUSTOMIZE */ 14/* CUSTOMIZE */
15
16typedef struct {
17 unsigned long mod;
18 KeySym keysym;
19 void (*func)(Arg *arg);
20 Arg arg;
21} Key;
22
15const char *browse[] = { "firefox", NULL }; 23const char *browse[] = { "firefox", NULL };
16const char *gimp[] = { "gimp", NULL }; 24const char *gimp[] = { "gimp", NULL };
17const char *term[] = { 25const char *term[] = {
@@ -20,7 +28,7 @@ const char *term[] = {
20}; 28};
21const char *xlock[] = { "xlock", NULL }; 29const char *xlock[] = { "xlock", NULL };
22 30
23Key key[] = { 31static 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 } },
diff --git a/tag.c b/tag.c
index c9eec90..82cf18a 100644
--- a/tag.c
+++ b/tag.c
@@ -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
15typedef struct {
16 const char *pattern;
17 char *tags[TLast];
18 Bool isfloat;
19} Rule;
20
12/* CUSTOMIZE */ 21/* CUSTOMIZE */
13static Rule rule[] = { 22static 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)
164void 174void
165settags(Client *c) 175settags(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(&regex, rule[i].pattern, 0)) {
183 for(j = 0; j < TLast; j++) 196 if(!regexec(&regex, 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(&regex);
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}