2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
14 update_name(Client *c)
22 XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
24 XGetWMName(dpy, c->win, &name);
27 if(name.encoding == XA_STRING)
28 strncpy(c->name, (char *)name.value, sizeof(c->name));
30 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
33 strncpy(c->name, *list, sizeof(c->name));
34 XFreeStringList(list);
48 for(l=&stack; *l && *l != c; l=&(*l)->snext);
53 XRaiseWindow(dpy, c->win);
54 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
59 manage(Window w, XWindowAttributes *wa)
62 XSetWindowAttributes twa;
65 c = emallocz(sizeof(Client));
67 c->r[RFloat].x = wa->x;
68 c->r[RFloat].y = wa->y;
69 c->r[RFloat].width = wa->width;
70 c->r[RFloat].height = wa->height;
71 c->border = wa->border_width;
72 XSetWindowBorderWidth(dpy, c->win, 0);
73 XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
74 XGetTransientForHint(dpy, c->win, &c->trans);
75 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
76 c->size.flags = PSize;
78 (c->size.flags & PMinSize && c->size.flags & PMaxSize
79 && c->size.min_width == c->size.max_width
80 && c->size.min_height == c->size.max_height);
82 twa.override_redirect = 1;
83 twa.background_pixmap = ParentRelative;
84 twa.event_mask = ExposureMask;
86 c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
87 c->r[RFloat].width, barrect.height, 0,
88 DefaultDepth(dpy, screen), CopyFromParent,
89 DefaultVisual(dpy, screen),
90 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
92 for(l=&clients; *l; l=&(*l)->next);
93 c->next = *l; /* *l == nil */
97 XMapWindow(dpy, c->win);
102 dummy_error_handler(Display *dpy, XErrorEvent *error)
113 XSetErrorHandler(dummy_error_handler);
115 XUnmapWindow(dpy, c->win);
116 XDestroyWindow(dpy, c->title);
118 for(l=&clients; *l && *l != c; l=&(*l)->next);
121 for(l=&stack; *l && *l != c; l=&(*l)->snext);
127 XSetErrorHandler(error_handler);
129 flush_events(EnterWindowMask);
139 for(c = clients; c; c = c->next)
146 draw_client(Client *c)