commit e01fb28a87a50d885fe4bff647b78b55b5bae8f0
parent 47da8c4c3eb840a38310dae846915ba020765ed6
Author: kocotian <kocotian@kocotian.pl>
Date: Sun, 7 Mar 2021 12:00:23 +0100
smart borders
Diffstat:
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -7,6 +7,7 @@ static void modmove(const Arg *arg);
static const unsigned int borderpx = 2; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const unsigned int smartgaps = 1; /* smart gaps */
+static const unsigned int smartbord = 1; /* smart borders */
static const unsigned int ogappx = 30; /* outer gaps */
static const unsigned int igappx = 3; /* inner gaps */
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
@@ -187,6 +188,7 @@ static Key keys[] = {
{ MODKEY, XK_a, gaptog, {0} },
{ MODKEY|ShiftMask, XK_a, gaptog, {1} },
+ { MODKEY|ControlMask, XK_a, sbtog, {0} },
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_d, spawn, SHCMD("dmenize") },
{ MODKEY, XK_f, togglefullscr, {0} },
diff --git a/dwm.c b/dwm.c
@@ -144,7 +144,7 @@ struct Monitor {
int eby; /* extra bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
- unsigned int smartgaps, ogappx, igappx;
+ unsigned int smartgaps, smartbord, ogappx, igappx;
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -253,6 +253,7 @@ static void setmfact(const Arg *arg);
static void setigappx(const Arg *arg);
static void setogappx(const Arg *arg);
static void gaptog(const Arg *arg);
+static void sbtog(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
@@ -961,6 +962,7 @@ createmon(void)
strncpy(m->attsymbol, directions[attachdirection].symbol,
strlen(directions[attachdirection].symbol) + 1);
m->smartgaps = smartgaps;
+ m->smartbord = smartbord;
m->ogappx = ogappx;
m->igappx = igappx;
@@ -1136,7 +1138,7 @@ drawbar(Monitor *m)
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
drw_setscheme(drw, scheme[SchemeNorm]);
- drw_rect(drw, 0, 0, mons->ww, bh, 1, 1);
+ drw_rect(drw, 0, 0, m->ww, bh, 1, 1);
drw_text(drw, 0, 0, mons->ww, bh, 0, "", 0);
if (m == selmon) { /* extra status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]);
@@ -1243,7 +1245,7 @@ focus(Client *c)
detachstack(c);
attachstack(c);
grabbuttons(c, 1);
- XSetWindowBorder(dpy, c->win, scheme[c->isterminal ? SchemeTermSel : SchemeSel][ColBorder].pixel);
+ XSetWindowBorder(dpy, c->win, scheme[c->isterminal && selmon->smartbord ? SchemeTermSel : SchemeSel][ColBorder].pixel);
setfocus(c);
} else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@@ -1516,7 +1518,7 @@ manage(Window w, XWindowAttributes *wa)
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
- XSetWindowBorder(dpy, w, scheme[c->isterminal ? SchemeTermNorm : SchemeNorm][ColBorder].pixel);
+ XSetWindowBorder(dpy, w, scheme[c->isterminal && selmon->smartbord ? SchemeTermNorm : SchemeNorm][ColBorder].pixel);
configure(c); /* propagates border_width, if size doesn't change */
updatewindowtype(c);
updatesizehints(c);
@@ -2350,6 +2352,12 @@ gaptog(const Arg *arg)
}
void
+sbtog(const Arg *arg)
+{
+ selmon->smartbord = !selmon->smartbord;
+}
+
+void
setup(void)
{
int i;
@@ -2701,7 +2709,7 @@ unfocus(Client *c, int setfocus)
if (!c)
return;
grabbuttons(c, 0);
- XSetWindowBorder(dpy, c->win, scheme[c->isterminal ? SchemeTermNorm : SchemeNorm][ColBorder].pixel);
+ XSetWindowBorder(dpy, c->win, scheme[c->isterminal && selmon->smartbord ? SchemeTermNorm : SchemeNorm][ColBorder].pixel);
if (setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);