Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dwm - Google style-bar
- =========================
- static void drawbar(Monitor *m);
- + static void drawborder(unsigned long col[ColLast]);
- void
- drawbar(Monitor *m) {
- int x;
- unsigned int i, occ = 0, urg = 0;
- - unsigned long *col;
- + unsigned long *col, *ltcol;
- Client *c;
- for(c = m->clients; c; c = c->next) {
- occ |= c->tags;
- if(c->isurgent) urg |= c->tags;
- }
- dc.x = 0;
- + dc.w = m->ww;
- + drawborder(dc.colors[0]);
- // draw tag names
- for(i = 0; i < LENGTH(tags); i++) {
- dc.w = TEXTW(tags[i]);
- col = m->tagset[m->seltags] & 1 << i ? dc.colors[1] : dc.colors[0];
- + ltcol = occ & 1 << i || m->tagset[m->seltags] & 1 << i ? dc.colors[0] : dc.colors[2];
- + drawtext(tags[i], ltcol, urg & 1 << i);
- + drawborder(col);
- dc.x += dc.w;
- XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
- XSync(dpy, False);
- }
- +
- + void
- + drawborder(unsigned long col[ColLast]){
- + XGCValues gcv;
- + XRectangle r = {dc.x, dc.y, dc.w, 2 };
- +
- + gcv.foreground = col[ColBorder];
- + XChangeGC(dpy, dc.gc, GCForeground, &gcv);
- + XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
- + }
- void
- setup(void) {
- XSetWindowAttributes wa;
- /* clean up any zombies immediately */
- sigchld(0);
- /* init screen */
- screen = DefaultScreen(dpy);
- root = RootWindow(dpy, screen);
- initfont(font);
- sw = DisplayWidth(dpy, screen);
- sh = DisplayHeight(dpy, screen);
- - bh = dc.h = dc.font.height + 2;
- + bh = dc.h = dc.font.height + 6;
- }
- void
- drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
- char buf[256];
- olen = strlen(text);
- h = dc.font.ascent + dc.font.descent;
- - y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
- + y = dc.y + 2 (dc.h / 2) - (h / 2) + dc.font.ascent;
- x = dc.x + (h / 2);
- /* shorten text if necessary */
- for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement