1 /* Copyright (c) 1994-1996 David Hogan, see README for licence details */
16 setactive(Client *c, int on)
18 /* dbg("setactive client %x %d", c->window, c->on); */
20 if(c->parent == c->screen->root)
24 XUngrabButton(dpy, AnyButton, AnyModifier, c->parent);
25 XSetInputFocus(dpy, c->window, RevertToPointerRoot, timestamp());
26 if(c->proto & Ptakefocus)
27 sendcmessage(c->window, wm_protocols, wm_take_focus, 0, 1);
30 if(c->proto & Plosefocus)
31 sendcmessage(c->window, wm_protocols, wm_lose_focus, 0, 1);
32 XGrabButton(dpy, AnyButton, AnyModifier, c->parent, False,
33 ButtonMask, GrabModeAsync, GrabModeSync, None, None);
39 draw_border(Client *c, int active)
45 pixel = c->screen->activeholdborder;
47 pixel = c->screen->activeborder;
50 pixel = c->screen->inactiveholdborder;
52 pixel = c->screen->inactiveborder;
55 if(debug) fprintf(stderr, "draw_border %p pixel %ld active %d hold %d\n", (void*)c, pixel, active, c->hold);
56 XSetWindowBackground(dpy, c->parent, pixel);
57 XClearWindow(dpy, c->parent);
66 fprintf(stderr, "rio: active(c==0)\n");
72 setactive(current, 0);
73 if(current->screen != c->screen)
74 cmapnofocus(current->screen);
77 for(cc = clients; cc; cc = cc->next)
79 cc->revert = c->revert;
81 while(c->revert && !normal(c->revert))
82 c->revert = c->revert->revert;
95 XSetWindowAttributes attr;
99 setactive(current, 0);
100 for(c = current->revert; c; c = c->revert)
105 cmapnofocus(current->screen);
106 /* if no candidates to revert to, fall through */
110 mask = CWOverrideRedirect/*|CWColormap*/;
111 attr.override_redirect = 1;
112 /* attr.colormap = screens[0].def_cmap;*/
113 w = XCreateWindow(dpy, screens[0].root, 0, 0, 1, 1, 0,
114 0 /*screens[0].depth*/, InputOnly, screens[0].vis, mask, &attr);
117 XSetInputFocus(dpy, w, RevertToPointerRoot, timestamp());
126 for(cc = *l; cc; cc = *l){
135 fprintf(stderr, "rio: %p not on client list in top()\n", (void*)c);
139 getclient(Window w, int create)
143 if(w == 0 || getscreen(w))
146 for(c = clients; c; c = c->next)
147 if(c->window == w || c->parent == w)
153 c = (Client *)malloc(sizeof(Client));
154 memset(c, 0, sizeof(Client));
156 /* c->parent will be set by the caller */
159 c->state = WithdrawnState;
162 c->label = c->class = 0;
180 for(cc = current; cc && cc->revert; cc = cc->revert)
182 cc->revert = cc->revert->revert;
186 for(cc = clients; cc && cc->next; cc = cc->next)
188 cc->next = cc->next->next;
193 if(c->parent != c->screen->root)
194 XDestroyWindow(dpy, c->parent);
196 c->parent = c->window = None; /* paranoia */
202 if(current->screen != c->screen)
203 cmapnofocus(c->screen);
204 setactive(current, 1);
207 if(c->ncmapwins != 0){
208 XFree((char *)c->cmapwins);
209 free((char *)c->wmcmaps);
212 XFree((char*) c->iconname);
214 XFree((char*) c->name);
216 XFree((char*) c->instance);
218 XFree((char*) c->class);
219 memset(c, 0, sizeof(Client)); /* paranoia */
231 for(c = current; c; c = c->revert){
232 fprintf(stderr, "%s(%x:%d)", c->label ? c->label : "?", (int)c->window, c->state);
236 fprintf(stderr, " -> ");
239 fprintf(stderr, "empty");
240 fprintf(stderr, "\n");
248 for(c = clients; c; c = c->next)
249 fprintf(stderr, "w 0x%x parent 0x%x @ (%d, %d)\n", (int)c->window, (int)c->parent, c->x, c->y);
258 if(clients == 0 || clients->next == 0)
261 /*for(c=clients; c->next; c=c->next) */
263 for(l=&clients; (*l)->next; l=&(*l)->next)
269 XMapRaised(dpy, c->parent);
274 for(l=&clients; *l; l=&(*l)->next)
279 XLowerWindow(dpy, c->window);
281 /* XMapRaised(dpy, clients->parent); */
283 /* active(clients); */