2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
13 #define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask)
16 update_name(Client *c)
24 XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
26 XGetWMName(dpy, c->win, &name);
29 if(name.encoding == XA_STRING)
30 strncpy(c->name, (char *)name.value, sizeof(c->name));
32 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
35 strncpy(c->name, *list, sizeof(c->name));
36 XFreeStringList(list);
47 update_size(Client *c)
51 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
53 c->flags = size.flags;
54 c->basew = size.base_width;
55 c->baseh = size.base_height;
56 c->incw = size.width_inc;
57 c->inch = size.height_inc;
58 c->maxw = size.max_width;
59 c->maxh = size.max_height;
60 c->minw = size.min_width;
61 c->minh = size.min_height;
68 for(l=&stack; *l && *l != c; l=&(*l)->snext);
73 XRaiseWindow(dpy, c->win);
74 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
79 manage(Window w, XWindowAttributes *wa)
82 XSetWindowAttributes twa;
84 c = emallocz(sizeof(Client));
91 XSetWindowBorderWidth(dpy, c->win, 1);
92 XSelectInput(dpy, c->win, CLIENT_MASK);
93 XGetTransientForHint(dpy, c->win, &c->trans);
95 twa.override_redirect = 1;
96 twa.background_pixmap = ParentRelative;
97 twa.event_mask = ExposureMask;
99 c->title = XCreateWindow(dpy, root, c->x, c->y, c->w, barrect.height,
100 0, DefaultDepth(dpy, screen), CopyFromParent,
101 DefaultVisual(dpy, screen),
102 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
104 for(l=&clients; *l; l=&(*l)->next);
105 c->next = *l; /* *l == nil */
109 XMapWindow(dpy, c->win);
110 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
111 GrabModeAsync, GrabModeSync, None, None);
112 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
113 GrabModeAsync, GrabModeSync, None, None);
114 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
115 GrabModeAsync, GrabModeSync, None, None);
124 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
125 e.type = ConfigureNotify;
134 e.override_redirect = False;
135 XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
136 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
137 XSelectInput(dpy, c->win, CLIENT_MASK);
142 dummy_error_handler(Display *dpy, XErrorEvent *error)
153 XSetErrorHandler(dummy_error_handler);
155 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
156 XUnmapWindow(dpy, c->win);
157 XDestroyWindow(dpy, c->title);
159 for(l=&clients; *l && *l != c; l=&(*l)->next);
162 for(l=&stack; *l && *l != c; l=&(*l)->snext);
168 XSetErrorHandler(error_handler);
170 discard_events(EnterWindowMask);
180 for(c = clients; c; c = c->next)
187 draw_client(Client *c)