[dwm][patches][layoutscroll] add patch for 6.5, fix possible segfault - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit a7f46eed7ad54c3afc47ca7b130020dd80898d58
 (DIR) parent 34d11146ed1e6139c29c6c14f11256a28793ba75
 (HTM) Author: Fyodor Doletov <doletov.fyodor@yandex.ru>
       Date:   Mon, 28 Jul 2025 05:16:33 +0300
       
       [dwm][patches][layoutscroll] add patch for 6.5, fix possible segfault
       
       Diffstat:
         A dwm.suckless.org/patches/layoutscr… |      67 +++++++++++++++++++++++++++++++
         M dwm.suckless.org/patches/layoutscr… |       5 ++++-
       
       2 files changed, 71 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/dwm.suckless.org/patches/layoutscroll/dwm-layoutscroll-6.5.diff b/dwm.suckless.org/patches/layoutscroll/dwm-layoutscroll-6.5.diff
       @@ -0,0 +1,67 @@
       +diff --git a/config.def.h b/config.def.h
       +index 9efa774..d06afaf 100644
       +--- a/config.def.h
       ++++ b/config.def.h
       +@@ -85,6 +85,8 @@ static const Key keys[] = {
       +         { MODKEY,                       XK_period, focusmon,       {.i = +1 } },
       +         { MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
       +         { MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
       ++        { MODKEY|ShiftMask,             XK_h,      layoutscroll,   {.i = -1 } },
       ++        { MODKEY|ShiftMask,             XK_l,      layoutscroll,   {.i = +1 } },
       +         TAGKEYS(                        XK_1,                      0)
       +         TAGKEYS(                        XK_2,                      1)
       +         TAGKEYS(                        XK_3,                      2)
       +diff --git a/dwm.c b/dwm.c
       +index 1443802..b2271d9 100644
       +--- a/dwm.c
       ++++ b/dwm.c
       +@@ -129,6 +129,7 @@ struct Monitor {
       +         Monitor *next;
       +         Window barwin;
       +         const Layout *lt[2];
       ++        int ltcur; /* current layout */
       + };
       + 
       + typedef struct {
       +@@ -199,6 +200,7 @@ static void sendmon(Client *c, Monitor *m);
       + static void setclientstate(Client *c, long state);
       + static void setfocus(Client *c);
       + static void setfullscreen(Client *c, int fullscreen);
       ++static void layoutscroll(const Arg *arg);
       + static void setlayout(const Arg *arg);
       + static void setmfact(const Arg *arg);
       + static void setup(void);
       +@@ -640,6 +642,7 @@ createmon(void)
       +         m->nmaster = nmaster;
       +         m->showbar = showbar;
       +         m->topbar = topbar;
       ++        m->ltcur = 0;
       +         m->lt[0] = &layouts[0];
       +         m->lt[1] = &layouts[1 % LENGTH(layouts)];
       +         strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
       +@@ -1506,6 +1509,25 @@ setfullscreen(Client *c, int fullscreen)
       +         }
       + }
       + 
       ++void
       ++layoutscroll(const Arg *arg)
       ++{
       ++        if (!arg || !arg->i)
       ++                return;
       ++        int switchto = selmon->ltcur + arg->i;
       ++        int l = LENGTH(layouts);
       ++
       ++        if (switchto >= l)
       ++                switchto = 0;
       ++        else if(switchto < 0)
       ++                switchto = l - 1;
       ++
       ++        selmon->ltcur = switchto;
       ++        Arg arg2 = {.v= &layouts[switchto] };
       ++        setlayout(&arg2);
       ++
       ++}
       ++
       + void
       + setlayout(const Arg *arg)
       + {
 (DIR) diff --git a/dwm.suckless.org/patches/layoutscroll/index.md b/dwm.suckless.org/patches/layoutscroll/index.md
       @@ -9,7 +9,10 @@ This patch is different from [cyclelayouts](../cyclelayouts) patch, because it d
        Download
        --------
        * [dwm-layoutscroll-6.2.diff](dwm-layoutscroll-6.2.diff)
       +* [dwm-layoutscroll-6.5.diff](dwm-layoutscroll-6.5.diff)
        
       -Author
       +Authors
        --------
        * Fyodor Doletov - <doletov.fyodor@yandex.ru>
       +* JeffOfBread - <JeffOfBreadCoding@gmail.com>
       +