My configuration of sxmo fork of suckless dwm.

git clone git://watertao.xyz/programs/sxmo-dwm.git

commit 88d7fe12902b83257e6ed3e181672f2669e3c37a
parent e9728a337a0199acb974ef5be024e26af3464e05
Author: Miles Alan <m@milesalan.com>
Date:   Sat, 25 Apr 2020 17:53:41 -0500

Add dragmfact

Diffstat:
Mconfig.def.h | 4++++
Mdwm.c | 32+++++++++++++++++++++++---------
2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -145,5 +145,9 @@ static Button buttons[] = { { ClkTagBar, 0, Button1, view, {0} }, { ClkLtSymbol, 0, Button1, cyclelayout, {.i = +1} }, { ClkStatusText, 0, Button1, spawn, SHCMD("sxmo_appmenu.sh control") }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, }; diff --git a/dwm.c b/dwm.c @@ -1675,7 +1675,16 @@ resizemouse(const Arg *arg) if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) return; - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + } else { + XWarpPointer(dpy, None, root, 0, 0, 0, 0, + selmon->mx + (selmon->ww * selmon->mfact), + selmon->my + (selmon->wh / 2) + ); + } + do { XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); switch(ev.type) { @@ -1691,19 +1700,24 @@ resizemouse(const Arg *arg) nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); - if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww - && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) - { - if (!c->isfloating && selmon->lt[selmon->sellt]->arrange - && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) - togglefloating(NULL); - } + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) resize(c, c->x, c->y, nw, nh, 1); break; } } while (ev.type != ButtonRelease); - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + } else { + selmon->mfact = (double) (ev.xmotion.x_root - selmon->mx) / (double) selmon->ww; + arrange(selmon); + XWarpPointer(dpy, None, root, 0, 0, 0, 0, + selmon->mx + (selmon->ww * selmon->mfact), + selmon->my + (selmon->wh / 2) + ); + } + XUngrabPointer(dpy, CurrentTime); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {