comparison client.c @ 57:f005d46462e8

implemented bar for dwm (I miss status text), I plan that status text is read from stdin in dwm
author Anselm R. Garbe <garbeam@wmii.de>
date Fri, 14 Jul 2006 10:07:38 +0200
parents fcbf7213d96f
children 24f9c674d03f
comparison
equal deleted inserted replaced
56:b72b7086c385 57:f005d46462e8
47 max(Arg *arg) 47 max(Arg *arg)
48 { 48 {
49 if(!sel) 49 if(!sel)
50 return; 50 return;
51 sel->x = sx; 51 sel->x = sx;
52 sel->y = sy; 52 sel->y = sy + bh;
53 sel->w = sw - 2 * sel->border; 53 sel->w = sw - 2 * sel->border;
54 sel->h = sh - 2 * sel->border; 54 sel->h = sh - 2 * sel->border - bh;
55 craise(sel); 55 craise(sel);
56 resize(sel, False); 56 resize(sel, False);
57 discard_events(EnterWindowMask); 57 discard_events(EnterWindowMask);
58 } 58 }
59 59
65 tsel = arg->i; 65 tsel = arg->i;
66 arrange(NULL); 66 arrange(NULL);
67 67
68 for(c = clients; c; c = next(c->next)) 68 for(c = clients; c; c = next(c->next))
69 draw_client(c); 69 draw_client(c);
70 draw_bar();
70 } 71 }
71 72
72 void 73 void
73 tappend(Arg *arg) 74 tappend(Arg *arg)
74 { 75 {
129 arrange = tiling; 130 arrange = tiling;
130 for(n = 0, c = clients; c; c = c->next) 131 for(n = 0, c = clients; c; c = c->next)
131 if(c->tags[tsel] && !c->floating) 132 if(c->tags[tsel] && !c->floating)
132 n++; 133 n++;
133 134
134 h = (n > 1) ? sh / (n - 1) : sh; 135 if(n > 1)
136 h = (sh - bh) / (n - 1);
137 else
138 h = sh - bh;
135 139
136 for(i = 0, c = clients; c; c = c->next) { 140 for(i = 0, c = clients; c; c = c->next) {
137 if(c->tags[tsel]) { 141 if(c->tags[tsel]) {
138 if(c->floating) { 142 if(c->floating) {
139 craise(c); 143 craise(c);
140 resize(c, True); 144 resize(c, True);
141 continue; 145 continue;
142 } 146 }
143 if(n == 1) { 147 if(n == 1) {
144 c->x = sx; 148 c->x = sx;
145 c->y = sy; 149 c->y = sy + bh;
146 c->w = sw - 2 * c->border; 150 c->w = sw - 2 * c->border;
147 c->h = sh - 2 * c->border; 151 c->h = sh - 2 * c->border - bh;
148 } 152 }
149 else if(i == 0) { 153 else if(i == 0) {
150 c->x = sx; 154 c->x = sx;
151 c->y = sy; 155 c->y = sy + bh;
152 c->w = mw - 2 * c->border; 156 c->w = mw - 2 * c->border;
153 c->h = sh - 2 * c->border; 157 c->h = sh - 2 * c->border - bh;
154 } 158 }
155 else { 159 else {
156 c->x = sx + mw; 160 c->x = sx + mw;
157 c->y = sy + (i - 1) * h; 161 c->y = sy + (i - 1) * h + bh;
158 c->w = w - 2 * c->border; 162 c->w = w - 2 * c->border;
159 c->h = h - 2 * c->border; 163 c->h = h - 2 * c->border;
160 } 164 }
161 resize(c, False); 165 resize(c, False);
162 i++; 166 i++;
371 375
372 c = emallocz(sizeof(Client)); 376 c = emallocz(sizeof(Client));
373 c->win = w; 377 c->win = w;
374 c->tx = c->x = wa->x; 378 c->tx = c->x = wa->x;
375 c->ty = c->y = wa->y; 379 c->ty = c->y = wa->y;
380 if(c->y < bh)
381 c->ty = c->y += bh;
376 c->tw = c->w = wa->width; 382 c->tw = c->w = wa->width;
377 c->h = wa->height; 383 c->h = wa->height;
378 c->th = th; 384 c->th = bh;
379 c->border = 1; 385 c->border = 1;
380 c->proto = win_proto(c->win); 386 c->proto = win_proto(c->win);
381 update_size(c); 387 update_size(c);
382 XSelectInput(dpy, c->win, 388 XSelectInput(dpy, c->win,
383 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 389 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
568 void 574 void
569 draw_client(Client *c) 575 draw_client(Client *c)
570 { 576 {
571 int i; 577 int i;
572 if(c == sel) { 578 if(c == sel) {
579 draw_bar();
573 XUnmapWindow(dpy, c->title); 580 XUnmapWindow(dpy, c->title);
574 XSetWindowBorder(dpy, c->win, dc.fg); 581 XSetWindowBorder(dpy, c->win, dc.fg);
575 return; 582 return;
576 } 583 }
577 584
578 XSetWindowBorder(dpy, c->win, dc.bg); 585 XSetWindowBorder(dpy, c->win, dc.bg);
579 XMapWindow(dpy, c->title); 586 XMapWindow(dpy, c->title);
580 587
581 dc.x = dc.y = 0; 588 dc.x = dc.y = 0;
582 dc.h = c->th;
583 589
584 dc.w = 0; 590 dc.w = 0;
585 for(i = 0; i < TLast; i++) { 591 for(i = 0; i < TLast; i++) {
586 if(c->tags[i]) { 592 if(c->tags[i]) {
587 dc.x += dc.w; 593 dc.x += dc.w;
588 dc.w = textw(c->tags[i]) + dc.font.height; 594 dc.w = textw(c->tags[i]) + dc.font.height;
589 draw(True, c->tags[i]); 595 drawtext(c->tags[i], True);
590 } 596 }
591 } 597 }
592 dc.x += dc.w; 598 dc.x += dc.w;
593 dc.w = textw(c->name) + dc.font.height; 599 dc.w = textw(c->name) + dc.font.height;
594 draw(True, c->name); 600 drawtext(c->name, True);
595 XCopyArea(dpy, dc.drawable, c->title, dc.gc, 601 XCopyArea(dpy, dc.drawable, c->title, dc.gc,
596 0, 0, c->tw, c->th, 0, 0); 602 0, 0, c->tw, c->th, 0, 0);
597 XFlush(dpy); 603 XFlush(dpy);
598 } 604 }