Add barpadding + notitle patch

This commit is contained in:
BitHeaven 2024-05-31 18:39:01 +05:00
parent ceb23ea470
commit a0fe569f7e
7 changed files with 35 additions and 47 deletions

View File

@ -3,5 +3,7 @@ quitprompt
fullgaps fullgaps
gaplessgrid gaplessgrid
status2d + extrabar status2d + extrabar
barpadding + notitle
anycorners anycorners
fonts?

View File

@ -153,7 +153,6 @@ static const Button buttons[] = {
/* click event mask button function argument */ /* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, SUPERKEY, Button1, movemouse, {0} }, { ClkClientWin, SUPERKEY, Button1, movemouse, {0} },
{ ClkClientWin, SUPERKEY, Button2, togglefloating, {0} }, { ClkClientWin, SUPERKEY, Button2, togglefloating, {0} },

View File

@ -153,7 +153,6 @@ static const Button buttons[] = {
/* click event mask button function argument */ /* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, SUPERKEY, Button1, movemouse, {0} }, { ClkClientWin, SUPERKEY, Button1, movemouse, {0} },
{ ClkClientWin, SUPERKEY, Button2, togglefloating, {0} }, { ClkClientWin, SUPERKEY, Button2, togglefloating, {0} },

BIN
dwm

Binary file not shown.

58
dwm.c
View File

@ -64,7 +64,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, enum { ClkTagBar, ClkLtSymbol, ClkStatusText,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
typedef union { typedef union {
@ -120,7 +120,6 @@ struct Monitor {
int eby; /* extra bar geometry */ int eby; /* extra bar geometry */
int mx, my, mw, mh; /* screen size */ int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */ int wx, wy, ww, wh; /* window area */
int gappx; /* gaps between windows */
unsigned int seltags; unsigned int seltags;
unsigned int sellt; unsigned int sellt;
unsigned int tagset[2]; unsigned int tagset[2];
@ -247,7 +246,7 @@ static int sw, sh; /* X display screen geometry width, height */
static int bh; /* bar height */ static int bh; /* bar height */
static int lrpad; /* sum of left and right padding for text */ static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display *, XErrorEvent *); static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0; static unsigned int numlockmask = 1;
static void (*handler[LASTEvent]) (XEvent *) = { static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress, [ButtonPress] = buttonpress,
[ClientMessage] = clientmessage, [ClientMessage] = clientmessage,
@ -447,10 +446,8 @@ buttonpress(XEvent *e)
arg.ui = 1 << i; arg.ui = 1 << i;
} else if (ev->x < x + TEXTW(selmon->ltsymbol)) } else if (ev->x < x + TEXTW(selmon->ltsymbol))
click = ClkLtSymbol; click = ClkLtSymbol;
else if (ev->x > selmon->ww - (int)TEXTW(stext))
click = ClkStatusText;
else else
click = ClkWinTitle; click = ClkStatusText;
} else if ((c = wintoclient(ev->window))) { } else if ((c = wintoclient(ev->window))) {
focus(c); focus(c);
restack(selmon); restack(selmon);
@ -578,8 +575,8 @@ configurenotify(XEvent *e)
for (c = m->clients; c; c = c->next) for (c = m->clients; c; c = c->next)
if (c->isfullscreen) if (c->isfullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh); resizeclient(c, m->mx, m->my, m->mw, m->mh);
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); XMoveResizeWindow(dpy, m->barwin, m->wx + gappx, m->by + gappx, m->ww - 2 * gappx, bh);
XMoveResizeWindow(dpy, m->extrabarwin, m->wx, m->eby, m->ww, bh); XMoveResizeWindow(dpy, m->extrabarwin, m->wx + gappx, m->eby - gappx, m->ww - 2 * gappx, bh);
} }
focus(NULL); focus(NULL);
arrange(NULL); arrange(NULL);
@ -650,7 +647,6 @@ createmon(void)
m->nmaster = nmaster; m->nmaster = nmaster;
m->showbar = showbar; m->showbar = showbar;
m->topbar = topbar; m->topbar = topbar;
m->gappx = gappx;
m->lt[0] = &layouts[0]; m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)]; m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@ -744,11 +740,11 @@ drawstatusbar(Monitor *m, int bh, int extra, char* stext) {
text = p; text = p;
if (extra) { if (extra) {
w = m->ww; w = m->ww - 2 * gappx;
ret = x = 1; ret = x = 0;
} else { } else {
w += 2; /* 1px padding on both sides */ ret = m->ww - w;
ret = x = m->ww - w; x = ret - 2 * gappx;
} }
drw_setscheme(drw, scheme[LENGTH(colors)]); drw_setscheme(drw, scheme[LENGTH(colors)]);
@ -859,15 +855,8 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - tw - x) > bh) { if ((w = m->ww - tw - x) > bh) {
if (m->sel) { drw_setscheme(drw, scheme[SchemeNorm]);
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_rect(drw, x, 0, w - 2 * gappx, bh, 1, 1);
drw_text(drw, x, 0, w, 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[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
} }
drw_map(drw, m->barwin, 0, 0, m->ww, bh); drw_map(drw, m->barwin, 0, 0, m->ww, bh);
@ -1359,11 +1348,8 @@ propertynotify(XEvent *e)
drawbars(); drawbars();
break; 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);
if (c == c->mon->sel)
drawbar(c->mon);
}
if (ev->atom == netatom[NetWMWindowType]) if (ev->atom == netatom[NetWMWindowType])
updatewindowtype(c); updatewindowtype(c);
} }
@ -1829,8 +1815,8 @@ togglebar(const Arg *arg)
{ {
selmon->showbar = !selmon->showbar; selmon->showbar = !selmon->showbar;
updatebarpos(selmon); updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + gappx, selmon->by + gappx, selmon->ww - 2 * gappx, bh);
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + gappx, selmon->eby - gappx, selmon->ww - 2 * gappx, bh);
arrange(selmon); arrange(selmon);
} }
@ -1947,7 +1933,7 @@ updatebars(void)
XClassHint ch = {"dwm", "dwm"}; XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
if (!m->barwin) { if (!m->barwin) {
m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), m->barwin = XCreateWindow(dpy, root, m->wx + gappx, m->by + gappx, m->ww - 2 * gappx, bh, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
@ -1955,7 +1941,7 @@ updatebars(void)
XSetClassHint(dpy, m->barwin, &ch); XSetClassHint(dpy, m->barwin, &ch);
} }
if (!m->extrabarwin) { if (!m->extrabarwin) {
m->extrabarwin = XCreateWindow(dpy, root, m->wx, m->eby, m->ww, bh, 0, DefaultDepth(dpy, screen), m->extrabarwin = XCreateWindow(dpy, root, m->wx + gappx, m->eby - gappx, m->ww - 2 * gappx, bh, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor); XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor);
@ -1979,13 +1965,15 @@ updatebarpos(Monitor *m)
m->wy = m->my; m->wy = m->my;
m->wh = m->mh; m->wh = m->mh;
m->wh -= bh * m->showbar * 2; m->wh -= bh * m->showbar * 2;
m->wy = m->showbar ? m->wy + bh : m->wy; m->wy = m->showbar ? m->wy + bh + gappx : m->wy;
if (m->showbar) { if (m->showbar) {
m->by = m->topbar ? m->wy - bh : m->wy + m->wh; m->by = m->topbar ? m->wy - bh - gappx : m->wy + m->wh + gappx;
m->eby = m->topbar ? m->wy + m->wh : m->wy - bh; m->eby = m->topbar ? m->wy + m->wh - gappx : m->wy - bh - gappx * 2;
m->wy = topbar ? m->wy : m->wy - gappx * 2;
m->wh = topbar ? m->wh - gappx * 2 : m->wh + gappx * 2;
} else { } else {
m->by = -bh; m->by = -bh - gappx;
m->eby = -bh; m->eby = -bh + gappx;
} }
} }

BIN
dwm.o

Binary file not shown.

View File

@ -11,18 +11,18 @@ tile(Monitor *m)
if (n > m->nmaster) if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0; mw = m->nmaster ? m->ww * m->mfact : 0;
else else
mw = m->ww - m->gappx; mw = m->ww - gappx;
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) for (i = 0, my = ty = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) { if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx;
resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0); resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx, h - (2*c->bw), 0);
if (my + HEIGHT(c) + m->gappx < m->wh) if (my + HEIGHT(c) + gappx < m->wh)
my += HEIGHT(c) + m->gappx; my += HEIGHT(c) + gappx;
} else { } else {
h = (m->wh - ty) / (n - i) - m->gappx; h = (m->wh - ty) / (n - i) - gappx;
resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0); resize(c, m->wx + mw + gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*gappx, h - (2*c->bw), 0);
if (ty + HEIGHT(c) + m->gappx < m->wh) if (ty + HEIGHT(c) + gappx < m->wh)
ty += HEIGHT(c) + m->gappx; ty += HEIGHT(c) + gappx;
} }
} }