From 9e53b46e35b09533448b8c58d7ec5727ad978e87 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Thu, 24 Oct 2019 06:52:00 +0200 Subject: [PATCH] Adding dragmfact patch --- README.md | 5 +++++ dwm.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- patches.h | 7 +++++++ 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 77ca856..195aa35 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2019-10-24 - Added dragmfact patch + 2019-10-22 - Added ispermanent and swallow patches 2019-10-16 - Introduced [flexipatch-finalizer](https://github.com/bakkeby/flexipatch-finalizer) @@ -113,6 +115,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/) - lets you cycle through all your layouts + - [dragmfact](https://dwm.suckless.org/patches/dragmfact/) + - lets you resize the split in the tile layout (i.e. modify mfact) by holding the modkey and dragging the mouse + - [dwmc](http://dwm.suckless.org/patches/dwmc/) - a simple dwmc client using a fork of fsignal to communicate with dwm diff --git a/dwm.c b/dwm.c index 56e9d21..6baee23 100644 --- a/dwm.c +++ b/dwm.c @@ -2333,9 +2333,25 @@ resizemouse(const Arg *arg) return; horizcorner = nx < c->w / 2; vertcorner = ny < c->h / 2; + #if DRAGMFACT_PATCH + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { + XWarpPointer (dpy, None, c->win, 0, 0, 0, 0, + horizcorner ? (-c->bw) : (c->w + c->bw - 1), + vertcorner ? (-c->bw) : (c->h + c->bw - 1)); + } else { + XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->mw * selmon->mfact, selmon->mh / 2); + } + #else XWarpPointer (dpy, None, c->win, 0, 0, 0, 0, - horizcorner ? (-c->bw) : (c->w + c->bw - 1), - vertcorner ? (-c->bw) : (c->h + c->bw - 1)); + horizcorner ? (-c->bw) : (c->w + c->bw - 1), + vertcorner ? (-c->bw) : (c->h + c->bw - 1)); + #endif // DRAGMFACT_PATCH + #elif DRAGMFACT_PATCH + 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->mw * selmon->mfact, selmon->mh / 2); + } #else XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); #endif // RESIZECORNERS_PATCH @@ -2360,6 +2376,7 @@ resizemouse(const Arg *arg) nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1); nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1); #endif // RESIZECORNERS_PATCH + #if !DRAGMFACT_PATCH 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) { @@ -2367,6 +2384,7 @@ resizemouse(const Arg *arg) && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) togglefloating(NULL); } + #endif // DRAGMFACT_PATCH if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) { #if RESIZECORNERS_PATCH resize(c, nx, ny, nw, nh, 1); @@ -2391,9 +2409,29 @@ resizemouse(const Arg *arg) } } while (ev.type != ButtonRelease); #if RESIZECORNERS_PATCH + #if DRAGMFACT_PATCH + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, + horizcorner ? (-c->bw) : (c->w + c->bw - 1), + vertcorner ? (-c->bw) : (c->h + c->bw - 1)); + } else { + selmon->mfact = (double) ev.xmotion.x / (double) selmon->mw; + arrange(selmon); + XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->mw * selmon->mfact, selmon->mh / 2); + } + #else XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, - horizcorner ? (-c->bw) : (c->w + c->bw - 1), - vertcorner ? (-c->bw) : (c->h + c->bw - 1)); + horizcorner ? (-c->bw) : (c->w + c->bw - 1), + vertcorner ? (-c->bw) : (c->h + c->bw - 1)); + #endif // DRAGMFACT_PATCH + #elif DRAGMFACT_PATCH + 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 / (double) selmon->mw; + arrange(selmon); + XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->mw * selmon->mfact, selmon->mh / 2); + } #else XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); #endif // RESIZECORNERS_PATCH diff --git a/patches.h b/patches.h index 8d43958..83c9208 100644 --- a/patches.h +++ b/patches.h @@ -115,6 +115,13 @@ */ #define CYCLELAYOUTS_PATCH 0 +/* This patch lets you resize the split in the tile layout (i.e. modify mfact) by holding + * the modkey and dragging the mouse. + * This patch can be a bit wonky with other layouts, but generally works. + * https://dwm.suckless.org/patches/dragmfact/ + */ +#define DRAGMFACT_PATCH 0 + /* Simple dwmc client using a fork of fsignal to communicate with dwm. * To use this either copy the patch/dwmc shell script to somewhere in your path or * uncomment the following line in Makefile: #cp -f patch/dwmc ${DESTDIR}${PREFIX}/bin