summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranselm@aab <unknown>2008-02-11 20:34:17 +0000
committeranselm@aab <unknown>2008-02-11 20:34:17 +0000
commit012710a3cee6a15e4b8284edb57d39332ddd60b4 (patch)
treeaeb47a7d1a95943de4e0bc56c77b2c2ed1ed2e8e
parentgot initial Xinerama support working, though there is a lot work todo (diff)
downloaddwm-012710a3cee6a15e4b8284edb57d39332ddd60b4.tar.gz
dwm-012710a3cee6a15e4b8284edb57d39332ddd60b4.zip
implemented urgent hint handling (with multihead support)
Diffstat (limited to '')
-rw-r--r--dwm.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/dwm.c b/dwm.c
index a3439bc..5814844 100644
--- a/dwm.c
+++ b/dwm.c
@@ -68,7 +68,7 @@ struct Client {
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;
@@ -146,7 +146,7 @@ void detach(Client *c);
146void detachstack(Client *c); 146void detachstack(Client *c);
147void drawbar(void); 147void drawbar(void);
148void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]); 148void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]);
149void drawtext(Monitor *, const char *text, unsigned long col[ColLast]); 149void drawtext(Monitor *, const char *text, unsigned long col[ColLast], Bool invert);
150void *emallocz(unsigned int size); 150void *emallocz(unsigned int size);
151void enternotify(XEvent *e); 151void enternotify(XEvent *e);
152void eprint(const char *errstr, ...); 152void eprint(const char *errstr, ...);
@@ -166,6 +166,7 @@ unsigned int idxoftag(const char *tag);
166void initfont(Monitor*, const char *fontstr); 166void initfont(Monitor*, const char *fontstr);
167Bool isoccupied(Monitor *m, unsigned int t); 167Bool isoccupied(Monitor *m, unsigned int t);
168Bool isprotodel(Client *c); 168Bool isprotodel(Client *c);
169Bool isurgent(int monitor, unsigned int t);
169Bool isvisible(Client *c, int monitor); 170Bool isvisible(Client *c, int monitor);
170void keypress(XEvent *e); 171void keypress(XEvent *e);
171void killclient(const char *arg); 172void killclient(const char *arg);
@@ -201,6 +202,7 @@ void unmapnotify(XEvent *e);
201void updatebarpos(Monitor *m); 202void updatebarpos(Monitor *m);
202void updatesizehints(Client *c); 203void updatesizehints(Client *c);
203void updatetitle(Client *c); 204void updatetitle(Client *c);
205void updatewmhints(Client *c);
204void view(const char *arg); 206void view(const char *arg);
205void viewprevtag(const char *arg); /* views previous selected tags */ 207void viewprevtag(const char *arg); /* views previous selected tags */
206int xerror(Display *dpy, XErrorEvent *ee); 208int xerror(Display *dpy, XErrorEvent *ee);
@@ -573,17 +575,17 @@ drawbar(void) {
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;
@@ -591,15 +593,15 @@ drawbar(void) {
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);
@@ -628,13 +630,13 @@ drawsquare(Monitor *m, Bool filled, Bool empty, unsigned long col[ColLast]) {
628} 630}
629 631
630void 632void
631drawtext(Monitor *m, const char *text, unsigned long col[ColLast]) { 633drawtext(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;
@@ -660,7 +662,7 @@ drawtext(Monitor *m, const char *text, unsigned long col[ColLast]) {
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
@@ -999,6 +1001,16 @@ isprotodel(Client *c) {
999} 1001}
1000 1002
1001Bool 1003Bool
1004isurgent(int monitor, unsigned int t) {
1005 Client *c;
1006
1007 for(c = clients; c; c = c->next)
1008 if(c->monitor == monitor && c->isurgent && c->tags[t])
1009 return True;
1010 return False;
1011}
1012
1013Bool
1002isvisible(Client *c, int monitor) { 1014isvisible(Client *c, int monitor) {
1003 unsigned int i; 1015 unsigned int i;
1004 1016
@@ -1215,6 +1227,10 @@ propertynotify(XEvent *e) {
1215 case XA_WM_NORMAL_HINTS: 1227 case XA_WM_NORMAL_HINTS:
1216 updatesizehints(c); 1228 updatesizehints(c);
1217 break; 1229 break;
1230 case XA_WM_HINTS:
1231 updatewmhints(c);
1232 drawbar();
1233 break;
1218 } 1234 }
1219 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { 1235 if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
1220 updatetitle(c); 1236 updatetitle(c);
@@ -1916,6 +1932,16 @@ updatetitle(Client *c) {
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
1935void
1936updatewmhints(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. */