commit 9af0350fd7cf753cbaa246a9695045bf8a03daeb
parent cb93d76716ea2f3b0cfc52d0f84807ce00bf2ef0
Author: ssnf <ssnf@ssnf.xyz>
Date: Tue, 20 Sep 2022 12:26:34 +0000
vanity gaps
Diffstat:
5 files changed, 593 insertions(+), 249 deletions(-)
diff --git a/config.h b/config.h
@@ -1,6 +1,10 @@
/* appearance */
static const uint borderpx = 3; /* border pixel of windows */
static const uint snap = 20; /* snap pixel */
+static const uint gappih = 4; /* horiz inner gap between windows */
+static const uint gappiv = 4; /* vert inner gap between windows */
+static const uint gappoh = 4; /* horiz outer gap between windows and screen edge */
+static const uint gappov = 4; /* vert outer gap between windows and screen edge */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "hack:size=12" };
@@ -36,7 +40,7 @@ static const Rule rules[] = {
};
/* layout(s) */
-static const float mfact = 0.5; /* factor of master area size [0.05..0.95] */
+static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
static const int nmaster = 2; /* number of clients in master area */
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
@@ -66,8 +70,10 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
static const char* browser[] = { "browser", NULL };
static const char* caps[] = { "setxkbmap", "-option", "caps:super", NULL };
static const char* color[] = { "colorpick", NULL };
+static const char* cyclebg[] = { "cyclebg", NULL };
static const char* compositor[] = { "compositor", NULL };
static const char* dmenucmd[] = { "dmenu_run", "-m", dmenumon, NULL };
+static const char* games[] = { "games", NULL };
static const char* lock[] = { "lock", NULL };
static const char* mict[] = { "mict", NULL };
static const char* mont[] = { "mont", NULL };
@@ -86,6 +92,8 @@ static Key keys[] = {
{ MOD|SHIFT, XK_i, spawn, {.v = color} },
{ MOD, XK_c, spawn, {.v = compositor} },
{ MOD, XK_x, spawn, {.v = lock} },
+ { MOD, XK_F5, spawn, {.v = cyclebg} },
+ { MOD, XK_g, spawn, {.v = games} },
{ 0, XF86XK_ScreenSaver, spawn, {.v = lock} },
{ 0, XF86XK_Suspend, spawn, {.v = lock} },
{ 0, XF86XK_Sleep, spawn, {.v = lock} },
diff --git a/dwm.c b/dwm.c
@@ -135,6 +135,10 @@ typedef struct Monitor {
int by; /* bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
+ int gappih; /* horizontal gap between windows */
+ int gappiv; /* vertical gap between windows */
+ int gappoh; /* horizontal outer gaps */
+ int gappov; /* vertical outer gaps */
uint seltags;
uint sellt;
uint tagset[2];
@@ -160,105 +164,105 @@ typedef struct {
} Rule;
/* function declarations */
-static void applyrules(Client* c);
-static int applysizehints(Client* c, int* x, int* y, int* w, int* h, int interact);
-static void arrange(Monitor* m);
-static void arrangemon(Monitor* m);
-static void attach(Client* c);
-static void attachstack(Client* c);
-static void buttonpress(XEvent* e);
-static void checkotherwm(void);
-static void cleanup(void);
-static void cleanupmon(Monitor* mon);
-static void clientmessage(XEvent* e);
-static void configure(Client* c);
-static void configurenotify(XEvent* e);
-static void configurerequest(XEvent* e);
+static void applyrules(Client* c);
+static int applysizehints(Client* c, int* x, int* y, int* w, int* h, int interact);
+static void arrange(Monitor* m);
+static void arrangemon(Monitor* m);
+static void attach(Client* c);
+static void attachstack(Client* c);
+static void buttonpress(XEvent* e);
+static void checkotherwm(void);
+static void cleanup(void);
+static void cleanupmon(Monitor* mon);
+static void clientmessage(XEvent* e);
+static void configure(Client* c);
+static void configurenotify(XEvent* e);
+static void configurerequest(XEvent* e);
static Monitor* createmon(void);
-static void destroynotify(XEvent* e);
-static void detach(Client* c);
-static void detachstack(Client* c);
+static void destroynotify(XEvent* e);
+static void detach(Client* c);
+static void detachstack(Client* c);
static Monitor* dirtomon(int dir);
-static void drawbar(Monitor* m);
-static void drawbars(void);
-static void enternotify(XEvent* e);
-static void expose(XEvent* e);
-static void fibonacci(Monitor* mon);
-static void focus(Client* c);
-static void focusin(XEvent* e);
-static void focusmon(const Arg* arg);
-static void focusstack(const Arg* arg);
-static Atom getatomprop(Client* c, Atom prop);
-static int getrootptr(int* x, int* y);
-static long getstate(Window w);
-static int gettextprop(Window w, Atom atom, char* text, uint size);
-static void grabbuttons(Client* c, int focused);
-static void grabkeys(void);
-static void keypress(XEvent* e);
-static void killclient(const Arg* arg);
-static void manage(Window w, XWindowAttributes* wa);
-static void mappingnotify(XEvent* e);
-static void maprequest(XEvent* e);
-static void motionnotify(XEvent* e);
-static void movemouse(const Arg* arg);
+static void drawbar(Monitor* m);
+static void drawbars(void);
+static void enternotify(XEvent* e);
+static void expose(XEvent* e);
+static void fibonacci(Monitor *m);
+static void focus(Client* c);
+static void focusin(XEvent* e);
+static void focusmon(const Arg* arg);
+static void focusstack(const Arg* arg);
+static Atom getatomprop(Client* c, Atom prop);
+static int getrootptr(int* x, int* y);
+static long getstate(Window w);
+static int gettextprop(Window w, Atom atom, char* text, uint size);
+static void grabbuttons(Client* c, int focused);
+static void grabkeys(void);
+static void keypress(XEvent* e);
+static void killclient(const Arg* arg);
+static void manage(Window w, XWindowAttributes* wa);
+static void mappingnotify(XEvent* e);
+static void maprequest(XEvent* e);
+static void motionnotify(XEvent* e);
+static void movemouse(const Arg* arg);
static Client* nexttiled(Client* c);
-static void pop(Client*);
-static void propertynotify(XEvent* e);
-static void quit(const Arg* arg);
+static void pop(Client*);
+static void propertynotify(XEvent* e);
+static void quit(const Arg* arg);
static Monitor* recttomon(int x, int y, int w, int h);
-static void resize(Client* c, int x, int y, int w, int h, int interact);
-static void resizeclient(Client* c, int x, int y, int w, int h);
-static void resizemouse(const Arg* arg);
-static void restack(Monitor* m);
-static void run(void);
-static void scan(void);
-static int sendevent(Client* c, Atom proto);
-static void sendmon(Client* c, Monitor* m);
-static void setclientstate(Client* c, long state);
-static void setfocus(Client* c);
-static void setfullscreen(Client* c, int fullscreen);
-static void setlayout(const Arg* arg);
-static void setmfact(const Arg* arg);
-static void setup(void);
-static void seturgent(Client* c, int urg);
-static void showhide(Client* c);
-static void sigchld(int unused);
-static void spawn(const Arg* arg);
-static void tag(const Arg* arg);
-static void tagmon(const Arg* arg);
-static void togglebar(const Arg* arg);
-static void togglefloating(const Arg* arg);
-static void togglefullscr(const Arg* arg);
-static void toggletag(const Arg* arg);
-static void toggleview(const Arg* arg);
-static void unfocus(Client* c, int setfocus);
-static void unmanage(Client* c, int destroyed);
-static void unmapnotify(XEvent* e);
-static void updatebarpos(Monitor* m);
-static void updatebars(void);
-static void updateclientlist(void);
-static int updategeom(void);
-static void updatenumlockmask(void);
-static void updatesizehints(Client* c);
-static void updatestatus(void);
-static void updatetitle(Client* c);
-static void updatewindowtype(Client* c);
-static void updatewmhints(Client* c);
-static void view(const Arg* arg);
+static void resize(Client* c, int x, int y, int w, int h, int interact);
+static void resizeclient(Client* c, int x, int y, int w, int h);
+static void resizemouse(const Arg* arg);
+static void restack(Monitor* m);
+static void run(void);
+static void scan(void);
+static int sendevent(Client* c, Atom proto);
+static void sendmon(Client* c, Monitor* m);
+static void setclientstate(Client* c, long state);
+static void setfocus(Client* c);
+static void setfullscreen(Client* c, int fullscreen);
+static void setlayout(const Arg* arg);
+static void setmfact(const Arg* arg);
+static void setup(void);
+static void seturgent(Client* c, int urg);
+static void showhide(Client* c);
+static void sigchld(int unused);
+static void spawn(const Arg* arg);
+static void tag(const Arg* arg);
+static void tagmon(const Arg* arg);
+static void togglebar(const Arg* arg);
+static void togglefloating(const Arg* arg);
+static void togglefullscr(const Arg* arg);
+static void toggletag(const Arg* arg);
+static void toggleview(const Arg* arg);
+static void unfocus(Client* c, int setfocus);
+static void unmanage(Client* c, int destroyed);
+static void unmapnotify(XEvent* e);
+static void updatebarpos(Monitor* m);
+static void updatebars(void);
+static void updateclientlist(void);
+static int updategeom(void);
+static void updatenumlockmask(void);
+static void updatesizehints(Client* c);
+static void updatestatus(void);
+static void updatetitle(Client* c);
+static void updatewindowtype(Client* c);
+static void updatewmhints(Client* c);
+static void view(const Arg* arg);
static Client* wintoclient(Window w);
static Monitor* wintomon(Window w);
-static int xerror(Display* dpy, XErrorEvent* error_event);
-static int xerrordummy(Display* dpy, XErrorEvent* error_event);
-static int xerrorstart(Display* dpy, XErrorEvent* error_event);
-static void xinitvisual();
-static void zoom(const Arg* arg);
+static int xerror(Display* dpy, XErrorEvent* error_event);
+static int xerrordummy(Display* dpy, XErrorEvent* error_event);
+static int xerrorstart(Display* dpy, XErrorEvent* error_event);
+static void xinitvisual();
+static void zoom(const Arg* arg);
/* swallow */
-static pid_t getparentprocess(pid_t p);
-static int isdescprocess(pid_t p, pid_t c);
+static pid_t getparentprocess(pid_t p);
+static int isdescprocess(pid_t p, pid_t c);
static Client* swallowingclient(Window w);
static Client* termforwin(const Client* c);
-static pid_t winpid(Window w);
+static pid_t winpid(Window w);
/* variables */
static const char broken[] = "broken";
@@ -270,20 +274,22 @@ static int bh, blw = 0; /* bar geometry */
static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display*, XErrorEvent*);
static uint numlockmask = 0;
-static void (*handler[LASTEvent])(XEvent*) = { [ButtonPress] = buttonpress,
- [ClientMessage] = clientmessage,
- [ConfigureRequest] = configurerequest,
- [ConfigureNotify] = configurenotify,
- [DestroyNotify] = destroynotify,
- [EnterNotify] = enternotify,
- [Expose] = expose,
- [FocusIn] = focusin,
- [KeyPress] = keypress,
- [MappingNotify] = mappingnotify,
- [MapRequest] = maprequest,
- [MotionNotify] = motionnotify,
- [PropertyNotify] = propertynotify,
- [UnmapNotify] = unmapnotify };
+static void (*handler[LASTEvent])(XEvent*) = {
+ [ButtonPress] = buttonpress,
+ [ClientMessage] = clientmessage,
+ [ConfigureRequest] = configurerequest,
+ [ConfigureNotify] = configurenotify,
+ [DestroyNotify] = destroynotify,
+ [EnterNotify] = enternotify,
+ [Expose] = expose,
+ [FocusIn] = focusin,
+ [KeyPress] = keypress,
+ [MappingNotify] = mappingnotify,
+ [MapRequest] = maprequest,
+ [MotionNotify] = motionnotify,
+ [PropertyNotify] = propertynotify,
+ [UnmapNotify] = unmapnotify
+};
static Atom wmatom[WMLast], netatom[NetLast];
static int running = 1;
static Cur* cursor[CurLast];
@@ -295,9 +301,8 @@ static Window root, wmcheckwin;
static xcb_connection_t* xcon;
-static int useargb = 0;
-static Visual *visual;
-static int depth;
+static Visual* visual;
+static int depth;
static Colormap cmap;
/* configuration, allows nested code to access above variables */
@@ -378,13 +383,15 @@ applyrules(Client* c)
c->noswallow = r->noswallow;
c->isfloating = r->isfloating;
c->tags |= r->tags;
- for (m = mons; m && m->num != r->monitor; m = m->next)
- ;
- if (m) c->mon = m;
+ for (m = mons; m && m->num != r->monitor; m = m->next);
+ if (m)
+ c->mon = m;
}
}
- if (ch.res_class) XFree(ch.res_class);
- if (ch.res_name) XFree(ch.res_name);
+ if (ch.res_class)
+ XFree(ch.res_class);
+ if (ch.res_name)
+ XFree(ch.res_name);
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
}
@@ -441,20 +448,24 @@ int applysizehints(Client* c, int* x, int* y, int* w, int* h, int interact)
void
arrange(Monitor* m)
{
- if (m) showhide(m->stack);
+ if (m)
+ showhide(m->stack);
else
- for (m = mons; m; m = m->next) showhide(m->stack);
+ for (m = mons; m; m = m->next)
+ showhide(m->stack);
if (m) {
arrangemon(m);
restack(m);
} else
- for (m = mons; m; m = m->next) arrangemon(m);
+ for (m = mons; m; m = m->next)
+ arrangemon(m);
}
void
arrangemon(Monitor* m)
{
- if (m->lt[m->sellt]->arrange) m->lt[m->sellt]->arrange(m);
+ if (m->lt[m->sellt]->arrange)
+ m->lt[m->sellt]->arrange(m);
}
void
@@ -536,9 +547,11 @@ cleanup(void)
view(&a);
selmon->lt[selmon->sellt] = &foo;
for (m = mons; m; m = m->next)
- while (m->stack) unmanage(m->stack, 0);
+ while (m->stack)
+ unmanage(m->stack, 0);
XUngrabKey(dpy, AnyKey, AnyModifier, root);
- while (mons) cleanupmon(mons);
+ while (mons)
+ cleanupmon(mons);
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors); i++)
@@ -555,7 +568,8 @@ cleanupmon(Monitor* mon)
{
Monitor* m;
- if (mon == mons) mons = mons->next;
+ if (mon == mons)
+ mons = mons->next;
else {
for (m = mons; m && m->next != mon; m = m->next)
;
@@ -572,14 +586,16 @@ clientmessage(XEvent* e)
XClientMessageEvent* cme = &e->xclient;
Client* c = wintoclient(cme->window);
- if (!c) return;
+ if (!c)
+ return;
if (cme->message_type == netatom[NetWMState]) {
if (cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen])
setfullscreen(c, (
cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ ||
(cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
} else if (cme->message_type == netatom[NetActiveWindow]) {
- if (c != selmon->selcli && !c->isurgent) seturgent(c, 1);
+ if (c != selmon->selcli && !c->isurgent)
+ seturgent(c, 1);
}
}
@@ -620,7 +636,8 @@ configurenotify(XEvent* e)
updatebars();
for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next)
- if (c->isfullscreen) resizeclient(c, m->mx, m->my, m->mw, m->mh);
+ if (c->isfullscreen)
+ resizeclient(c, m->mx, m->my, m->mw, m->mh);
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
}
focus(NULL);
@@ -638,7 +655,8 @@ configurerequest(XEvent* e)
XWindowChanges wc;
if ((c = wintoclient(ev->window))) {
- if (ev->value_mask & CWBorderWidth) c->bw = ev->border_width;
+ if (ev->value_mask & CWBorderWidth)
+ c->bw = ev->border_width;
else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
m = c->mon;
if (ev->value_mask & CWX) {
@@ -661,7 +679,8 @@ configurerequest(XEvent* e)
c->x = m->mx + (m->mw / 2 - WIDTH(c) / 2); /* center in x direction */
if ((c->y + c->h) > m->my + m->mh && c->isfloating)
c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */
- if ((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight))) configure(c);
+ if ((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight)))
+ configure(c);
if (ISVISIBLE(c))
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
} else
@@ -690,6 +709,10 @@ createmon()
m->nmaster = nmaster;
m->showbar = showbar;
m->topbar = topbar;
+ m->gappih = gappih;
+ m->gappiv = gappiv;
+ m->gappoh = gappoh;
+ m->gappov = gappov;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
return m;
@@ -701,7 +724,8 @@ destroynotify(XEvent* e)
Client* c;
XDestroyWindowEvent* ev = &e->xdestroywindow;
- if ((c = wintoclient(ev->window))) unmanage(c, 1);
+ if ((c = wintoclient(ev->window)))
+ unmanage(c, 1);
else if ((c = swallowingclient(ev->window)))
unmanage(c->swallowing, 1);
}
@@ -726,8 +750,7 @@ detachstack(Client* c)
*tc = c->snext;
if (c == c->mon->selcli) {
- for (t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext)
- ;
+ for (t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext);
c->mon->selcli = t;
}
}
@@ -737,7 +760,8 @@ Monitor* dirtomon(int dir)
Monitor* m = NULL;
if (dir > 0) {
- if (!(m = selmon->next)) m = mons;
+ if (!(m = selmon->next))
+ m = mons;
} else if (selmon == mons)
for (m = mons; m->next; m = m->next)
;
@@ -782,7 +806,8 @@ drawbar(Monitor* m)
if (m->selcli) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->selcli->name, 0);
- if (m->selcli->isfloating) drw_rect(drw, x + boxs, boxs, boxw, boxw, m->selcli->isfixed, 0);
+ if (m->selcli->isfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, m->selcli->isfixed, 0);
} else {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
@@ -796,7 +821,8 @@ drawbars(void)
{
Monitor* m;
- for (m = mons; m; m = m->next) drawbar(m);
+ for (m = mons; m; m = m->next)
+ drawbar(m);
}
void
@@ -806,7 +832,8 @@ enternotify(XEvent* e)
Monitor* m;
XCrossingEvent* ev = &e->xcrossing;
- if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) return;
+ if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
+ return;
c = wintoclient(ev->window);
m = c ? c->mon : wintomon(ev->window);
if (m != selmon) {
@@ -823,50 +850,77 @@ expose(XEvent* e)
Monitor* m;
XExposeEvent* ev = &e->xexpose;
- if (ev->count == 0 && (m = wintomon(ev->window))) drawbar(m);
+ if (ev->count == 0 && (m = wintomon(ev->window)))
+ drawbar(m);
}
void
-fibonacci(Monitor* mon)
+fibonacci(Monitor* m)
{
- uint i, n, nx, ny, nw, nh;
+ uint i, n;
+ int cx, cy, cw, ch;
+ int nv, hrest, wrest, r;
Client* c;
- for (n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), ++n)
- ;
- if (n == 0) return;
-
- nx = mon->wx;
- ny = 0;
- nw = mon->ww;
- nh = mon->wh;
-
- for (i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
- if ((i % 2 && nh / 2 > 2 * c->bw) || (!(i % 2) && nw / 2 > 2 * c->bw)) {
- if (i < n - 1) {
- if (i % 2) nh /= 2;
- else
- nw /= 2;
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), ++n);
+ if (!n)
+ return;
+ cx = m->wx + m->gappov;
+ cy = m->wy + m->gappoh;
+ cw = m->ww - 2 * m->gappov;
+ ch = m->wh - 2 * m->gappoh;
+ hrest = wrest = 0;
+ r = 1;
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
+ if (r) {
+ if ((i % 2 && (ch - m->gappih) / 2 <= (bh + 2 * c->bw))
+ || (!(i % 2) && (cw - m->gappiv) / 2 <= (bh + 2 * c->bw)))
+ r = 0;
+ if (r && i < n - 1) {
+ if (i % 2) {
+ nv = (ch - m->gappih) / 2;
+ hrest = ch - 2 * nv - m->gappih;
+ ch = nv;
+ } else {
+ nv = (cw - m->gappiv) / 2;
+ wrest = cw - 2 * nv - m->gappiv;
+ cw = nv;
+ }
}
- if ((i % 4) == 0) {
- ny += nh;
+ switch (i % 4) {
+ case 0:
+ cy += ch + m->gappih;
+ ch += hrest;
+ break;
+ case 1:
+ cx += cw + m->gappiv;
+ cw += wrest;
+ break;
+ case 2:
+ cy += ch + m->gappih;
+ ch += hrest;
+ if (i < n - 1)
+ cw += wrest;
+ break;
+ case 3:
+ cx += cw + m->gappiv;
+ cw -= wrest;
+ break;
}
-
- else if ((i % 4) == 1)
- nx += nw;
- else if ((i % 4) == 2)
- ny += nh;
- else if ((i % 4) == 3)
- nx += nw;
-
- if (i == 0) {
- if (n != 1) nw = mon->ww * mon->mfact;
- ny = mon->wy;
+ if (!i) {
+ if (n != 1) {
+ cw = (m->ww - m->gappiv - 2 * m->gappov)
+ - (m->ww - m->gappiv - 2 * m->gappov)
+ * (1 - m->mfact)
+ ;
+ wrest = 0;
+ }
+ cy = m->wy + m->gappoh;
} else if (i == 1)
- nw = mon->ww - nw;
- i++;
+ cw = m->ww - cw - m->gappiv - 2 * m->gappov;
+ ++i;
}
- resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
+ resize(c, cx, cy, cw - (2 * c->bw), ch - (2 * c->bw), False);
}
}
@@ -876,7 +930,8 @@ focus(Client* c)
if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext)
;
- if (selmon->selcli && selmon->selcli != c) unfocus(selmon->selcli, 0);
+ if (selmon->selcli && selmon->selcli != c)
+ unfocus(selmon->selcli, 0);
if (c) {
if (c->mon != selmon) selmon = c->mon;
if (c->isurgent) seturgent(c, 0);
@@ -899,7 +954,8 @@ focusin(XEvent* e)
{
XFocusChangeEvent* ev = &e->xfocus;
- if (selmon->selcli && ev->window != selmon->selcli->win) setfocus(selmon->selcli);
+ if (selmon->selcli && ev->window != selmon->selcli->win)
+ setfocus(selmon->selcli);
}
void
@@ -907,8 +963,10 @@ focusmon(const Arg* arg)
{
Monitor* m;
- if (!mons->next) return;
- if ((m = dirtomon(arg->i)) == selmon) return;
+ if (!mons->next)
+ return;
+ if ((m = dirtomon(arg->i)) == selmon)
+ return;
unfocus(selmon->selcli, 0);
selmon = m;
focus(NULL);
@@ -919,8 +977,10 @@ focusstack(const Arg* arg)
{
Client *c = NULL, *i;
- if (!selmon->selcli) return;
- if (arg->i > sizeof(arg)) return;
+ if (!selmon->selcli)
+ return;
+ if (arg->i > sizeof(arg))
+ return;
if (arg->i > 0) {
for (c = selmon->selcli->next; c && !ISVISIBLE(c); c = c->next)
;
@@ -979,7 +1039,8 @@ long getstate(Window w)
dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState], &real, &format, &n, &extra, (uchar**)&p) !=
Success)
return -1;
- if (n != 0) result = *p;
+ if (n != 0)
+ result = *p;
XFree(p);
return result;
}
@@ -990,10 +1051,13 @@ int gettextprop(Window w, Atom atom, char* text, uint size)
int n;
XTextProperty name;
- if (!text || size == 0) return 0;
+ if (!text || size == 0)
+ return 0;
text[0] = '\0';
- if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems) return 0;
- if (name.encoding == XA_STRING) strncpy(text, (char*)name.value, size - 1);
+ if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
+ return 0;
+ if (name.encoding == XA_STRING)
+ strncpy(text, (char*)name.value, size - 1);
else {
if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
strncpy(text, *list, size - 1);
@@ -1071,7 +1135,8 @@ keypress(XEvent* e)
void
killclient(const Arg* arg)
{
- if (!selmon->selcli) return;
+ if (!selmon->selcli)
+ return;
if (!sendevent(selmon->selcli, wmatom[WMDelete])) {
XGrabServer(dpy);
XSetErrorHandler(xerrordummy);
@@ -1112,8 +1177,10 @@ manage(Window w, XWindowAttributes* wa)
term = termforwin(c);
}
- if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) c->x = c->mon->mx + c->mon->mw - WIDTH(c);
- if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh) c->y = c->mon->my + c->mon->mh - HEIGHT(c);
+ if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
+ c->x = c->mon->mx + c->mon->mw - WIDTH(c);
+ if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
+ c->y = c->mon->my + c->mon->mh - HEIGHT(c);
c->x = MAX(c->x, c->mon->mx);
/* only fix client y-offset, if the client center might cover the bar */
c->y = MAX(
@@ -1141,11 +1208,13 @@ manage(Window w, XWindowAttributes* wa)
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, (uchar*)&(c->win), 1);
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
setclientstate(c, NormalState);
- if (c->mon == selmon) unfocus(selmon->selcli, 0);
+ if (c->mon == selmon)
+ unfocus(selmon->selcli, 0);
c->mon->selcli = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
- if (term) swallow(term, c);
+ if (term)
+ swallow(term, c);
focus(NULL);
}
@@ -1155,7 +1224,8 @@ mappingnotify(XEvent* e)
XMappingEvent* ev = &e->xmapping;
XRefreshKeyboardMapping(ev);
- if (ev->request == MappingKeyboard) grabkeys();
+ if (ev->request == MappingKeyboard)
+ grabkeys();
}
void
@@ -1164,9 +1234,12 @@ maprequest(XEvent* e)
static XWindowAttributes wa;
XMapRequestEvent* ev = &e->xmaprequest;
- if (!XGetWindowAttributes(dpy, ev->window, &wa)) return;
- if (wa.override_redirect) return;
- if (!wintoclient(ev->window)) manage(ev->window, &wa);
+ if (!XGetWindowAttributes(dpy, ev->window, &wa))
+ return;
+ if (wa.override_redirect)
+ return;
+ if (!wintoclient(ev->window))
+ manage(ev->window, &wa);
}
void
@@ -1176,7 +1249,8 @@ motionnotify(XEvent* e)
Monitor* m;
XMotionEvent* ev = &e->xmotion;
- if (ev->window != root) return;
+ if (ev->window != root)
+ return;
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
unfocus(selmon->selcli, 1);
selmon = m;
@@ -1194,7 +1268,8 @@ movemouse(const Arg* arg)
XEvent ev;
Time lasttime = 0;
- if (!(c = selmon->selcli)) return;
+ if (!(c = selmon->selcli))
+ return;
if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
return;
restack(selmon);
@@ -1205,7 +1280,8 @@ movemouse(const Arg* arg)
dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurMove]->cursor, CurrentTime) !=
GrabSuccess)
return;
- if (!getrootptr(&x, &y)) return;
+ if (!getrootptr(&x, &y))
+ return;
do {
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
switch (ev.type) {
@@ -1213,12 +1289,14 @@ movemouse(const Arg* arg)
case Expose:
case MapRequest: handler[ev.type](&ev); break;
case MotionNotify:
- if ((ev.xmotion.time - lasttime) <= (1000 / 60)) continue;
+ if ((ev.xmotion.time - lasttime) <= (1000 / 60))
+ continue;
lasttime = ev.xmotion.time;
nx = ocx + (ev.xmotion.x - x);
ny = ocy + (ev.xmotion.y - y);
- if (abs(selmon->wx - nx) < snap) nx = selmon->wx;
+ if (abs(selmon->wx - nx) < snap)
+ nx = selmon->wx;
else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
nx = selmon->wx + selmon->ww - WIDTH(c);
if (abs(selmon->wy - ny) < snap) ny = selmon->wy;
@@ -1228,7 +1306,8 @@ movemouse(const Arg* arg)
!c->isfloating && selmon->lt[selmon->sellt]->arrange &&
(abs(nx - c->x) > snap || abs(ny - c->y) > snap))
togglefloating(NULL);
- if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) resize(c, nx, ny, c->w, c->h, 1);
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ resize(c, nx, ny, c->w, c->h, 1);
break;
}
} while (ev.type != ButtonRelease);
@@ -1263,8 +1342,10 @@ propertynotify(XEvent* e)
Window trans;
XPropertyEvent* ev = &e->xproperty;
- if ((ev->window == root) && (ev->atom == XA_WM_NAME)) updatestatus();
- else if (ev->state == PropertyDelete) return;
+ if ((ev->window == root) && (ev->atom == XA_WM_NAME))
+ updatestatus();
+ else if (ev->state == PropertyDelete)
+ return;
else if ((c = wintoclient(ev->window))) {
switch (ev->atom) {
default: break;
@@ -1282,9 +1363,11 @@ propertynotify(XEvent* e)
}
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
updatetitle(c);
- if (c == c->mon->selcli) drawbar(c->mon);
+ if (c == c->mon->selcli)
+ drawbar(c->mon);
}
- if (ev->atom == netatom[NetWMWindowType]) updatewindowtype(c);
+ if (ev->atom == netatom[NetWMWindowType])
+ updatewindowtype(c);
}
}
@@ -1310,7 +1393,8 @@ Monitor* recttomon(int x, int y, int w, int h)
void
resize(Client* c, int x, int y, int w, int h, int interact)
{
- if (applysizehints(c, &x, &y, &w, &h, interact)) resizeclient(c, x, y, w, h);
+ if (applysizehints(c, &x, &y, &w, &h, interact))
+ resizeclient(c, x, y, w, h);
}
void
@@ -1341,7 +1425,8 @@ resizemouse(const Arg* arg)
XEvent ev;
Time lasttime = 0;
- if (!(c = selmon->selcli)) return;
+ if (!(c = selmon->selcli))
+ return;
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
return;
restack(selmon);
@@ -1373,7 +1458,8 @@ resizemouse(const Arg* arg)
(abs(nw - c->w) > snap || abs(nh - c->h) > snap))
togglefloating(NULL);
}
- if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) resize(c, c->x, c->y, nw, nh, 1);
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ resize(c, c->x, c->y, nw, nh, 1);
break;
}
} while (ev.type != ButtonRelease);
@@ -1396,8 +1482,10 @@ restack(Monitor* m)
XWindowChanges wc;
drawbar(m);
- if (!m->selcli) return;
- if (m->selcli->isfloating || !m->lt[m->sellt]->arrange) XRaiseWindow(dpy, m->selcli->win);
+ if (!m->selcli)
+ return;
+ if (m->selcli->isfloating || !m->lt[m->sellt]->arrange)
+ XRaiseWindow(dpy, m->selcli->win);
if (m->lt[m->sellt]->arrange) {
wc.stack_mode = Below;
wc.sibling = m->barwin;
@@ -1442,12 +1530,14 @@ scan()
manage(wins[i], &wa);
}
for (i = 0; i < num; i++) { /* now the transients */
- if (!XGetWindowAttributes(dpy, wins[i], &wa)) continue;
+ if (!XGetWindowAttributes(dpy, wins[i], &wa))
+ continue;
if (
XGetTransientForHint(dpy, wins[i], &d1) && (wa.map_state == IsViewable || getstate(wins[i]) == IconicState))
manage(wins[i], &wa);
}
- if (wins) XFree(wins);
+ if (wins)
+ XFree(wins);
}
scanner = 0;
}
@@ -1455,7 +1545,8 @@ scan()
void
sendmon(Client* c, Monitor* m)
{
- if (c->mon == m) return;
+ if (c->mon == m)
+ return;
unfocus(c, 1);
detach(c);
detachstack(c);
@@ -1484,7 +1575,8 @@ sendevent(Client* c, Atom proto)
XEvent ev;
if (XGetWMProtocols(dpy, c->win, &protocols, &n)) {
- while (!exists && n--) exists = protocols[n] == proto;
+ while (!exists && n--)
+ exists = protocols[n] == proto;
XFree(protocols);
}
if (exists) {
@@ -1555,9 +1647,11 @@ setmfact(const Arg* arg)
{
float f;
- if (!arg || !selmon->lt[selmon->sellt]->arrange) return;
+ if (!arg || !selmon->lt[selmon->sellt]->arrange)
+ return;
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
- if (f < 0.05 || f > 0.95) return;
+ if (f < 0.05 || f > 0.95)
+ return;
selmon->mfact = f;
arrange(selmon);
}
@@ -1641,7 +1735,8 @@ seturgent(Client* c, int urg)
XWMHints* wmh;
c->isurgent = urg;
- if (!(wmh = XGetWMHints(dpy, c->win))) return;
+ if (!(wmh = XGetWMHints(dpy, c->win)))
+ return;
wmh->flags = urg ? (wmh->flags | XUrgencyHint) : (wmh->flags & ~XUrgencyHint);
XSetWMHints(dpy, c->win, wmh);
XFree(wmh);
@@ -1650,7 +1745,8 @@ seturgent(Client* c, int urg)
void
showhide(Client* c)
{
- if (!c) return;
+ if (!c)
+ return;
if (ISVISIBLE(c)) {
/* show clients top down */
XMoveWindow(dpy, c->win, c->x, c->y);
@@ -1675,7 +1771,8 @@ sigchld(int unused)
void
spawn(const Arg* arg)
{
- if (arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num;
+ if (arg->v == dmenucmd)
+ dmenumon[0] = '0' + selmon->num;
if (fork() == 0) {
if (dpy)
close(ConnectionNumber(dpy));
@@ -1700,7 +1797,8 @@ tag(const Arg* arg)
void
tagmon(const Arg* arg)
{
- if (!selmon->selcli || !mons->next) return;
+ if (!selmon->selcli || !mons->next)
+ return;
sendmon(selmon->selcli, dirtomon(arg->i));
}
@@ -1738,7 +1836,8 @@ toggletag(const Arg* arg)
{
uint newtags;
- if (!selmon->selcli) return;
+ if (!selmon->selcli)
+ return;
newtags = selmon->selcli->tags ^ (arg->ui & TAGMASK);
if (newtags) {
selmon->selcli->tags = newtags;
@@ -1762,7 +1861,8 @@ toggleview(const Arg* arg)
void
unfocus(Client* c, int setfocus)
{
- if (!c) return;
+ if (!c)
+ return;
grabbuttons(c, 0);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
if (setfocus) {
@@ -1819,7 +1919,8 @@ unmapnotify(XEvent* e)
XUnmapEvent* ev = &e->xunmap;
if ((c = wintoclient(ev->window))) {
- if (ev->send_event) setclientstate(c, WithdrawnState);
+ if (ev->send_event)
+ setclientstate(c, WithdrawnState);
else
unmanage(c, 0);
}
@@ -1903,7 +2004,8 @@ updategeom()
if (n <= nn) { /* new mons available */
for (i = 0; i < (nn - n); i++) {
for (m = mons; m && m->next; m = m->next);
- if (m) m->next = createmon();
+ if (m)
+ m->next = createmon();
else
mons = createmon();
}
@@ -2018,7 +2120,8 @@ updatesizehints(Client* c)
void
updatestatus()
{
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) strcpy(stext, "dwm-6.2");
+ if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
+ strcpy(stext, "dwm-6.2");
drawbar(selmon);
}
@@ -2054,7 +2157,8 @@ updatewmhints(Client* c)
XSetWMHints(dpy, c->win, wmh);
} else
c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0;
- if (wmh->flags & InputHint) c->neverfocus = !wmh->input;
+ if (wmh->flags & InputHint)
+ c->neverfocus = !wmh->input;
else
c->neverfocus = 0;
XFree(wmh);
@@ -2067,7 +2171,8 @@ view(const Arg* arg)
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle selcli tagset */
- if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ if (arg->ui & TAGMASK)
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
focus(NULL);
arrange(selmon);
}
@@ -2089,7 +2194,8 @@ winpid(Window w)
e = NULL;
r = xcb_res_query_client_ids_reply(xcon, c, &e);
- if (!r) return 0;
+ if (!r)
+ return 0;
i = xcb_res_query_client_ids_ids_iterator(r);
result = 0;
@@ -2104,7 +2210,8 @@ winpid(Window w)
free(r);
- if (result == (pid_t)-1) result = 0;
+ if (result == (pid_t)-1)
+ result = 0;
return result;
}
@@ -2116,7 +2223,8 @@ getparentprocess(pid_t p)
uint v;
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (uint)p);
- if (!(f = fopen(buf, "r"))) return 0;
+ if (!(f = fopen(buf, "r")))
+ return 0;
v = 0;
+ fscanf(f, "%*u %*s %*c %u", &v);
fclose(f);
@@ -2136,11 +2244,13 @@ termforwin(const Client* w)
Client* c;
Monitor* m;
- if (!w->pid || w->isterminal) return NULL;
+ if (!w->pid || w->isterminal)
+ return NULL;
for (m = mons; m; m = m->next)
for (c = m->clients; c; c = c->next)
- if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid)) return c;
+ if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
+ return c;
return NULL;
}
@@ -2152,7 +2262,8 @@ swallowingclient(Window w)
for (m = mons; m; m = m->next)
for (c = m->clients; c; c = c->next)
- if (c->swallowing && c->swallowing->win == w) return c;
+ if (c->swallowing && c->swallowing->win == w)
+ return c;
return NULL;
}
@@ -2162,7 +2273,8 @@ Client* wintoclient(Window w) {
for (m = mons; m; m = m->next)
for (c = m->clients; c; c = c->next)
- if (c->win == w) return c;
+ if (c->win == w)
+ return c;
return NULL;
}
@@ -2171,10 +2283,13 @@ Monitor* wintomon(Window w) {
Client* c;
Monitor* m;
- if (w == root && getrootptr(&x, &y)) return recttomon(x, y, 1, 1);
+ if (w == root && getrootptr(&x, &y))
+ return recttomon(x, y, 1, 1);
for (m = mons; m; m = m->next)
- if (w == m->barwin) return m;
- if ((c = wintoclient(w))) return c->mon;
+ if (w == m->barwin)
+ return m;
+ if ((c = wintoclient(w)))
+ return c->mon;
return selmon;
}
@@ -2217,34 +2332,28 @@ xerrorstart(Display* dpy, XErrorEvent* error_event)
void
xinitvisual()
{
- XVisualInfo *infos;
- XRenderPictFormat *fmt;
- int nitems;
- int i;
-
- XVisualInfo tpl = {
- .screen = screen,
- .depth = 32,
- .class = TrueColor
- };
- long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
+ XVisualInfo* info, v;
+ XRenderPictFormat* fmt;
+ long masks;
+ int i, n;
- infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
+ masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
+ v.screen = screen;
+ v.depth = 32;
+ v.class = TrueColor;
+ info = XGetVisualInfo(dpy, masks, &v, &n);
visual = NULL;
- for(i = 0; i < nitems; i ++) {
- fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
+ for (i = 0; i < n; ++i) {
+ fmt = XRenderFindVisualFormat(dpy, info[i].visual);
if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
- visual = infos[i].visual;
- depth = infos[i].depth;
+ visual = info[i].visual;
+ depth = info[i].depth;
cmap = XCreateColormap(dpy, root, visual, AllocNone);
- useargb = 1;
break;
}
}
-
- XFree(infos);
-
- if (! visual) {
+ XFree(info);
+ if (visual == NULL) {
visual = DefaultVisual(dpy, screen);
depth = DefaultDepth(dpy, screen);
cmap = DefaultColormap(dpy, screen);
@@ -2256,9 +2365,11 @@ zoom(const Arg* arg)
{
Client* c = selmon->selcli;
- if (!selmon->lt[selmon->sellt]->arrange || (selmon->selcli && selmon->selcli->isfloating)) return;
+ if (!selmon->lt[selmon->sellt]->arrange || (selmon->selcli && selmon->selcli->isfloating))
+ return;
if (c == nexttiled(selmon->clients))
- if (!c || !(c = nexttiled(c->next))) return;
+ if (!c || !(c = nexttiled(c->next)))
+ return;
pop(c);
}
diff --git a/patches/dwm-barpadding-20211020-a786211.diff b/patches/dwm-barpadding-20211020-a786211.diff
@@ -0,0 +1,118 @@
+From a3cfb215f7f647d83d67e33df8f33a73e43bd65f Mon Sep 17 00:00:00 2001
+From: Bakkeby <bakkeby@gmail.com>
+Date: Wed, 20 Oct 2021 09:14:07 +0200
+Subject: [PATCH] barpadding: adds space between the statusbar and the edge of
+ the screen
+
+---
+ config.def.h | 2 ++
+ dwm.c | 25 +++++++++++++++----------
+ 2 files changed, 17 insertions(+), 10 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..f0b739f 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
++static const int vertpad = 10; /* vertical padding of bar */
++static const int sidepad = 10; /* horizontal padding of bar */
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
+ static const char col_gray1[] = "#222222";
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..df6d0d7 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -242,6 +242,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 *) = {
+@@ -568,7 +570,7 @@ configurenotify(XEvent *e)
+ for (c = m->clients; c; c = c->next)
+ if (c->isfullscreen)
+ 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 + sp, m->by + vp, m->ww - 2 * sp, bh);
+ }
+ focus(NULL);
+ arrange(NULL);
+@@ -706,7 +708,7 @@ drawbar(Monitor *m)
+ if (m == selmon) { /* status is only drawn on selected monitor */
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
++ drw_text(drw, m->ww - tw - 2 * sp, 0, tw, bh, 0, stext, 0);
+ }
+
+ for (c = m->clients; c; c = c->next) {
+@@ -732,12 +734,12 @@ drawbar(Monitor *m)
+ if ((w = m->ww - tw - x) > bh) {
+ if (m->sel) {
+ drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
+- 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[SchemeNorm]);
+- 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, bh);
+@@ -1547,7 +1549,10 @@ setup(void)
+ die("no fonts could be loaded.");
+ lrpad = drw->fonts->h;
+ bh = drw->fonts->h + 2;
++ sp = sidepad;
++ vp = (topbar == 1) ? vertpad : - vertpad;
+ updategeom();
++
+ /* init atoms */
+ utf8string = XInternAtom(dpy, "UTF8_STRING", False);
+ wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
+@@ -1704,7 +1709,7 @@ togglebar(const Arg *arg)
+ {
+ selmon->showbar = !selmon->showbar;
+ updatebarpos(selmon);
+- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
++ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh);
+ arrange(selmon);
+ }
+
+@@ -1814,7 +1819,7 @@ updatebars(void)
+ for (m = mons; m; m = m->next) {
+ if (m->barwin)
+ continue;
+- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
++ m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh, 0, DefaultDepth(dpy, screen),
+ CopyFromParent, DefaultVisual(dpy, screen),
+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+ XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
+@@ -1829,11 +1834,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
+--
+2.33.0
+
diff --git a/patches/dwm-hide_vacant_tags-6.3.diff b/patches/dwm-hide_vacant_tags-6.3.diff
@@ -0,0 +1,39 @@
+diff --git a/dwm.c b/dwm.c
+index a96f33c..f2da729 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -432,9 +432,15 @@ buttonpress(XEvent *e)
+ }
+ if (ev->window == selmon->barwin) {
+ i = x = 0;
+- do
++ unsigned int occ = 0;
++ for(c = m->clients; c; c=c->next)
++ occ |= c->tags;
++ do {
++ /* Do not reserve space for vacant tags */
++ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
++ continue;
+ x += TEXTW(tags[i]);
+- while (ev->x >= x && ++i < LENGTH(tags));
++ } while (ev->x >= x && ++i < LENGTH(tags));
+ if (i < LENGTH(tags)) {
+ click = ClkTagBar;
+ arg.ui = 1 << i;
+@@ -719,13 +725,12 @@ drawbar(Monitor *m)
+ }
+ x = 0;
+ for (i = 0; i < LENGTH(tags); i++) {
++ /* Do not draw vacant tags */
++ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
++ continue;
+ w = TEXTW(tags[i]);
+ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+- if (occ & 1 << i)
+- drw_rect(drw, x + boxs, boxs, boxw, boxw,
+- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+- urg & 1 << i);
+ x += w;
+ }
+ w = blw = TEXTW(m->ltsymbol);
diff --git a/patches/dwm-swaptags-6.2.diff b/patches/dwm-swaptags-6.2.diff
@@ -0,0 +1,68 @@
+From 9513cc776dc8114967988d4abc32fd7f37446ddb Mon Sep 17 00:00:00 2001
+From: fossy <fossy@dnmx.org>
+Date: Sun, 28 Nov 2021 21:34:37 +0100
+Subject: [PATCH] Move function and it's prototype from config.def.h to dwm.c
+
+---
+ config.def.h | 3 ++-
+ dwm.c | 23 +++++++++++++++++++++++
+ 2 files changed, 25 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..f31a66d 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -50,7 +50,8 @@ static const Layout layouts[] = {
+ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
+ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
+ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
+- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
++ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \
++ { Mod4Mask|ShiftMask, KEY, swaptags, {.ui = 1 << TAG} },
+
+ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
+ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..d11addd 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -234,6 +234,7 @@ static int xerror(Display *dpy, XErrorEvent *ee);
+ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
++static void swaptags(const Arg *arg);
+
+ /* variables */
+ static const char broken[] = "broken";
+@@ -2127,6 +2128,28 @@ zoom(const Arg *arg)
+ pop(c);
+ }
+
++void
++swaptags(const Arg *arg)
++{
++ unsigned int newtag = arg->ui & TAGMASK;
++ unsigned int curtag = selmon->tagset[selmon->seltags];
++
++ if (newtag == curtag || !curtag || (curtag & (curtag-1)))
++ return;
++
++ for (Client *c = selmon->clients; c != NULL; c = c->next) {
++ if((c->tags & newtag) || (c->tags & curtag))
++ c->tags ^= curtag ^ newtag;
++
++ if(!c->tags) c->tags = newtag;
++ }
++
++ selmon->tagset[selmon->seltags] = newtag;
++
++ focus(NULL);
++ arrange(selmon);
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+--
+2.34.1
+