diff '--color=auto' -up dwm-6.3/config.def.h windowfollow-impl-6-3/config.def.h --- dwm-6.3/config.def.h 2022-01-07 11:42:18.000000000 +0000 +++ windowfollow-impl-6-3/config.def.h 2022-10-02 18:32:22.244267491 +0100 @@ -31,6 +31,11 @@ static const Rule rules[] = { { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, }; +/* window following */ +#define WFACTIVE '>' +#define WFINACTIVE 'v' +#define WFDEFAULT WFINACTIVE + /* layout(s) */ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ @@ -65,6 +70,7 @@ static Key keys[] = { { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_n, togglefollow, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, @@ -103,6 +109,7 @@ static Button buttons[] = { /* click event mask button function argument */ { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkFollowSymbol, 0, Button1, togglefollow, {0} }, { ClkWinTitle, 0, Button2, zoom, {0} }, { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, diff '--color=auto' -up dwm-6.3/dwm.1 windowfollow-impl-6-3/dwm.1 --- dwm-6.3/dwm.1 2022-01-07 11:42:18.000000000 +0000 +++ windowfollow-impl-6-3/dwm.1 2022-10-02 18:32:22.244267491 +0100 @@ -44,7 +44,8 @@ command. .TP .B Button1 click on a tag label to display all windows with that tag, click on the layout -label toggles between tiled and floating layout. +label toggles between tiled and floating layout, click on the window follow +icon toggles it on and off. .TP .B Button3 click on a tag label adds/removes all windows with that tag to/from the view. @@ -80,6 +81,9 @@ Send focused window to next screen, if a .B Mod1\-b Toggles bar on and off. .TP +.B Mod1\-n +Toggles window following on and off. +.TP .B Mod1\-t Sets tiled layout. .TP diff '--color=auto' -up dwm-6.3/dwm.c windowfollow-impl-6-3/dwm.c --- dwm-6.3/dwm.c 2022-01-07 11:42:18.000000000 +0000 +++ windowfollow-impl-6-3/dwm.c 2022-10-02 18:32:22.244267491 +0100 @@ -65,7 +65,7 @@ enum { NetSupported, NetWMName, NetWMSta NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, - ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ + ClkClientWin, ClkRootWin, ClkFollowSymbol, ClkLast }; /* clicks */ typedef union { int i; @@ -113,6 +113,7 @@ typedef struct { struct Monitor { char ltsymbol[16]; + char wfsymbol[2]; float mfact; int nmaster; int num; @@ -212,6 +213,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglefollow(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unfocus(Client *c, int setfocus); @@ -440,6 +442,8 @@ buttonpress(XEvent *e) arg.ui = 1 << i; } else if (ev->x < x + blw) click = ClkLtSymbol; + else if (ev->x < x + blw + TEXTW(selmon->wfsymbol)) + click = ClkFollowSymbol; else if (ev->x > selmon->ww - (int)TEXTW(stext)) click = ClkStatusText; else @@ -642,6 +646,8 @@ createmon(void) m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + m->wfsymbol[0] = WFDEFAULT; + m->wfsymbol[1] = '\0'; return m; } @@ -732,6 +738,9 @@ drawbar(Monitor *m) drw_setscheme(drw, scheme[SchemeNorm]); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); + w = TEXTW(m->wfsymbol); + x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->wfsymbol, 0); + if ((w = m->ww - tw - x) > bh) { if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); @@ -1664,6 +1673,8 @@ tag(const Arg *arg) focus(NULL); arrange(selmon); } + if (selmon->wfsymbol[0] == WFACTIVE) + view(arg); } void @@ -1672,6 +1683,8 @@ tagmon(const Arg *arg) if (!selmon->sel || !mons->next) return; sendmon(selmon->sel, dirtomon(arg->i)); + if (selmon->wfsymbol[0] == WFACTIVE) + focusmon(arg); } void @@ -1712,6 +1725,13 @@ togglebar(const Arg *arg) } void +togglefollow(const Arg *arg) +{ + selmon->wfsymbol[0] = (selmon->wfsymbol[0] == WFACTIVE) ? WFINACTIVE : WFACTIVE; + drawbars(); +} + +void togglefloating(const Arg *arg) { if (!selmon->sel)