Xinqi Bao's Git
82cf18aab65768022297fc70a81a4fdb7bee3582
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
10 #include <sys/types.h>
11 #include <X11/Xutil.h>
22 static Rule rule
[] = {
23 /* class instance tags isfloat */
24 { "Firefox.*", { [Twww
] = "www" }, False
},
25 { "Gimp.*", { 0 }, True
},
32 [Tscratch
] = "scratch",
37 void (*arrange
)(Arg
*) = dotile
;
45 sel
->tags
[arg
->i
] = tags
[arg
->i
];
55 for(c
= clients
; c
; c
= c
->next
) {
58 resize(c
, True
, TopLeft
);
63 if(sel
&& !sel
->tags
[tsel
]) {
64 if((sel
= getnext(clients
, tsel
))) {
80 for(n
= 0, c
= clients
; c
; c
= c
->next
)
81 if(c
->tags
[tsel
] && !c
->isfloat
)
85 h
= (sh
- bh
) / (n
- 1);
89 for(i
= 0, c
= clients
; c
; c
= c
->next
) {
94 resize(c
, True
, TopLeft
);
100 *c
->w
= sw
- 2 * c
->border
;
101 *c
->h
= sh
- 2 * c
->border
- bh
;
106 *c
->w
= mw
- 2 * c
->border
;
107 *c
->h
= sh
- 2 * c
->border
- bh
;
111 *c
->y
= sy
+ (i
- 1) * h
+ bh
;
112 *c
->w
= w
- 2 * c
->border
;
113 *c
->h
= h
- 2 * c
->border
;
115 else { /* fallback if h < bh */
118 *c
->w
= w
- 2 * c
->border
;
119 *c
->h
= sh
- 2 * c
->border
- bh
;
121 resize(c
, False
, TopLeft
);
127 if(!sel
|| (sel
&& !sel
->tags
[tsel
])) {
128 if((sel
= getnext(clients
, tsel
))) {
137 getnext(Client
*c
, unsigned int t
)
139 for(; c
&& !c
->tags
[t
]; c
= c
->next
);
152 if(!(c
= getnext(clients
, arg
->i
)))
155 for(i
= 0; i
< TLast
; i
++)
157 c
->tags
[tsel
] = tags
[tsel
];
169 for(i
= 0; i
< TLast
; i
++)
178 static unsigned int len
= rule
? sizeof(rule
) / sizeof(rule
[0]) : 0;
182 Bool matched
= False
;
186 c
->tags
[tsel
] = tags
[tsel
];
190 if(XGetClassHint(dpy
, c
->win
, &ch
)) {
191 snprintf(classinst
, sizeof(classinst
), "%s:%s",
192 ch
.res_class
? ch
.res_class
: "",
193 ch
.res_name
? ch
.res_name
: "");
194 for(i
= 0; !matched
&& i
< len
; i
++) {
195 if(!regcomp(®ex
, rule
[i
].pattern
, 0)) {
196 if(!regexec(®ex
, classinst
, 1, &tmp
, 0)) {
197 for(j
= 0; j
< TLast
; j
++) {
200 c
->tags
[j
] = rule
[i
].tags
[j
];
202 c
->isfloat
= rule
[i
].isfloat
;
213 c
->tags
[tsel
] = tags
[tsel
];