- }
-
- if(XGetClassHint(dpy, c->win, &ch)) {
- if(ch.res_class && ch.res_name) {
- for(i = 0; i < len; i++)
- if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class))
- && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance)))
- {
- for(j = 0; j < TLast; j++)
- c->tags[j] = rule[i].tags[j];
- c->floating = rule[i].floating;
- matched = True;
- break;
- }
- }
- if(ch.res_class)
- XFree(ch.res_class);
- if(ch.res_name)
- XFree(ch.res_name);
- }
-
- if(!matched)
- c->tags[tsel] = tags[tsel];
-}
-
-void
-manage(Window w, XWindowAttributes *wa)
-{
- Client *c, **l;
- XSetWindowAttributes twa;
- Window trans;
-
- c = emallocz(sizeof(Client));
- c->win = w;
- c->tx = c->x = wa->x;
- c->ty = c->y = wa->y;
- if(c->y < bh)
- c->ty = c->y += bh;
- c->tw = c->w = wa->width;
- c->h = wa->height;
- c->th = bh;
- c->border = 1;
- c->proto = win_proto(c->win);
- update_size(c);
- XSelectInput(dpy, c->win,
- StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
- XGetTransientForHint(dpy, c->win, &trans);
- twa.override_redirect = 1;
- twa.background_pixmap = ParentRelative;
- twa.event_mask = ExposureMask;
-
- c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
- 0, DefaultDepth(dpy, screen), CopyFromParent,
- DefaultVisual(dpy, screen),
- CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
-
- update_name(c);
- init_tags(c);
-
- for(l = &clients; *l; l = &(*l)->next);
- c->next = *l; /* *l == nil */
- *l = c;
-
- XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
- GrabModeAsync, GrabModeSync, None, None);
-
- if(!c->floating)
- c->floating = trans
- || ((c->maxw == c->minw) && (c->maxh == c->minh));
-
- arrange(NULL);
- /* mapping the window now prevents flicker */
- if(c->tags[tsel]) {
- XMapRaised(dpy, c->win);
- XMapRaised(dpy, c->title);
- focus(c);
- }