From 7e220dcb0c21e429f15ca37715450d7d5bf62081 Mon Sep 17 00:00:00 2001 From: tavo-wasd Date: Tue, 29 Nov 2022 07:55:56 -0600 Subject: [PATCH] sticky --- README.md | 3 +- config.def.h | 3 +- dwm.c | 14 +++++- patches/dwm-sticky-6.1.diff | 58 +++++++++++++++++++++++++ patches/manpatch/config.def.h.manpatch5 | 10 +++++ patches/manpatch/dwm.c.manpatch6 | 11 +++++ 6 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 patches/dwm-sticky-6.1.diff create mode 100644 patches/manpatch/config.def.h.manpatch5 create mode 100644 patches/manpatch/dwm.c.manpatch6 diff --git a/README.md b/README.md index 742ea88..d1637aa 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Applied via \*.diff files found in suckless.org, in the appearing order. Unsuccessful patches generated a \*.rej file which was moved to the corresponding "patches/manpatch/" directory for each program, and renamed \*.manpatch. This was then used to manually patch the source code. ### dwm -(2147 lines of code unpatched, added +414 lines for 2561 total) +(2147 lines of code unpatched, added +424 lines for 2571 total) - swallow - pertag - fullgaps @@ -17,6 +17,7 @@ Unsuccessful patches generated a \*.rej file which was moved to the correspondin - attachbottom - warp - alwayscenter +- sticky ## Dependencies (Archlinux names) ttf-nerd-fonts-symbols-2048-em-mono. diff --git a/config.def.h b/config.def.h index 47b4b6c..71e91e6 100644 --- a/config.def.h +++ b/config.def.h @@ -109,6 +109,7 @@ static const Key keys[] = { { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_t, togglefloating, {0} }, + { MODKEY, XK_s, togglesticky, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, @@ -137,7 +138,7 @@ static const Key keys[] = { { MODKEY, XK_p, spawn, {.v = dpower } }, { MODKEY, XK_i, spawn, {.v = dinput } }, { MODKEY|ShiftMask, XK_p, spawn, {.v = dpass } }, - { MODKEY|ShiftMask, XK_e, spawn, {.v = dexec} }, + { MODKEY, XK_e, spawn, {.v = dexec} }, { 0, XF86XK_MonBrightnessDown, spawn, {.v = brightdown } }, { 0, XF86XK_MonBrightnessUp, spawn, {.v = brightup } }, { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown } }, diff --git a/dwm.c b/dwm.c index fc336b7..be610fc 100644 --- a/dwm.c +++ b/dwm.c @@ -55,7 +55,7 @@ #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) +#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky) #define LENGTH(X) (sizeof X / sizeof X[0]) #define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define WIDTH(X) ((X)->w + 2 * (X)->bw) @@ -101,7 +101,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow, issticky; pid_t pid; Client *next; Client *snext; @@ -237,6 +237,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglesticky(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unfocus(Client *c, int setfocus); @@ -1864,6 +1865,15 @@ togglefloating(const Arg *arg) arrange(selmon); } +void +togglesticky(const Arg *arg) +{ + if (!selmon->sel) + return; + selmon->sel->issticky = !selmon->sel->issticky; + arrange(selmon); +} + void toggletag(const Arg *arg) { diff --git a/patches/dwm-sticky-6.1.diff b/patches/dwm-sticky-6.1.diff new file mode 100644 index 0000000..717793f --- /dev/null +++ b/patches/dwm-sticky-6.1.diff @@ -0,0 +1,58 @@ +diff --git a/config.def.h b/config.def.h +index 7054c06..9b5d5b8 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -76,6 +76,7 @@ static Key keys[] = { + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, ++ { MODKEY, XK_s, togglesticky, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, +diff --git a/dwm.c b/dwm.c +index 0362114..0ef5c7f 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -49,7 +49,7 @@ + #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) + #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ + * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) +-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) ++#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky) + #define LENGTH(X) (sizeof X / sizeof X[0]) + #define MOUSEMASK (BUTTONMASK|PointerMotionMask) + #define WIDTH(X) ((X)->w + 2 * (X)->bw) +@@ -92,7 +92,7 @@ struct Client { + int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int bw, oldbw; + unsigned int tags; +- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; ++ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, issticky; + Client *next; + Client *snext; + Monitor *mon; +@@ -211,6 +211,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 togglesticky(const Arg *arg); + static void toggletag(const Arg *arg); + static void toggleview(const Arg *arg); + static void unfocus(Client *c, int setfocus); +@@ -1713,6 +1714,15 @@ togglefloating(const Arg *arg) + } + + void ++togglesticky(const Arg *arg) ++{ ++ if (!selmon->sel) ++ return; ++ selmon->sel->issticky = !selmon->sel->issticky; ++ arrange(selmon); ++} ++ ++void + toggletag(const Arg *arg) + { + unsigned int newtags; diff --git a/patches/manpatch/config.def.h.manpatch5 b/patches/manpatch/config.def.h.manpatch5 new file mode 100644 index 0000000..a0b4af7 --- /dev/null +++ b/patches/manpatch/config.def.h.manpatch5 @@ -0,0 +1,10 @@ +--- config.def.h ++++ config.def.h +@@ -76,6 +76,7 @@ static Key keys[] = { + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, ++ { MODKEY, XK_s, togglesticky, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, diff --git a/patches/manpatch/dwm.c.manpatch6 b/patches/manpatch/dwm.c.manpatch6 new file mode 100644 index 0000000..fc2304a --- /dev/null +++ b/patches/manpatch/dwm.c.manpatch6 @@ -0,0 +1,11 @@ +--- dwm.c ++++ dwm.c +@@ -92,7 +92,7 @@ struct Client { + int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int bw, oldbw; + unsigned int tags; +- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; ++ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, issticky; + Client *next; + Client *snext; + Monitor *mon;