9 #include <X11/Xatom.h> |
9 #include <X11/Xatom.h> |
10 #include <X11/Xutil.h> |
10 #include <X11/Xutil.h> |
11 |
11 |
12 #include "dwm.h" |
12 #include "dwm.h" |
13 |
13 |
14 static void (*arrange)(Arg *) = tiling; |
14 void (*arrange)(Arg *) = tiling; |
15 |
15 |
16 static Rule rule[] = { |
16 static Rule rule[] = { |
17 { "Firefox-bin", "Gecko", { [Twww] = "www" } }, |
17 /* class instance tags floating */ |
|
18 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, |
18 }; |
19 }; |
19 |
20 |
20 static Client * |
21 static Client * |
21 next(Client *c) |
22 next(Client *c) |
22 { |
23 { |
120 int n, i, w, h; |
121 int n, i, w, h; |
121 |
122 |
122 w = sw - mw; |
123 w = sw - mw; |
123 arrange = tiling; |
124 arrange = tiling; |
124 for(n = 0, c = clients; c; c = c->next) |
125 for(n = 0, c = clients; c; c = c->next) |
125 if(c->tags[tsel]) |
126 if(c->tags[tsel] && !c->floating) |
126 n++; |
127 n++; |
127 |
128 |
128 h = (n > 1) ? sh / (n - 1) : sh; |
129 h = (n > 1) ? sh / (n - 1) : sh; |
129 |
130 |
130 for(i = 0, c = clients; c; c = c->next) { |
131 for(i = 0, c = clients; c; c = c->next) { |
131 if(c->tags[tsel]) { |
132 if(c->tags[tsel]) { |
|
133 if(c->floating) { |
|
134 craise(c); |
|
135 resize(c, True); |
|
136 continue; |
|
137 } |
132 if(n == 1) { |
138 if(n == 1) { |
133 c->x = sx; |
139 c->x = sx; |
134 c->y = sy; |
140 c->y = sy; |
135 c->w = sw - 2 * c->border; |
141 c->w = sw - 2 * c->border; |
136 c->h = sh - 2 * c->border; |
142 c->h = sh - 2 * c->border; |
328 return; |
334 return; |
329 } |
335 } |
330 |
336 |
331 if(XGetClassHint(dpy, c->win, &ch)) { |
337 if(XGetClassHint(dpy, c->win, &ch)) { |
332 if(ch.res_class && ch.res_name) { |
338 if(ch.res_class && ch.res_name) { |
333 fprintf(stderr, "%s:%s\n", ch.res_class, ch.res_name); |
|
334 for(i = 0; i < len; i++) |
339 for(i = 0; i < len; i++) |
335 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) |
340 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) |
336 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) |
341 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) |
337 { |
342 { |
338 fprintf(stderr, "->>>%s:%s\n", ch.res_class, ch.res_name); |
|
339 for(j = 0; j < TLast; j++) |
343 for(j = 0; j < TLast; j++) |
340 c->tags[j] = rule[i].tags[j]; |
344 c->tags[j] = rule[i].tags[j]; |
|
345 c->floating = rule[i].floating; |
341 matched = True; |
346 matched = True; |
342 break; |
347 break; |
343 } |
348 } |
344 } |
349 } |
345 if(ch.res_class) |
350 if(ch.res_class) |
355 void |
360 void |
356 manage(Window w, XWindowAttributes *wa) |
361 manage(Window w, XWindowAttributes *wa) |
357 { |
362 { |
358 Client *c, **l; |
363 Client *c, **l; |
359 XSetWindowAttributes twa; |
364 XSetWindowAttributes twa; |
|
365 Window trans; |
360 |
366 |
361 c = emallocz(sizeof(Client)); |
367 c = emallocz(sizeof(Client)); |
362 c->win = w; |
368 c->win = w; |
363 c->tx = c->x = wa->x; |
369 c->tx = c->x = wa->x; |
364 c->ty = c->y = wa->y; |
370 c->ty = c->y = wa->y; |
368 c->border = 1; |
374 c->border = 1; |
369 c->proto = win_proto(c->win); |
375 c->proto = win_proto(c->win); |
370 update_size(c); |
376 update_size(c); |
371 XSelectInput(dpy, c->win, |
377 XSelectInput(dpy, c->win, |
372 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
378 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
373 XGetTransientForHint(dpy, c->win, &c->trans); |
379 XGetTransientForHint(dpy, c->win, &trans); |
374 twa.override_redirect = 1; |
380 twa.override_redirect = 1; |
375 twa.background_pixmap = ParentRelative; |
381 twa.background_pixmap = ParentRelative; |
376 twa.event_mask = ExposureMask; |
382 twa.event_mask = ExposureMask; |
377 |
383 |
378 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, |
384 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, |
394 GrabModeAsync, GrabModeSync, None, None); |
400 GrabModeAsync, GrabModeSync, None, None); |
395 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, |
401 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, |
396 GrabModeAsync, GrabModeSync, None, None); |
402 GrabModeAsync, GrabModeSync, None, None); |
397 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
403 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
398 GrabModeAsync, GrabModeSync, None, None); |
404 GrabModeAsync, GrabModeSync, None, None); |
|
405 |
|
406 if(!c->floating) |
|
407 c->floating = trans |
|
408 || ((c->maxw == c->minw) && (c->maxh == c->minh)); |
|
409 |
399 arrange(NULL); |
410 arrange(NULL); |
400 if(c->tags[tsel]) |
411 if(c->tags[tsel]) |
401 focus(c); |
412 focus(c); |
402 else |
413 else |
403 ban_client(c); |
414 ban_client(c); |