comparison client.c @ 123:61490330e90a

cleaned up code
author arg@10ksloc.org
date Thu, 20 Jul 2006 12:18:06 +0200
parents 329fd7dae530
children 75576e44c1d8
comparison
equal deleted inserted replaced
122:f20cea484900 123:61490330e90a
95 95
96 Client * 96 Client *
97 getclient(Window w) 97 getclient(Window w)
98 { 98 {
99 Client *c; 99 Client *c;
100
100 for(c = clients; c; c = c->next) 101 for(c = clients; c; c = c->next)
101 if(c->win == w) 102 if(c->win == w)
102 return c; 103 return c;
103 return NULL; 104 return NULL;
104 } 105 }
105 106
106 Client * 107 Client *
107 getctitle(Window w) 108 getctitle(Window w)
108 { 109 {
109 Client *c; 110 Client *c;
111
110 for(c = clients; c; c = c->next) 112 for(c = clients; c; c = c->next)
111 if(c->title == w) 113 if(c->title == w)
112 return c; 114 return c;
113 return NULL; 115 return NULL;
114 } 116 }
196 void 198 void
197 manage(Window w, XWindowAttributes *wa) 199 manage(Window w, XWindowAttributes *wa)
198 { 200 {
199 int diff; 201 int diff;
200 Client *c; 202 Client *c;
203 Window trans;
201 XSetWindowAttributes twa; 204 XSetWindowAttributes twa;
202 Window trans;
203 205
204 c = emallocz(sizeof(Client)); 206 c = emallocz(sizeof(Client));
205 c->win = w; 207 c->win = w;
206 c->x = c->tx = wa->x; 208 c->x = c->tx = wa->x;
207 c->y = c->ty = wa->y; 209 c->y = c->ty = wa->y;
276 278
277 void 279 void
278 pop(Client *c) 280 pop(Client *c)
279 { 281 {
280 Client **l; 282 Client **l;
283
281 for(l = &clients; *l && *l != c; l = &(*l)->next); 284 for(l = &clients; *l && *l != c; l = &(*l)->next);
282 *l = c->next; 285 *l = c->next;
283 286
284 c->next = clients; /* pop */ 287 c->next = clients; /* pop */
285 clients = c; 288 clients = c;
287 } 290 }
288 291
289 void 292 void
290 resize(Client *c, Bool inc, Corner sticky) 293 resize(Client *c, Bool inc, Corner sticky)
291 { 294 {
295 int bottom = c->y + c->h;
296 int right = c->x + c->w;
292 XConfigureEvent e; 297 XConfigureEvent e;
293 int right = c->x + c->w;
294 int bottom = c->y + c->h;
295 298
296 if(inc) { 299 if(inc) {
297 if(c->incw) 300 if(c->incw)
298 c->w -= (c->w - c->basew) % c->incw; 301 c->w -= (c->w - c->basew) % c->incw;
299 if(c->inch) 302 if(c->inch)
335 } 338 }
336 339
337 void 340 void
338 setsize(Client *c) 341 setsize(Client *c)
339 { 342 {
343 long msize;
340 XSizeHints size; 344 XSizeHints size;
341 long msize; 345
342 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) 346 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
343 size.flags = PSize; 347 size.flags = PSize;
344 c->flags = size.flags; 348 c->flags = size.flags;
345 if(c->flags & PBaseSize) { 349 if(c->flags & PBaseSize) {
346 c->basew = size.base_width; 350 c->basew = size.base_width;
373 } 377 }
374 378
375 void 379 void
376 settitle(Client *c) 380 settitle(Client *c)
377 { 381 {
382 char **list = NULL;
383 int n;
378 XTextProperty name; 384 XTextProperty name;
379 int n;
380 char **list = NULL;
381 385
382 name.nitems = 0; 386 name.nitems = 0;
383 c->name[0] = 0; 387 c->name[0] = 0;
384 XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]); 388 XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]);
385 if(!name.nitems) 389 if(!name.nitems)