implemented barpadding patch and fixed issues with systray

This commit is contained in:
_N0x 2021-10-13 16:26:23 +02:00
parent 0297cb5edc
commit e429212501
2 changed files with 27 additions and 15 deletions

View File

@ -11,6 +11,8 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display
static const int showsystray = 1; /* 0 means no systray */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const int vertpad = 8; /* vertical padding of bar */
static const int sidepad = 8; /* horizontal padding of bar */
static const char *fonts[] = { "MesloLGS NF:size=11" };
static const char dmenufont[] = "MesloLGS NF:size=11";
static const char dmenupromt[] = "Run:";

View File

@ -284,6 +284,8 @@ static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
static int lrpad; /* sum of left and right padding for text */
static int vp; /* vertical padding for bar */
static int sp; /* side padding for bar */
static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = {
@ -850,8 +852,7 @@ drawstatusbar(Monitor *m, int bh, char* stext, int stw) {
text[i] = '\0';
w = TEXTW(text) - lrpad;
drw_text(drw, x - stw, 0, w, bh, 0, text, 0);
drw_text(drw, x - stw - 2 * sp, 0, w, bh, 0, text, 0);
x += w;
/* process code */
@ -894,7 +895,7 @@ drawstatusbar(Monitor *m, int bh, char* stext, int stw) {
if (!isCode) {
w = TEXTW(text) - lrpad;
drw_text(drw, x - stw, 0, w, bh, 0, text, 0);
drw_text(drw, x - stw - 2 * sp, 0, w, bh, 0, text, 0);
}
drw_setscheme(drw, scheme[SchemeNorm]);
@ -947,12 +948,12 @@ drawbar(Monitor *m)
if ((w = m->ww - sw - stw - x) > bh) {
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
drw_setscheme(drw, scheme[SchemeInfoNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1);
}
}
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
@ -1543,7 +1544,7 @@ resizebarwin(Monitor *m) {
unsigned int w = m->ww;
if (showsystray && m == systraytomon(m))
w -= getsystraywidth();
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, w - 2 * sp, bh);
}
void
@ -1931,6 +1932,9 @@ setup(void)
lrpad = drw->fonts->h;
bh = drw->fonts->h + 2;
updategeom();
sp = sidepad;
vp = (topbar == 1) ? vertpad : - vertpad;
/* init atoms */
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
@ -1967,6 +1971,7 @@ setup(void)
/* init bars */
updatebars();
updatestatus();
updatebarpos(selmon);
/* supporting window for NetWMCheck */
wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0);
XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32,
@ -2226,7 +2231,7 @@ updatebars(void)
w = m->ww;
if (showsystray && m == systraytomon(m))
w -= getsystraywidth();
m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen),
m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, w -2 * sp, bh, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
@ -2243,11 +2248,11 @@ updatebarpos(Monitor *m)
m->wy = m->my;
m->wh = m->mh;
if (m->showbar) {
m->wh -= bh;
m->by = m->topbar ? m->wy : m->wy + m->wh;
m->wy = m->topbar ? m->wy + bh : m->wy;
m->wh = m->wh - vertpad - bh;
m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad;
m->wy = m->topbar ? m->wy + bh + vp : m->wy;
} else
m->by = -bh;
m->by = -bh - vp;
}
void
@ -2468,7 +2473,8 @@ updatesystray(void)
XWindowChanges wc;
Client *i;
Monitor *m = systraytomon(NULL);
unsigned int x = m->mx + m->mw;
unsigned int x = m->mx + m->mw - sp;
unsigned int y = m->by + vp;
unsigned int w = 1;
if (!showsystray)
@ -2477,7 +2483,7 @@ updatesystray(void)
/* init systray */
if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
systray->win = XCreateSimpleWindow(dpy, root, x, m->by, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
systray->win = XCreateSimpleWindow(dpy, root, x, y, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
wa.event_mask = ButtonPressMask | ExposureMask;
wa.override_redirect = True;
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
@ -2513,8 +2519,12 @@ updatesystray(void)
w = w ? w + systrayspacing : 1;
x -= w;
XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh);
wc.x = x; wc.y = m->by; wc.width = w; wc.height = bh;
wc.stack_mode = Above; wc.sibling = m->barwin;
wc.x = x;
wc.y = y;
wc.width = w;
wc.height = bh;
wc.stack_mode = Above;
wc.sibling = m->barwin;
XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
XMapWindow(dpy, systray->win);
XMapSubwindows(dpy, systray->win);