comparison client.c @ 32:082c75b937b5

removed unnecessary crap
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 01:30:55 +0200
parents 386649deb651
children e90449e03167
comparison
equal deleted inserted replaced
31:386649deb651 32:082c75b937b5
5 5
6 #include <math.h> 6 #include <math.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 10 #include <X11/Xutil.h>
11 #include "util.h" 11
12 #include "wm.h" 12 #include "wm.h"
13 13
14 void (*arrange)(void *aux); 14 void (*arrange)(void *aux);
15 15
16 void 16 void
17 max(void *aux) 17 max(void *aux)
18 { 18 {
19 if(!stack) 19 if(!stack)
20 return; 20 return;
21 stack->x = sx; 21 stack->x = sx;
22 stack->y = bh; 22 stack->y = sy;
23 stack->w = sw - 2 * stack->border; 23 stack->w = sw - 2 * stack->border;
24 stack->h = sh - bh - 2 * stack->border; 24 stack->h = sh - 2 * stack->border;
25 resize(stack); 25 resize(stack);
26 discard_events(EnterWindowMask); 26 discard_events(EnterWindowMask);
27 } 27 }
28 28
29 void 29 void
57 cols = rows + 1; 57 cols = rows + 1;
58 else 58 else
59 cols = rows; 59 cols = rows;
60 60
61 gw = (sw - 2) / cols; 61 gw = (sw - 2) / cols;
62 gh = (sh - bh - 2) / rows; 62 gh = (sh - 2) / rows;
63 63
64 for(i = j = 0, c = clients; c; c = c->next) { 64 for(i = j = 0, c = clients; c; c = c->next) {
65 c->x = i * gw; 65 c->x = i * gw;
66 c->y = j * gh + bh; 66 c->y = j * gh;
67 c->w = gw; 67 c->w = gw;
68 c->h = gh; 68 c->h = gh;
69 resize(c); 69 resize(c);
70 if(++i == cols) { 70 if(++i == cols) {
71 j++; 71 j++;
87 c = stack->snext ? stack->snext : stack; 87 c = stack->snext ? stack->snext : stack;
88 else if(!strncmp(arg, "prev", 5)) 88 else if(!strncmp(arg, "prev", 5))
89 for(c = stack; c && c->snext; c = c->snext); 89 for(c = stack; c && c->snext; c = c->snext);
90 if(!c) 90 if(!c)
91 c = stack; 91 c = stack;
92 raise(c); 92 craise(c);
93 focus(c); 93 focus(c);
94 } 94 }
95 95
96 void 96 void
97 kill(void *aux) 97 ckill(void *aux)
98 { 98 {
99 Client *c = stack; 99 Client *c = stack;
100 100
101 if(!c) 101 if(!c)
102 return; 102 return;
112 int i; 112 int i;
113 113
114 c->tw = 0; 114 c->tw = 0;
115 for(i = 0; i < TLast; i++) 115 for(i = 0; i < TLast; i++)
116 if(c->tags[i]) 116 if(c->tags[i])
117 c->tw += textw(&brush.font, c->tags[i]) + bh; 117 c->tw += textw(&brush.font, c->tags[i]) + brush.font.height;
118 c->tw += textw(&brush.font, c->name) + bh; 118 c->tw += textw(&brush.font, c->name) + brush.font.height;
119 if(c->tw > c->w) 119 if(c->tw > c->w)
120 c->tw = c->w + 2; 120 c->tw = c->w + 2;
121 c->tx = c->x + c->w - c->tw + 2; 121 c->tx = c->x + c->w - c->tw + 2;
122 c->ty = c->y; 122 c->ty = c->y;
123 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); 123 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
188 else 188 else
189 c->grav = NorthWestGravity; 189 c->grav = NorthWestGravity;
190 } 190 }
191 191
192 void 192 void
193 raise(Client *c) 193 craise(Client *c)
194 { 194 {
195 XRaiseWindow(dpy, c->win); 195 XRaiseWindow(dpy, c->win);
196 XRaiseWindow(dpy, c->title); 196 XRaiseWindow(dpy, c->title);
197 } 197 }
198 198
232 232
233 c = emallocz(sizeof(Client)); 233 c = emallocz(sizeof(Client));
234 c->win = w; 234 c->win = w;
235 c->tx = c->x = wa->x; 235 c->tx = c->x = wa->x;
236 c->ty = c->y = wa->y; 236 c->ty = c->y = wa->y;
237 if(c->y < bh)
238 c->ty = c->y += bh;
239 c->tw = c->w = wa->width; 237 c->tw = c->w = wa->width;
240 c->h = wa->height; 238 c->h = wa->height;
241 c->th = bh; 239 c->th = th;
242 c->border = 1; 240 c->border = 1;
243 update_size(c); 241 update_size(c);
244 XSetWindowBorderWidth(dpy, c->win, 1); 242 XSetWindowBorderWidth(dpy, c->win, 1);
245 XSetWindowBorder(dpy, c->win, brush.border); 243 XSetWindowBorder(dpy, c->win, brush.border);
246 XSelectInput(dpy, c->win, 244 XSelectInput(dpy, c->win,
377 375
378 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 376 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
379 XDestroyWindow(dpy, c->title); 377 XDestroyWindow(dpy, c->title);
380 378
381 for(l=&clients; *l && *l != c; l=&(*l)->next); 379 for(l=&clients; *l && *l != c; l=&(*l)->next);
382 eassert(*l == c);
383 *l = c->next; 380 *l = c->next;
384 for(l=&stack; *l && *l != c; l=&(*l)->snext); 381 for(l=&stack; *l && *l != c; l=&(*l)->snext);
385 eassert(*l == c);
386 *l = c->snext; 382 *l = c->snext;
387 free(c); 383 free(c);
388 384
389 XFlush(dpy); 385 XFlush(dpy);
390 XSetErrorHandler(error_handler); 386 XSetErrorHandler(error_handler);
416 412
417 void 413 void
418 draw_client(Client *c) 414 draw_client(Client *c)
419 { 415 {
420 int i; 416 int i;
421 if(c == stack) { 417 if(c == stack)
422 draw_bar(); 418 return;
423 return;
424 }
425 419
426 brush.x = brush.y = 0; 420 brush.x = brush.y = 0;
427 brush.h = c->th; 421 brush.h = c->th;
428 422
429 brush.w = 0; 423 brush.w = 0;
430 for(i = 0; i < TLast; i++) { 424 for(i = 0; i < TLast; i++) {
431 if(c->tags[i]) { 425 if(c->tags[i]) {
432 brush.x += brush.w; 426 brush.x += brush.w;
433 brush.w = textw(&brush.font, c->tags[i]) + bh; 427 brush.w = textw(&brush.font, c->tags[i]) + brush.font.height;
434 draw(dpy, &brush, True, c->tags[i]); 428 draw(dpy, &brush, True, c->tags[i]);
435 } 429 }
436 } 430 }
437 brush.x += brush.w; 431 brush.x += brush.w;
438 brush.w = textw(&brush.font, c->name) + bh; 432 brush.w = textw(&brush.font, c->name) + brush.font.height;
439 draw(dpy, &brush, True, c->name); 433 draw(dpy, &brush, True, c->name);
440 XCopyArea(dpy, brush.drawable, c->title, brush.gc, 434 XCopyArea(dpy, brush.drawable, c->title, brush.gc,
441 0, 0, c->tw, c->th, 0, 0); 435 0, 0, c->tw, c->th, 0, 0);
442 XFlush(dpy); 436 XFlush(dpy);
443 } 437 }