implemented urgent hint handling (with multihead support)
This commit is contained in:
parent
c2c54cc0fa
commit
012710a3ce
48
dwm.c
48
dwm.c
|
@ -68,7 +68,7 @@ struct Client {
|
||||||
int minax, maxax, minay, maxay;
|
int minax, maxax, minay, maxay;
|
||||||
long flags;
|
long flags;
|
||||||
unsigned int border, oldborder;
|
unsigned int border, oldborder;
|
||||||
Bool isbanned, isfixed, isfloating;
|
Bool isbanned, isfixed, isfloating, isurgent;
|
||||||
Bool *tags;
|
Bool *tags;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *prev;
|
Client *prev;
|
||||||
|
@ -146,7 +146,7 @@ void detach(Client *c);
|
||||||
void detachstack(Client *c);
|
void detachstack(Client *c);
|
||||||
void drawbar(void);
|
void drawbar(void);
|
||||||
void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]);
|
void drawsquare(Monitor *, Bool filled, Bool empty, unsigned long col[ColLast]);
|
||||||
void drawtext(Monitor *, const char *text, unsigned long col[ColLast]);
|
void drawtext(Monitor *, const char *text, unsigned long col[ColLast], Bool invert);
|
||||||
void *emallocz(unsigned int size);
|
void *emallocz(unsigned int size);
|
||||||
void enternotify(XEvent *e);
|
void enternotify(XEvent *e);
|
||||||
void eprint(const char *errstr, ...);
|
void eprint(const char *errstr, ...);
|
||||||
|
@ -166,6 +166,7 @@ unsigned int idxoftag(const char *tag);
|
||||||
void initfont(Monitor*, const char *fontstr);
|
void initfont(Monitor*, const char *fontstr);
|
||||||
Bool isoccupied(Monitor *m, unsigned int t);
|
Bool isoccupied(Monitor *m, unsigned int t);
|
||||||
Bool isprotodel(Client *c);
|
Bool isprotodel(Client *c);
|
||||||
|
Bool isurgent(int monitor, unsigned int t);
|
||||||
Bool isvisible(Client *c, int monitor);
|
Bool isvisible(Client *c, int monitor);
|
||||||
void keypress(XEvent *e);
|
void keypress(XEvent *e);
|
||||||
void killclient(const char *arg);
|
void killclient(const char *arg);
|
||||||
|
@ -201,6 +202,7 @@ void unmapnotify(XEvent *e);
|
||||||
void updatebarpos(Monitor *m);
|
void updatebarpos(Monitor *m);
|
||||||
void updatesizehints(Client *c);
|
void updatesizehints(Client *c);
|
||||||
void updatetitle(Client *c);
|
void updatetitle(Client *c);
|
||||||
|
void updatewmhints(Client *c);
|
||||||
void view(const char *arg);
|
void view(const char *arg);
|
||||||
void viewprevtag(const char *arg); /* views previous selected tags */
|
void viewprevtag(const char *arg); /* views previous selected tags */
|
||||||
int xerror(Display *dpy, XErrorEvent *ee);
|
int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
@ -573,17 +575,17 @@ drawbar(void) {
|
||||||
for(j = 0; j < LENGTH(tags); j++) {
|
for(j = 0; j < LENGTH(tags); j++) {
|
||||||
m->dc.w = textw(m, tags[j]);
|
m->dc.w = textw(m, tags[j]);
|
||||||
if(m->seltags[j]) {
|
if(m->seltags[j]) {
|
||||||
drawtext(m, tags[j], m->dc.sel);
|
drawtext(m, tags[j], m->dc.sel, isurgent(i, j));
|
||||||
drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.sel);
|
drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.sel);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
drawtext(m, tags[j], m->dc.norm);
|
drawtext(m, tags[j], m->dc.norm, isurgent(i, j));
|
||||||
drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.norm);
|
drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, isoccupied(m, j), m->dc.norm);
|
||||||
}
|
}
|
||||||
m->dc.x += m->dc.w;
|
m->dc.x += m->dc.w;
|
||||||
}
|
}
|
||||||
m->dc.w = blw;
|
m->dc.w = blw;
|
||||||
drawtext(m, m->layout->symbol, m->dc.norm);
|
drawtext(m, m->layout->symbol, m->dc.norm, False);
|
||||||
x = m->dc.x + m->dc.w;
|
x = m->dc.x + m->dc.w;
|
||||||
m->dc.w = textw(m, stext);
|
m->dc.w = textw(m, stext);
|
||||||
m->dc.x = m->sw - m->dc.w;
|
m->dc.x = m->sw - m->dc.w;
|
||||||
|
@ -591,15 +593,15 @@ drawbar(void) {
|
||||||
m->dc.x = x;
|
m->dc.x = x;
|
||||||
m->dc.w = m->sw - x;
|
m->dc.w = m->sw - x;
|
||||||
}
|
}
|
||||||
drawtext(m, stext, m->dc.norm);
|
drawtext(m, stext, m->dc.norm, False);
|
||||||
if((m->dc.w = m->dc.x - x) > bh) {
|
if((m->dc.w = m->dc.x - x) > bh) {
|
||||||
m->dc.x = x;
|
m->dc.x = x;
|
||||||
if(sel && sel->monitor == selmonitor) {
|
if(sel && sel->monitor == selmonitor) {
|
||||||
drawtext(m, sel->name, m->dc.sel);
|
drawtext(m, sel->name, m->dc.sel, False);
|
||||||
drawsquare(m, False, sel->isfloating, m->dc.sel);
|
drawsquare(m, False, sel->isfloating, m->dc.sel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
drawtext(m, NULL, m->dc.norm);
|
drawtext(m, NULL, m->dc.norm, False);
|
||||||
}
|
}
|
||||||
XCopyArea(dpy, m->dc.drawable, m->barwin, m->dc.gc, 0, 0, m->sw, bh, 0, 0);
|
XCopyArea(dpy, m->dc.drawable, m->barwin, m->dc.gc, 0, 0, m->sw, bh, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -628,13 +630,13 @@ drawsquare(Monitor *m, Bool filled, Bool empty, unsigned long col[ColLast]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawtext(Monitor *m, const char *text, unsigned long col[ColLast]) {
|
drawtext(Monitor *m, const char *text, unsigned long col[ColLast], Bool invert) {
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
unsigned int len, olen;
|
unsigned int len, olen;
|
||||||
XRectangle r = { m->dc.x, m->dc.y, m->dc.w, m->dc.h };
|
XRectangle r = { m->dc.x, m->dc.y, m->dc.w, m->dc.h };
|
||||||
|
|
||||||
XSetForeground(dpy, m->dc.gc, col[ColBG]);
|
XSetForeground(dpy, m->dc.gc, col[invert ? ColFG : ColBG]);
|
||||||
XFillRectangles(dpy, m->dc.drawable, m->dc.gc, &r, 1);
|
XFillRectangles(dpy, m->dc.drawable, m->dc.gc, &r, 1);
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
|
@ -660,7 +662,7 @@ drawtext(Monitor *m, const char *text, unsigned long col[ColLast]) {
|
||||||
}
|
}
|
||||||
if(w > m->dc.w)
|
if(w > m->dc.w)
|
||||||
return; /* too long */
|
return; /* too long */
|
||||||
XSetForeground(dpy, m->dc.gc, col[ColFG]);
|
XSetForeground(dpy, m->dc.gc, col[invert ? ColBG : ColFG]);
|
||||||
if(m->dc.font.set)
|
if(m->dc.font.set)
|
||||||
XmbDrawString(dpy, m->dc.drawable, m->dc.font.set, m->dc.gc, x, y, buf, len);
|
XmbDrawString(dpy, m->dc.drawable, m->dc.font.set, m->dc.gc, x, y, buf, len);
|
||||||
else
|
else
|
||||||
|
@ -998,6 +1000,16 @@ isprotodel(Client *c) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
isurgent(int monitor, unsigned int t) {
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for(c = clients; c; c = c->next)
|
||||||
|
if(c->monitor == monitor && c->isurgent && c->tags[t])
|
||||||
|
return True;
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
isvisible(Client *c, int monitor) {
|
isvisible(Client *c, int monitor) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -1215,6 +1227,10 @@ propertynotify(XEvent *e) {
|
||||||
case XA_WM_NORMAL_HINTS:
|
case XA_WM_NORMAL_HINTS:
|
||||||
updatesizehints(c);
|
updatesizehints(c);
|
||||||
break;
|
break;
|
||||||
|
case XA_WM_HINTS:
|
||||||
|
updatewmhints(c);
|
||||||
|
drawbar();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
||||||
updatetitle(c);
|
updatetitle(c);
|
||||||
|
@ -1916,6 +1932,16 @@ updatetitle(Client *c) {
|
||||||
gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
|
gettextprop(c->win, wmatom[WMName], c->name, sizeof c->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
updatewmhints(Client *c) {
|
||||||
|
XWMHints *wmh;
|
||||||
|
|
||||||
|
if((wmh = XGetWMHints(dpy, c->win))) {
|
||||||
|
c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
|
||||||
|
XFree(wmh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* There's no way to check accesses to destroyed windows, thus those cases are
|
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
* default error handler, which may call exit. */
|
* default error handler, which may call exit. */
|
||||||
|
|
Loading…
Reference in a new issue