Adding dragfact patch (combines dragmfact and dragcfact) - dwm - 🖥 my version of dwm (frankenstein's monster)
 (HTM) git clone https://git.drkhsh.at/dwm.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9cf0e488f24d46cfde4fa605fb833650f2f8a355
 (DIR) parent e5931eabb3a21b05bd29e212e04cac62bc7883ac
 (HTM) Author: drkhsh <me@drkhsh.at>
       Date:   Mon, 12 Sep 2022 12:47:08 +0200
       
       Adding dragfact patch (combines dragmfact and dragcfact)
       
       https://github.com/bakkeby/patches/blob/82b0568c4c0db3cac5bc6d51ee62f1f2c737e998/dwm/dwm-dragfact-6.3.diff
       
       Diffstat:
         M config.def.h                        |       3 ++-
         M dwm.c                               |      88 ++++++++++++++++++++++++++++++-
       
       2 files changed, 89 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/config.def.h b/config.def.h
       @@ -161,7 +161,8 @@ static const Button buttons[] = {
                { ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
                { ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
                { ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
       -        { ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
       +        { ClkClientWin,         MODKEY,         Button3,        resizeorfacts,  {0} },
       +        { ClkClientWin,       MODKEY|ShiftMask, Button3,        resizemouse,    {0} },
                { ClkTagBar,            0,              Button1,        view,           {0} },
                { ClkTagBar,            0,              Button3,        toggleview,     {0} },
                { ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
 (DIR) diff --git a/dwm.c b/dwm.c
       @@ -57,7 +57,7 @@
        #define TEXTW(X)                (drw_fontset_getwidth(drw, (X)) + lrpad)
        
        /* enums */
       -enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
       +enum { CurNormal, CurResize, CurMove, CurDragFact, CurLast }; /* cursor */
        enum { SchemeNorm, SchemeSel }; /* color schemes */
        enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
               NetWMFullscreen, NetActiveWindow, NetWMWindowType,
       @@ -177,6 +177,7 @@ static void destroynotify(XEvent *e);
        static void detach(Client *c);
        static void detachstack(Client *c);
        static Monitor *dirtomon(int dir);
       +static void dragfact(const Arg *arg);
        static void drawbar(Monitor *m);
        static void drawbars(void);
        static void enternotify(XEvent *e);
       @@ -208,6 +209,7 @@ static Monitor *recttomon(int x, int y, int w, int h);
        static void resize(Client *c, int x, int y, int w, int h, int interact);
        static void resizeclient(Client *c, int x, int y, int w, int h);
        static void resizemouse(const Arg *arg);
       +static void resizeorfacts(const Arg *arg);
        static void restack(Monitor *m);
        static void run(void);
        static void scan(void);
       @@ -780,6 +782,75 @@ dirtomon(int dir)
        }
        
        void
       +dragfact(const Arg *arg)
       +{
       +        unsigned int n;
       +        int px, py; // pointer coordinates
       +        int dist_x, dist_y;
       +        int horizontal = 0; // layout configuration
       +        float mfact, cfact, cf, cw, ch, mw, mh;
       +        Client *c;
       +        Monitor *m = selmon;
       +        XEvent ev;
       +        Time lasttime = 0;
       +
       +        for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
       +        if (!(c = m->sel) || !n || !m->lt[m->sellt]->arrange)
       +                return;
       +
       +        /* Add custom handling for horizontal layouts here, e.g. */
       +        // if (m->lt[m->sellt]->arrange == bstack)
       +        //         horizontal = 1;
       +
       +        if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
       +                None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
       +                return;
       +
       +        if (!getrootptr(&px, &py))
       +                return;
       +
       +        cf = c->cfact;
       +        ch = c->h;
       +        cw = c->w;
       +        mw = m->ww * m->mfact;
       +        mh = m->wh * m->mfact;
       +
       +        do {
       +                XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
       +                switch (ev.type) {
       +                case ConfigureRequest:
       +                case Expose:
       +                case MapRequest:
       +                        handler[ev.type](&ev);
       +                        break;
       +                case MotionNotify:
       +                        if ((ev.xmotion.time - lasttime) <= (1000 / 40))
       +                                continue;
       +                        lasttime = ev.xmotion.time;
       +
       +                        dist_x = ev.xmotion.x - px;
       +                        dist_y = ev.xmotion.y - py;
       +
       +                        if (horizontal) {
       +                                cfact = (float) cf * (cw + dist_x) / cw;
       +                                mfact = (float) (mh + dist_y) / m->wh;
       +                        } else {
       +                                cfact = (float) cf * (ch - dist_y) / ch;
       +                                mfact = (float) (mw + dist_x) / m->ww;
       +                        }
       +
       +                        c->cfact = MAX(0.25, MIN(4.0, cfact));
       +                        m->mfact = MAX(0.05, MIN(0.95, mfact));
       +                        arrangemon(m);
       +                        break;
       +                }
       +        } while (ev.type != ButtonRelease);
       +
       +        XUngrabPointer(dpy, CurrentTime);
       +        while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
       +}
       +
       +void
        drawbar(Monitor *m)
        {
                int x, w, tw = 0;
       @@ -1445,6 +1516,20 @@ resizemouse(const Arg *arg)
        }
        
        void
       +resizeorfacts(const Arg *arg)
       +{
       +        Monitor *m = selmon;
       +
       +        if (!m->sel)
       +                return;
       +
       +        if (!m->lt[m->sellt]->arrange || m->sel->isfloating)
       +                resizemouse(arg);
       +        else
       +                dragfact(arg);
       +}
       +
       +void
        restack(Monitor *m)
        {
                Client *c;
       @@ -1701,6 +1786,7 @@ setup(void)
                cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
                cursor[CurResize] = drw_cur_create(drw, XC_sizing);
                cursor[CurMove] = drw_cur_create(drw, XC_fleur);
       +        cursor[CurDragFact] = drw_cur_create(drw, XC_rightbutton);
                /* init appearance */
                scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
                for (i = 0; i < LENGTH(colors); i++)