1 /* Copyright (c) 1994-1996 David Hogan, see README for licence details */
16 setactive(Client *c, int on)
18 if (c->parent == c->screen->root) {
19 fprintf(stderr, "rio: bad parent in setactive; dumping core\n");
23 XUngrabButton(dpy, AnyButton, AnyModifier, c->parent);
24 XSetInputFocus(dpy, c->window, RevertToPointerRoot, timestamp());
25 if (c->proto & Ptakefocus)
26 sendcmessage(c->window, wm_protocols, wm_take_focus, 0, 1);
29 if (c->proto & Plosefocus)
30 sendcmessage(c->window, wm_protocols, wm_lose_focus, 0, 1);
31 XGrabButton(dpy, AnyButton, AnyModifier, c->parent, False,
32 ButtonMask, GrabModeAsync, GrabModeSync, None, None);
38 draw_border(Client *c, int active)
44 pixel = c->screen->activeholdborder;
46 pixel = c->screen->activeborder;
49 pixel = c->screen->inactiveholdborder;
51 pixel = c->screen->inactiveborder;
54 if (debug) fprintf(stderr, "draw_border %p pixel %ld active %d hold %d\n", c, pixel, active, c->hold);
55 XSetWindowBackground(dpy, c->parent, pixel);
56 XClearWindow(dpy, c->parent);
65 fprintf(stderr, "rio: active(c==0)\n");
71 setactive(current, 0);
72 if (current->screen != c->screen)
73 cmapnofocus(current->screen);
76 for (cc = clients; cc; cc = cc->next)
78 cc->revert = c->revert;
80 while (c->revert && !normal(c->revert))
81 c->revert = c->revert->revert;
94 XSetWindowAttributes attr;
98 setactive(current, 0);
99 for (c = current->revert; c; c = c->revert)
104 cmapnofocus(current->screen);
105 /* if no candidates to revert to, fall through */
109 mask = CWOverrideRedirect/*|CWColormap*/;
110 attr.override_redirect = 1;
111 /* attr.colormap = screens[0].def_cmap;*/
112 w = XCreateWindow(dpy, screens[0].root, 0, 0, 1, 1, 0,
113 0 /*screens[0].depth*/, InputOnly, screens[0].vis, mask, &attr);
116 XSetInputFocus(dpy, w, RevertToPointerRoot, timestamp());
125 for (cc = *l; cc; cc = *l) {
134 fprintf(stderr, "rio: %p not on client list in top()\n", c);
138 getclient(Window w, int create)
142 if (w == 0 || getscreen(w))
145 for (c = clients; c; c = c->next)
146 if (c->window == w || c->parent == w)
152 c = (Client *)malloc(sizeof(Client));
153 memset(c, 0, sizeof(Client));
155 /* c->parent will be set by the caller */
158 c->state = WithdrawnState;
161 c->label = c->class = 0;
179 for (cc = current; cc && cc->revert; cc = cc->revert)
181 cc->revert = cc->revert->revert;
185 for (cc = clients; cc && cc->next; cc = cc->next)
187 cc->next = cc->next->next;
192 if (c->parent != c->screen->root)
193 XDestroyWindow(dpy, c->parent);
195 c->parent = c->window = None; /* paranoia */
201 if (current->screen != c->screen)
202 cmapnofocus(c->screen);
203 setactive(current, 1);
206 if (c->ncmapwins != 0) {
207 XFree((char *)c->cmapwins);
208 free((char *)c->wmcmaps);
210 if (c->iconname != 0)
211 XFree((char*) c->iconname);
213 XFree((char*) c->name);
214 if (c->instance != 0)
215 XFree((char*) c->instance);
217 XFree((char*) c->class);
218 memset(c, 0, sizeof(Client)); /* paranoia */
230 for (c = current; c; c = c->revert) {
231 fprintf(stderr, "%s(%x:%d)", c->label ? c->label : "?", c->window, c->state);
235 fprintf(stderr, " -> ");
238 fprintf(stderr, "empty");
239 fprintf(stderr, "\n");
247 for (c = clients; c; c = c->next)
248 fprintf(stderr, "w 0x%x parent 0x%x @ (%d, %d)\n", c->window, c->parent, c->x, c->y);