mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding float border color patch
This commit is contained in:
parent
d0757568ee
commit
5d33aebaaf
@ -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
|
||||
|
23
config.def.h
23
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} },
|
||||
|
2
drw.c
2
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;
|
||||
}
|
||||
|
4
drw.h
4
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 {
|
||||
|
70
dwm.c
70
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]);
|
||||
|
@ -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] }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
#endif
|
||||
|
@ -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
|
||||
#endif
|
||||
|
@ -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
|
||||
#endif
|
||||
|
@ -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)
|
||||
|
@ -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/
|
||||
|
Loading…
Reference in New Issue
Block a user