add systray border
This commit is contained in:
parent
a7ab3e50e6
commit
e9b07a4d70
1 changed files with 23 additions and 19 deletions
42
dwm.c
42
dwm.c
|
|
@ -207,7 +207,7 @@ static void detachstack(Client *c);
|
||||||
static Monitor *dirtomon(int dir);
|
static Monitor *dirtomon(int dir);
|
||||||
static void drawbar(Monitor *m);
|
static void drawbar(Monitor *m);
|
||||||
static void drawbars(void);
|
static void drawbars(void);
|
||||||
static int drawstatusbar(Monitor *m, int bh, char* text);
|
static int drawstatusbar(Monitor *m, int bh, char* text, int stw);
|
||||||
static void enternotify(XEvent *e);
|
static void enternotify(XEvent *e);
|
||||||
static void expose(XEvent *e);
|
static void expose(XEvent *e);
|
||||||
static void focus(Client *c);
|
static void focus(Client *c);
|
||||||
|
|
@ -945,12 +945,12 @@ dirtomon(int dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
drawstatusbar(Monitor *m, int bh, char* stext) {
|
drawstatusbar(Monitor *m, int bh, char* stext, int stw) {
|
||||||
int ret, i, j, w, x, len;
|
int ret, i, j, w, x, len;
|
||||||
short isCode = 0;
|
short isCode = 0;
|
||||||
char *text;
|
char *text;
|
||||||
char *p;
|
char *p;
|
||||||
int mw = m->ww - borderpx * 2;
|
int mw = m->ww;
|
||||||
int th = bh - borderpx * 2;
|
int th = bh - borderpx * 2;
|
||||||
|
|
||||||
len = strlen(stext) + 1 ;
|
len = strlen(stext) + 1 ;
|
||||||
|
|
@ -995,7 +995,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||||
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||||
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||||
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||||
drw_rect(drw, x - 2 * sp, borderpx, w + borderpx - sp * 2, th, 1, 1);
|
drw_rect(drw, x - 2 * sp - stw, borderpx, w + borderpx + stw, th, 1, 1);
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
/* process status text */
|
/* process status text */
|
||||||
|
|
@ -1050,7 +1050,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||||
|
|
||||||
if (!isCode) {
|
if (!isCode) {
|
||||||
w = TEXTW(text, statusfontindex) - lrpad;
|
w = TEXTW(text, statusfontindex) - lrpad;
|
||||||
drw_text(drw, x - 2 * sp, borderpx, w + borderpx, th, 0, text, 0, statusfontindex);
|
drw_text(drw, x - 2 * sp - stw, borderpx, w + borderpx + stw, th, 0, text, 0, statusfontindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
|
@ -1070,18 +1070,18 @@ drawbar(Monitor *m)
|
||||||
unsigned int i, occ = 0, urg = 0;
|
unsigned int i, occ = 0, urg = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
XSetForeground(drw->dpy, drw->gc, clrborder.pixel);
|
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, 0, 0, m->ww, bh);
|
|
||||||
|
|
||||||
if (!m->showbar)
|
if (!m->showbar)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(showsystray && m == systraytomon(m))
|
if(showsystray && m == systraytomon(m))
|
||||||
stw = getsystraywidth();
|
stw = getsystraywidth();
|
||||||
|
|
||||||
|
XSetForeground(drw->dpy, drw->gc, clrborder.pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, 0, 0, m->ww, bh);
|
||||||
|
|
||||||
/* draw status first so it can be overdrawn by tags later */
|
/* draw status first so it can be overdrawn by tags later */
|
||||||
if (m == selmon || 1) { /* status is only drawn on selected monitor */
|
if (m == selmon || 1) { /* status is only drawn on selected monitor */
|
||||||
tw = statusw = m->ww - drawstatusbar(m, bh, stext);
|
tw = statusw = m->ww - drawstatusbar(m, bh, stext, stw);
|
||||||
}
|
}
|
||||||
|
|
||||||
resizebarwin(m);
|
resizebarwin(m);
|
||||||
|
|
@ -1097,7 +1097,7 @@ drawbar(Monitor *m)
|
||||||
continue;
|
continue;
|
||||||
w = TEXTW(tags[i], statusfontindex);
|
w = TEXTW(tags[i], statusfontindex);
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
drw_text(drw, x, y, w , th, lrpad / 2, tags[i], urg & 1 << i, statusfontindex);
|
drw_text(drw, x, y, w, th, lrpad / 2, tags[i], urg & 1 << i, statusfontindex);
|
||||||
if (ulineall || m->tagset[m->seltags] & 1 << i)
|
if (ulineall || m->tagset[m->seltags] & 1 << i)
|
||||||
drw_rect(drw, x + ulinepad, bh - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0);
|
drw_rect(drw, x + ulinepad, bh - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0);
|
||||||
|
|
||||||
|
|
@ -1111,14 +1111,14 @@ drawbar(Monitor *m)
|
||||||
if ((w = mw - tw - x) > th) {
|
if ((w = mw - tw - x) > th) {
|
||||||
if (m->sel) {
|
if (m->sel) {
|
||||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||||
drw_text(drw, x, y, w - sidepad, th, lrpad / 2, m->sel->name, 0, statusfontindex);
|
drw_text(drw, x, y, w - sidepad - stw, th, lrpad / 2, m->sel->name, 0, statusfontindex);
|
||||||
if (m->sel->isfloating)
|
if (m->sel->isfloating)
|
||||||
drw_rect(drw, x + boxs, y + boxs, boxw, boxw, m->sel->isfixed, 0);
|
drw_rect(drw, x + boxs, y + boxs, boxw - stw, boxw, m->sel->isfixed, 0);
|
||||||
} else {
|
} else {
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
// drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1);
|
// drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1);
|
||||||
// drw_rect(drw, x, y, w - 2 * sp, th, 1, 1);
|
// drw_rect(drw, x, y, w - 2 * sp, th, 1, 1);
|
||||||
drw_rect(drw, x, y, w - 1, th, 1, 1);
|
drw_rect(drw, x, y, w - sp - stw, th, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
||||||
|
|
@ -2655,7 +2655,7 @@ togglebar(const Arg *arg)
|
||||||
wc.y = -bh;
|
wc.y = -bh;
|
||||||
else if (selmon->showbar) {
|
else if (selmon->showbar) {
|
||||||
wc.y = 0;
|
wc.y = 0;
|
||||||
if (!selmon->topbar)
|
if (!selmon->topbar)
|
||||||
wc.y = selmon->mh - bh;
|
wc.y = selmon->mh - bh;
|
||||||
}
|
}
|
||||||
XConfigureWindow(dpy, systray->win, CWY, &wc);
|
XConfigureWindow(dpy, systray->win, CWY, &wc);
|
||||||
|
|
@ -3059,6 +3059,8 @@ updatesystrayicongeom(Client *i, int w, int h)
|
||||||
if (i->w > 2*bh)
|
if (i->w > 2*bh)
|
||||||
i->w = bh;
|
i->w = bh;
|
||||||
}
|
}
|
||||||
|
i->w = i->w - sp * 2 - borderpx * 2;
|
||||||
|
i->h = i->h - sp * 2 - borderpx * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -3096,7 +3098,7 @@ updatesystray(void)
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
Client *i;
|
Client *i;
|
||||||
Monitor *m = systraytomon(NULL);
|
Monitor *m = systraytomon(NULL);
|
||||||
unsigned int x = m->mx + m->mw;
|
unsigned int x = m->mx + m->mw - sp;
|
||||||
unsigned int w = 1;
|
unsigned int w = 1;
|
||||||
|
|
||||||
if (!showsystray)
|
if (!showsystray)
|
||||||
|
|
@ -3135,22 +3137,24 @@ updatesystray(void)
|
||||||
XMapRaised(dpy, i->win);
|
XMapRaised(dpy, i->win);
|
||||||
w += systrayspacing;
|
w += systrayspacing;
|
||||||
i->x = w;
|
i->x = w;
|
||||||
XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
|
XMoveResizeWindow(dpy, i->win, i->x, 3 * borderpx + 1, i->w, i->h);
|
||||||
w += i->w;
|
w += i->w;
|
||||||
if (i->mon != m)
|
if (i->mon != m)
|
||||||
i->mon = m;
|
i->mon = m;
|
||||||
}
|
}
|
||||||
w = w ? w + systrayspacing : 1;
|
w = w ? w + systrayspacing + borderpx : 1;
|
||||||
x -= w;
|
x -= w;
|
||||||
XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh);
|
XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh);
|
||||||
wc.x = x; wc.y = m->by; wc.width = w; wc.height = bh;
|
wc.x = x; wc.y = m->by - borderpx; wc.width = w; wc.height = bh;
|
||||||
wc.stack_mode = Above; wc.sibling = m->barwin;
|
wc.stack_mode = Above; wc.sibling = m->barwin;
|
||||||
XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
|
XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
|
||||||
XMapWindow(dpy, systray->win);
|
XMapWindow(dpy, systray->win);
|
||||||
XMapSubwindows(dpy, systray->win);
|
XMapSubwindows(dpy, systray->win);
|
||||||
/* redraw background */
|
/* redraw background */
|
||||||
XSetForeground(dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
|
XSetForeground(dpy, drw->gc, clrborder.pixel);
|
||||||
XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh);
|
XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh);
|
||||||
|
XSetForeground(dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
|
||||||
|
XFillRectangle(dpy, systray->win, drw->gc, 0, borderpx, w - borderpx, bh - 2 * borderpx);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue