66 int x, y, w, h; |
66 int x, y, w, h; |
67 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
67 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
68 int minax, maxax, minay, maxay; |
68 int minax, maxax, minay, maxay; |
69 long flags; |
69 long flags; |
70 unsigned int border, oldborder; |
70 unsigned int border, oldborder; |
71 Bool isbanned, isfixed, isfloating; |
71 Bool isbanned, isfixed, isfloating, isurgent; |
72 Bool *tags; |
72 Bool *tags; |
73 Client *next; |
73 Client *next; |
74 Client *prev; |
74 Client *prev; |
75 Client *snext; |
75 Client *snext; |
76 Window win; |
76 Window win; |
144 void destroynotify(XEvent *e); |
144 void destroynotify(XEvent *e); |
145 void detach(Client *c); |
145 void detach(Client *c); |
146 void detachstack(Client *c); |
146 void detachstack(Client *c); |
147 void drawbar(void); |
147 void drawbar(void); |
148 void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]); |
148 void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]); |
149 void drawtext(Monitor *, const char *text, unsigned long col[ColLast]); |
149 void drawtext(Monitor *, const char *text, unsigned long col[ColLast], Bool invert); |
150 void *emallocz(unsigned int size); |
150 void *emallocz(unsigned int size); |
151 void enternotify(XEvent *e); |
151 void enternotify(XEvent *e); |
152 void eprint(const char *errstr, ...); |
152 void eprint(const char *errstr, ...); |
153 void expose(XEvent *e); |
153 void expose(XEvent *e); |
154 void floating(void); /* default floating layout */ |
154 void floating(void); /* default floating layout */ |
164 void grabkeys(void); |
164 void grabkeys(void); |
165 unsigned int idxoftag(const char *tag); |
165 unsigned int idxoftag(const char *tag); |
166 void initfont(Monitor*, const char *fontstr); |
166 void initfont(Monitor*, const char *fontstr); |
167 Bool isoccupied(Monitor *m, unsigned int t); |
167 Bool isoccupied(Monitor *m, unsigned int t); |
168 Bool isprotodel(Client *c); |
168 Bool isprotodel(Client *c); |
|
169 Bool isurgent(int monitor, unsigned int t); |
169 Bool isvisible(Client *c, int monitor); |
170 Bool isvisible(Client *c, int monitor); |
170 void keypress(XEvent *e); |
171 void keypress(XEvent *e); |
171 void killclient(const char *arg); |
172 void killclient(const char *arg); |
172 void manage(Window w, XWindowAttributes *wa); |
173 void manage(Window w, XWindowAttributes *wa); |
173 void mappingnotify(XEvent *e); |
174 void mappingnotify(XEvent *e); |
199 void unmanage(Client *c); |
200 void unmanage(Client *c); |
200 void unmapnotify(XEvent *e); |
201 void unmapnotify(XEvent *e); |
201 void updatebarpos(Monitor *m); |
202 void updatebarpos(Monitor *m); |
202 void updatesizehints(Client *c); |
203 void updatesizehints(Client *c); |
203 void updatetitle(Client *c); |
204 void updatetitle(Client *c); |
|
205 void updatewmhints(Client *c); |
204 void view(const char *arg); |
206 void view(const char *arg); |
205 void viewprevtag(const char *arg); /* views previous selected tags */ |
207 void viewprevtag(const char *arg); /* views previous selected tags */ |
206 int xerror(Display *dpy, XErrorEvent *ee); |
208 int xerror(Display *dpy, XErrorEvent *ee); |
207 int xerrordummy(Display *dsply, XErrorEvent *ee); |
209 int xerrordummy(Display *dsply, XErrorEvent *ee); |
208 int xerrorstart(Display *dsply, XErrorEvent *ee); |
210 int xerrorstart(Display *dsply, XErrorEvent *ee); |
571 Monitor *m = &monitors[i]; |
573 Monitor *m = &monitors[i]; |
572 m->dc.x = 0; |
574 m->dc.x = 0; |
573 for(j = 0; j < LENGTH(tags); j++) { |
575 for(j = 0; j < LENGTH(tags); j++) { |
574 m->dc.w = textw(m, tags[j]); |
576 m->dc.w = textw(m, tags[j]); |
575 if(m->seltags[j]) { |
577 if(m->seltags[j]) { |
576 drawtext(m, tags[j], m->dc.sel); |
578 drawtext(m, tags[j], m->dc.sel, isurgent(i, j)); |
577 drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.sel); |
579 drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.sel); |
578 } |
580 } |
579 else { |
581 else { |
580 drawtext(m, tags[j], m->dc.norm); |
582 drawtext(m, tags[j], m->dc.norm, isurgent(i, j)); |
581 drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.norm); |
583 drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.norm); |
582 } |
584 } |
583 m->dc.x += m->dc.w; |
585 m->dc.x += m->dc.w; |
584 } |
586 } |
585 m->dc.w = blw; |
587 m->dc.w = blw; |
586 drawtext(m, m->layout->symbol, m->dc.norm); |
588 drawtext(m, m->layout->symbol, m->dc.norm, False); |
587 x = m->dc.x + m->dc.w; |
589 x = m->dc.x + m->dc.w; |
588 m->dc.w = textw(m, stext); |
590 m->dc.w = textw(m, stext); |
589 m->dc.x = m->sw - m->dc.w; |
591 m->dc.x = m->sw - m->dc.w; |
590 if(m->dc.x < x) { |
592 if(m->dc.x < x) { |
591 m->dc.x = x; |
593 m->dc.x = x; |
592 m->dc.w = m->sw - x; |
594 m->dc.w = m->sw - x; |
593 } |
595 } |
594 drawtext(m, stext, m->dc.norm); |
596 drawtext(m, stext, m->dc.norm, False); |
595 if((m->dc.w = m->dc.x - x) > bh) { |
597 if((m->dc.w = m->dc.x - x) > bh) { |
596 m->dc.x = x; |
598 m->dc.x = x; |
597 if(sel && sel->monitor == selmonitor) { |
599 if(sel && sel->monitor == selmonitor) { |
598 drawtext(m, sel->name, m->dc.sel); |
600 drawtext(m, sel->name, m->dc.sel, False); |
599 drawsquare(m, False, sel->isfloating, m->dc.sel); |
601 drawsquare(m, False, sel->isfloating, m->dc.sel); |
600 } |
602 } |
601 else |
603 else |
602 drawtext(m, NULL, m->dc.norm); |
604 drawtext(m, NULL, m->dc.norm, False); |
603 } |
605 } |
604 XCopyArea(dpy, m->dc.drawable, m->barwin, m->dc.gc, 0, 0, m->sw, bh, 0, 0); |
606 XCopyArea(dpy, m->dc.drawable, m->barwin, m->dc.gc, 0, 0, m->sw, bh, 0, 0); |
605 XSync(dpy, False); |
607 XSync(dpy, False); |
606 } |
608 } |
607 } |
609 } |
626 XDrawRectangles(dpy, m->dc.drawable, m->dc.gc, &r, 1); |
628 XDrawRectangles(dpy, m->dc.drawable, m->dc.gc, &r, 1); |
627 } |
629 } |
628 } |
630 } |
629 |
631 |
630 void |
632 void |
631 drawtext(Monitor *m, const char *text, unsigned long col[ColLast]) { |
633 drawtext(Monitor *m, const char *text, unsigned long col[ColLast], Bool invert) { |
632 int x, y, w, h; |
634 int x, y, w, h; |
633 static char buf[256]; |
635 static char buf[256]; |
634 unsigned int len, olen; |
636 unsigned int len, olen; |
635 XRectangle r = { m->dc.x, m->dc.y, m->dc.w, m->dc.h }; |
637 XRectangle r = { m->dc.x, m->dc.y, m->dc.w, m->dc.h }; |
636 |
638 |
637 XSetForeground(dpy, m->dc.gc, col[ColBG]); |
639 XSetForeground(dpy, m->dc.gc, col[invert ? ColFG : ColBG]); |
638 XFillRectangles(dpy, m->dc.drawable, m->dc.gc, &r, 1); |
640 XFillRectangles(dpy, m->dc.drawable, m->dc.gc, &r, 1); |
639 if(!text) |
641 if(!text) |
640 return; |
642 return; |
641 w = 0; |
643 w = 0; |
642 olen = len = strlen(text); |
644 olen = len = strlen(text); |
658 if(len > 3) |
660 if(len > 3) |
659 buf[len - 3] = '.'; |
661 buf[len - 3] = '.'; |
660 } |
662 } |
661 if(w > m->dc.w) |
663 if(w > m->dc.w) |
662 return; /* too long */ |
664 return; /* too long */ |
663 XSetForeground(dpy, m->dc.gc, col[ColFG]); |
665 XSetForeground(dpy, m->dc.gc, col[invert ? ColBG : ColFG]); |
664 if(m->dc.font.set) |
666 if(m->dc.font.set) |
665 XmbDrawString(dpy, m->dc.drawable, m->dc.font.set, m->dc.gc, x, y, buf, len); |
667 XmbDrawString(dpy, m->dc.drawable, m->dc.font.set, m->dc.gc, x, y, buf, len); |
666 else |
668 else |
667 XDrawString(dpy, m->dc.drawable, m->dc.gc, x, y, buf, len); |
669 XDrawString(dpy, m->dc.drawable, m->dc.gc, x, y, buf, len); |
668 } |
670 } |
1914 updatetitle(Client *c) { |
1930 updatetitle(Client *c) { |
1915 if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) |
1931 if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name)) |
1916 gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name); |
1932 gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name); |
1917 } |
1933 } |
1918 |
1934 |
|
1935 void |
|
1936 updatewmhints(Client *c) { |
|
1937 XWMHints *wmh; |
|
1938 |
|
1939 if((wmh = XGetWMHints(dpy, c->win))) { |
|
1940 c->isurgent = (wmh->flags & XUrgencyHint) ? True : False; |
|
1941 XFree(wmh); |
|
1942 } |
|
1943 } |
|
1944 |
1919 /* There's no way to check accesses to destroyed windows, thus those cases are |
1945 /* There's no way to check accesses to destroyed windows, thus those cases are |
1920 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs |
1946 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs |
1921 * default error handler, which may call exit. */ |
1947 * default error handler, which may call exit. */ |
1922 int |
1948 int |
1923 xerror(Display *dpy, XErrorEvent *ee) { |
1949 xerror(Display *dpy, XErrorEvent *ee) { |