summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-09-11 00:51:37 +0200
committerbakkeby <[email protected]>2019-09-11 00:51:37 +0200
commit5d33aebaafbc042cf576a76fbdf4ae64ef5cfff1 (patch)
tree2353a6e57314546ef121e2d5f25b9c34c4297940
parentd0757568ee2680e50d142a32ec7c759439431399 (diff)
downloaddwm-flexipatch-5d33aebaafbc042cf576a76fbdf4ae64ef5cfff1.tar.gz
dwm-flexipatch-5d33aebaafbc042cf576a76fbdf4ae64ef5cfff1.zip
Adding float border color patch
-rw-r--r--README.md7
-rw-r--r--config.def.h23
-rw-r--r--drw.c2
-rw-r--r--drw.h4
-rw-r--r--dwm.c70
-rw-r--r--patch/cyclelayouts.c13
-rw-r--r--patch/fibonacci.c4
-rw-r--r--patch/gapplessgrid.c21
-rw-r--r--patch/horizgrid.c14
-rw-r--r--patch/systray.c16
-rw-r--r--patches.h5
11 files changed, 121 insertions, 58 deletions
diff --git a/README.md b/README.md
index fac315e..1fc7c7e 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-This side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more.
+This dwm 6.2 side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more.
For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.h):
```c
@@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-09-10 - Minor tweaks to awesomebar patch (incl. alpha and systray compatibility).
+2019-09-10 - Minor tweaks to awesomebar patch (incl. alpha and systray compatibility). Added floatbordercolor patch.
2019-09-09 - Added deck, fibonacci (dwindle and spiral), gridmode, gapplessgrid, horizgrid, nrowgrid, centeredmaster and flextile layouts. Added alternativetags and awesomebar patches.
@@ -63,6 +63,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [fancybar](https://dwm.suckless.org/patches/fancybar/)
- shows the titles of all visible windows in the status bar
+ - [floatbordercolor](https://dwm.suckless.org/patches/float_border_color/)
+ - this patch allows a different border color to be chosen for floating windows
+
- [focusonnetactive](https://dwm.suckless.org/patches/focusonnetactive/)
- by default, dwm responds to \_NET_ACTIVE_WINDOW client messages by setting the urgency bit on the named window
- this patch activates the window instead
diff --git a/config.def.h b/config.def.h
index 55cb61d..2ced165 100644
--- a/config.def.h
+++ b/config.def.h
@@ -32,16 +32,26 @@ static const char col_cyan[] = "#005577";
#if ALPHA_PATCH
static const unsigned int baralpha = 0xd0;
static const unsigned int borderalpha = OPAQUE;
-static const unsigned int alphas[][3] = {
+static const unsigned int alphas[][3] = {
/* fg bg border */
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
#if AWESOMEBAR_PATCH
- [SchemeHid] = { OPAQUE, baralpha, borderalpha },
+ [SchemeHid] = { OPAQUE, baralpha, borderalpha },
#endif // AWESOMEBAR_PATCH
};
#endif // ALPHA_PATCH
-static const char *colors[][3] = {
+#if FLOAT_BORDER_COLOR_PATCH
+static const char *colors[][4] = {
+ /* fg bg border float */
+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2, col_gray2 },
+ [SchemeSel] = { col_gray4, col_cyan, col_cyan, col_cyan },
+ #if AWESOMEBAR_PATCH
+ [SchemeHid] = { col_cyan, col_gray1, col_cyan, col_cyan },
+ #endif // AWESOMEBAR_PATCH
+};
+#else
+static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
@@ -49,6 +59,7 @@ static const char *colors[][3] = {
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
#endif // AWESOMEBAR_PATCH
};
+#endif // FLOAT_BORDER_COLOR_PATCH
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@@ -238,9 +249,9 @@ static Key keys[] = {
{ MODKEY|ControlMask, XK_e, setflexlayout, {.i = 262 } }, // deck layout
{ MODKEY|ControlMask, XK_r, setflexlayout, {.i = 6 } }, // monocle
{ MODKEY|ControlMask, XK_g, setflexlayout, {.i = 257 } }, // columns (col) layout
- { MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = 0 } }, /* flextile, 0 = layout axis */
- { MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = 1 } }, /* flextile, 1 = master axis */
- { MODKEY|ControlMask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = 2 } }, /* flextile, 2 = stack axis */
+ { MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = 0 } }, /* flextile, 0 = layout axis */
+ { MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = 1 } }, /* flextile, 1 = master axis */
+ { MODKEY|ControlMask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = 2 } }, /* flextile, 2 = stack axis */
{ MODKEY|ControlMask, XK_Return, mirrorlayout, {0} }, /* flextile, flip master and stack areas */
#endif // FLEXTILE_LAYOUT
{ MODKEY, XK_space, setlayout, {0} },
diff --git a/drw.c b/drw.c
index 0b2da00..1d55382 100644
--- a/drw.c
+++ b/drw.c
@@ -158,7 +158,7 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
* and lots more all over the internet.
*/
FcBool iscol;
- if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
+ if (FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
XftFontClose(drw->dpy, xfont);
return NULL;
}
diff --git a/drw.h b/drw.h
index 021d3eb..5a02232 100644
--- a/drw.h
+++ b/drw.h
@@ -12,7 +12,11 @@ typedef struct Fnt {
struct Fnt *next;
} Fnt;
+#if FLOAT_BORDER_COLOR_PATCH
+enum { ColFg, ColBg, ColBorder, ColFloat }; /* Clr scheme index */
+#else
enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
+#endif // FLOAT_BORDER_COLOR_PATCH
typedef XftColor Clr;
typedef struct {
diff --git a/dwm.c b/dwm.c
index a309de1..68d2c3b 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1064,7 +1064,7 @@ drawbar(Monitor *m)
if (!ISVISIBLE(c) || c == m->sel)
continue;
tw = TEXTW(c->name);
- if(tw < mw)
+ if (tw < mw)
ew += (mw - tw);
else
i++;
@@ -1117,8 +1117,21 @@ drawbars(void)
{
Monitor *m;
+ #if SYSTRAY_PATCH
+ if (showsystray) {
+ /* Clear status bar to avoid artifacts beneath systray icons */
+ drw_rect(drw, 0, 0, selmon->ww, bh, 1, 1);
+ drw_map(drw, selmon->barwin, 0, 0, selmon->ww, bh);
+ }
+ #endif // SYSTRAY_PATCH
+
for (m = mons; m; m = m->next)
drawbar(m);
+
+ #if SYSTRAY_PATCH
+ if (showsystray)
+ updatesystray();
+ #endif // SYSTRAY_PATCH
}
void
@@ -1175,7 +1188,14 @@ focus(Client *c)
detachstack(c);
attachstack(c);
grabbuttons(c, 1);
+ #if FLOAT_BORDER_COLOR_PATCH
+ if (c->isfloating)
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColFloat].pixel);
+ else
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ #else
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ #endif // FLOAT_BORDER_COLOR_PATCH
setfocus(c);
} else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@@ -1197,21 +1217,8 @@ focusin(XEvent *e)
{
XFocusChangeEvent *ev = &e->xfocus;
- #if SYSTRAY_PATCH && !AWESOMEBAR_PATCH
- if (showsystray) {
- /* Clear status bar to avoid artifacts beneath systray icons */
- drw_rect(drw, 0, 0, selmon->ww, bh, 1, 1);
- drw_map(drw, selmon->barwin, 0, 0, selmon->ww, bh);
- }
- #endif // SYSTRAY_PATCH
-
if (selmon->sel && ev->window != selmon->sel->win)
setfocus(selmon->sel);
-
- #if SYSTRAY_PATCH
- if (showsystray)
- updatesystray();
- #endif // SYSTRAY_PATCH
}
void
@@ -1477,7 +1484,14 @@ manage(Window w, XWindowAttributes *wa)
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ #if FLOAT_BORDER_COLOR_PATCH
+ if (c->isfloating)
+ XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColFloat].pixel);
+ else
+ XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
+ #else
XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
+ #endif // FLOAT_BORDER_COLOR_PATCH
configure(c); /* propagates border_width, if size doesn't change */
updatewindowtype(c);
updatesizehints(c);
@@ -1501,6 +1515,10 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating)
XRaiseWindow(dpy, c->win);
+ #if FLOAT_BORDER_COLOR_PATCH
+ if (c->isfloating)
+ XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColFloat].pixel);
+ #endif // FLOAT_BORDER_COLOR_PATCH
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH
attachx(c);
#else
@@ -2175,11 +2193,16 @@ setup(void)
/* init appearance */
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
for (i = 0; i < LENGTH(colors); i++)
+ scheme[i] = drw_scm_create(drw, colors[i],
#if ALPHA_PATCH
- scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
- #else
- scheme[i] = drw_scm_create(drw, colors[i], 3);
+ alphas[i],
#endif // ALPHA_PATCH
+ #if FLOAT_BORDER_COLOR_PATCH
+ 4
+ #else
+ 3
+ #endif // FLOAT_BORDER_COLOR_PATCH
+ );
#if SYSTRAY_PATCH
/* init system tray */
if (showsystray)
@@ -2338,6 +2361,12 @@ togglefloating(const Arg *arg)
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
+ #if FLOAT_BORDER_COLOR_PATCH
+ if (selmon->sel->isfloating)
+ XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColFloat].pixel);
+ else
+ XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColBorder].pixel);
+ #endif // FLOAT_BORDER_COLOR_PATCH
if (selmon->sel->isfloating) {
#if SAVEFLOATS_PATCH
if (selmon->sel->sfx != -9999) {
@@ -2422,7 +2451,14 @@ unfocus(Client *c, int setfocus)
if (!c)
return;
grabbuttons(c, 0);
+ #if FLOAT_BORDER_COLOR_PATCH
+ if (c->isfloating)
+ XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColFloat].pixel);
+ else
+ XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
+ #else
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
+ #endif // FLOAT_BORDER_COLOR_PATCH
if (setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
diff --git a/patch/cyclelayouts.c b/patch/cyclelayouts.c
index 4fdc873..bd33bfe 100644
--- a/patch/cyclelayouts.c
+++ b/patch/cyclelayouts.c
@@ -1,16 +1,17 @@
void
-cyclelayout(const Arg *arg) {
+cyclelayout(const Arg *arg)
+{
Layout *l;
- for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
- if(arg->i > 0) {
- if(l->symbol && (l + 1)->symbol)
+ for (l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
+ if (arg->i > 0) {
+ if (l->symbol && (l + 1)->symbol)
setlayout(&((Arg) { .v = (l + 1) }));
else
setlayout(&((Arg) { .v = layouts }));
} else {
- if(l != layouts && (l - 1)->symbol)
+ if (l != layouts && (l - 1)->symbol)
setlayout(&((Arg) { .v = (l - 1) }));
else
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
}
-} \ No newline at end of file
+}
diff --git a/patch/fibonacci.c b/patch/fibonacci.c
index bc911a9..a8f3a06 100644
--- a/patch/fibonacci.c
+++ b/patch/fibonacci.c
@@ -90,7 +90,7 @@ fibonacci(Monitor *mon, int s)
ny += nh;
}
if ((i % 4) == 0) {
- if(s)
+ if (s)
ny += nh;
else
ny -= nh;
@@ -134,4 +134,4 @@ spiral(Monitor *m)
{
fibonacci(m, 0);
}
-#endif \ No newline at end of file
+#endif
diff --git a/patch/gapplessgrid.c b/patch/gapplessgrid.c
index 52cb627..2757ac4 100644
--- a/patch/gapplessgrid.c
+++ b/patch/gapplessgrid.c
@@ -39,19 +39,20 @@ gaplessgrid(Monitor *m)
}
#else
void
-gaplessgrid(Monitor *m) {
+gaplessgrid(Monitor *m)
+{
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
Client *c;
- for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
- if(n == 0)
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
+ if (n == 0)
return;
/* grid dimensions */
- for(cols = 0; cols <= n/2; cols++)
- if(cols*cols >= n)
+ for (cols = 0; cols <= n/2; cols++)
+ if (cols*cols >= n)
break;
- if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2;
rows = n/cols;
@@ -59,18 +60,18 @@ gaplessgrid(Monitor *m) {
cw = cols ? m->ww / cols : m->ww;
cn = 0; /* current column number */
rn = 0; /* current row number */
- for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
- if(i/rows + 1 > cols - n%cols)
+ for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
+ if (i/rows + 1 > cols - n%cols)
rows = n/cols + 1;
ch = rows ? m->wh / rows : m->wh;
cx = m->wx + cn*cw;
cy = m->wy + rn*ch;
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
rn++;
- if(rn >= rows) {
+ if (rn >= rows) {
rn = 0;
cn++;
}
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/patch/horizgrid.c b/patch/horizgrid.c
index 60eea1c..586a2b0 100644
--- a/patch/horizgrid.c
+++ b/patch/horizgrid.c
@@ -55,14 +55,14 @@ horizgrid(Monitor *m) {
int ntop, nbottom = 0;
/* Count windows */
- for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
- if(n == 0)
+ if (n == 0)
return;
- else if(n == 1) { /* Just fill the whole screen */
+ else if (n == 1) { /* Just fill the whole screen */
c = nexttiled(m->clients);
resize(c, m->wx, m->wy, m->ww - (2*c->bw), m->wh - (2*c->bw), False);
- } else if(n == 2) { /* Split vertically */
+ } else if (n == 2) { /* Split vertically */
w = m->ww / 2;
c = nexttiled(m->clients);
resize(c, m->wx, m->wy, w - (2*c->bw), m->wh - (2*c->bw), False);
@@ -71,12 +71,12 @@ horizgrid(Monitor *m) {
} else {
ntop = n / 2;
nbottom = n - ntop;
- for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
- if(i < ntop)
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < ntop)
resize(c, m->wx + i * m->ww / ntop, m->wy, m->ww / ntop - (2*c->bw), m->wh / 2 - (2*c->bw), False);
else
resize(c, m->wx + (i - ntop) * m->ww / nbottom, m->wy + m->wh / 2, m->ww / nbottom - (2*c->bw), m->wh / 2 - (2*c->bw), False);
}
}
}
-#endif \ No newline at end of file
+#endif
diff --git a/patch/systray.c b/patch/systray.c
index c96509d..0e70539 100644
--- a/patch/systray.c
+++ b/patch/systray.c
@@ -38,17 +38,18 @@ resizerequest(XEvent *e)
}
Monitor *
-systraytomon(Monitor *m) {
+systraytomon(Monitor *m)
+{
Monitor *t;
int i, n;
- if(!systraypinning) {
- if(!m)
+ if (!systraypinning) {
+ if (!m)
return selmon;
return m == selmon ? m : NULL;
}
- for(n = 1, t = mons; t && t->next; n++, t = t->next) ;
- for(i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next) ;
- if(systraypinningfailfirst && n < systraypinning)
+ for (n = 1, t = mons; t && t->next; n++, t = t->next) ;
+ for (i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next) ;
+ if (systraypinningfailfirst && n < systraypinning)
return mons;
return t;
}
@@ -184,7 +185,8 @@ updatesystrayiconstate(Client *i, XPropertyEvent *ev)
}
Client *
-wintosystrayicon(Window w) {
+wintosystrayicon(Window w)
+{
Client *i = NULL;
if (!showsystray || !w)
diff --git a/patches.h b/patches.h
index 7d3ab4f..f32faed 100644
--- a/patches.h
+++ b/patches.h
@@ -85,6 +85,11 @@
*/
#define FANCYBAR_PATCH 0
+/* This patch allows a different border color to be chosen for floating windows.
+ * https://dwm.suckless.org/patches/float_border_color/
+ */
+#define FLOAT_BORDER_COLOR_PATCH 0
+
/* By default, dwm responds to _NET_ACTIVE_WINDOW client messages by setting
* the urgency bit on the named window. This patch activates the window instead.
* https://dwm.suckless.org/patches/focusonnetactive/