Adding float border color patch

This commit is contained in:
bakkeby 2019-09-11 00:51:37 +02:00
parent d0757568ee
commit 5d33aebaaf
11 changed files with 121 additions and 58 deletions

View File

@ -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): 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 ```c
@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### 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. 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/) - [fancybar](https://dwm.suckless.org/patches/fancybar/)
- shows the titles of all visible windows in the status bar - 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/) - [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 - 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 - this patch activates the window instead

View File

@ -41,6 +41,16 @@ static const unsigned int alphas[][3] = {
#endif // AWESOMEBAR_PATCH #endif // AWESOMEBAR_PATCH
}; };
#endif // ALPHA_PATCH #endif // ALPHA_PATCH
#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] = { static const char *colors[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
@ -49,6 +59,7 @@ static const char *colors[][3] = {
[SchemeHid] = { col_cyan, col_gray1, col_cyan }, [SchemeHid] = { col_cyan, col_gray1, col_cyan },
#endif // AWESOMEBAR_PATCH #endif // AWESOMEBAR_PATCH
}; };
#endif // FLOAT_BORDER_COLOR_PATCH
/* tagging */ /* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

4
drw.h
View File

@ -12,7 +12,11 @@ typedef struct Fnt {
struct Fnt *next; struct Fnt *next;
} Fnt; } Fnt;
#if FLOAT_BORDER_COLOR_PATCH
enum { ColFg, ColBg, ColBorder, ColFloat }; /* Clr scheme index */
#else
enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */ enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
#endif // FLOAT_BORDER_COLOR_PATCH
typedef XftColor Clr; typedef XftColor Clr;
typedef struct { typedef struct {

68
dwm.c
View File

@ -1117,8 +1117,21 @@ drawbars(void)
{ {
Monitor *m; 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) for (m = mons; m; m = m->next)
drawbar(m); drawbar(m);
#if SYSTRAY_PATCH
if (showsystray)
updatesystray();
#endif // SYSTRAY_PATCH
} }
void void
@ -1175,7 +1188,14 @@ focus(Client *c)
detachstack(c); detachstack(c);
attachstack(c); attachstack(c);
grabbuttons(c, 1); 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); XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
#else
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
#endif // FLOAT_BORDER_COLOR_PATCH
setfocus(c); setfocus(c);
} else { } else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@ -1197,21 +1217,8 @@ focusin(XEvent *e)
{ {
XFocusChangeEvent *ev = &e->xfocus; 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) if (selmon->sel && ev->window != selmon->sel->win)
setfocus(selmon->sel); setfocus(selmon->sel);
#if SYSTRAY_PATCH
if (showsystray)
updatesystray();
#endif // SYSTRAY_PATCH
} }
void void
@ -1477,7 +1484,14 @@ manage(Window w, XWindowAttributes *wa)
wc.border_width = c->bw; wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc); 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); 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 */ configure(c); /* propagates border_width, if size doesn't change */
updatewindowtype(c); updatewindowtype(c);
updatesizehints(c); updatesizehints(c);
@ -1501,6 +1515,10 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed; c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating) if (c->isfloating)
XRaiseWindow(dpy, c->win); 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 #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH
attachx(c); attachx(c);
#else #else
@ -2175,11 +2193,16 @@ setup(void)
/* init appearance */ /* init appearance */
scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
for (i = 0; i < LENGTH(colors); i++) for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i],
#if ALPHA_PATCH #if ALPHA_PATCH
scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3); alphas[i],
#else
scheme[i] = drw_scm_create(drw, colors[i], 3);
#endif // ALPHA_PATCH #endif // ALPHA_PATCH
#if FLOAT_BORDER_COLOR_PATCH
4
#else
3
#endif // FLOAT_BORDER_COLOR_PATCH
);
#if SYSTRAY_PATCH #if SYSTRAY_PATCH
/* init system tray */ /* init system tray */
if (showsystray) if (showsystray)
@ -2338,6 +2361,12 @@ togglefloating(const Arg *arg)
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
return; return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; 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 (selmon->sel->isfloating) {
#if SAVEFLOATS_PATCH #if SAVEFLOATS_PATCH
if (selmon->sel->sfx != -9999) { if (selmon->sel->sfx != -9999) {
@ -2422,7 +2451,14 @@ unfocus(Client *c, int setfocus)
if (!c) if (!c)
return; return;
grabbuttons(c, 0); 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); XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
#else
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
#endif // FLOAT_BORDER_COLOR_PATCH
if (setfocus) { if (setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]); XDeleteProperty(dpy, root, netatom[NetActiveWindow]);

View File

@ -1,5 +1,6 @@
void void
cyclelayout(const Arg *arg) { cyclelayout(const Arg *arg)
{
Layout *l; Layout *l;
for (l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++); for (l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
if (arg->i > 0) { if (arg->i > 0) {

View File

@ -39,7 +39,8 @@ gaplessgrid(Monitor *m)
} }
#else #else
void void
gaplessgrid(Monitor *m) { gaplessgrid(Monitor *m)
{
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch; unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
Client *c; Client *c;

View File

@ -38,7 +38,8 @@ resizerequest(XEvent *e)
} }
Monitor * Monitor *
systraytomon(Monitor *m) { systraytomon(Monitor *m)
{
Monitor *t; Monitor *t;
int i, n; int i, n;
if (!systraypinning) { if (!systraypinning) {
@ -184,7 +185,8 @@ updatesystrayiconstate(Client *i, XPropertyEvent *ev)
} }
Client * Client *
wintosystrayicon(Window w) { wintosystrayicon(Window w)
{
Client *i = NULL; Client *i = NULL;
if (!showsystray || !w) if (!showsystray || !w)

View File

@ -85,6 +85,11 @@
*/ */
#define FANCYBAR_PATCH 0 #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 /* 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. * the urgency bit on the named window. This patch activates the window instead.
* https://dwm.suckless.org/patches/focusonnetactive/ * https://dwm.suckless.org/patches/focusonnetactive/