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):
```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

View File

@ -41,6 +41,16 @@ static const unsigned int alphas[][3] = {
#endif // AWESOMEBAR_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] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
@ -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" };

4
drw.h
View File

@ -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 {

68
dwm.c
View File

@ -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]);

View File

@ -1,5 +1,6 @@
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) {

View File

@ -39,7 +39,8 @@ 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;

View File

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

View File

@ -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/