dwm-dragmfact-6.2.diff (2421B)
1 From 17df87822b379ce47d0aba3c36c5ef0adf4a7c3e Mon Sep 17 00:00:00 2001 2 From: Miles Alan <m@milesalan.com> 3 Date: Sun, 8 Dec 2019 18:15:13 -0600 4 Subject: [PATCH] Mod + Right click / drag in tiling mode to resize mfact. 5 Works with multiple monitors. 6 7 --- 8 dwm.c | 32 +++++++++++++++++++++++--------- 9 1 file changed, 23 insertions(+), 9 deletions(-) 10 11 diff --git a/dwm.c b/dwm.c 12 index c15f679..e273803 100644 13 --- a/dwm.c 14 +++ b/dwm.c 15 @@ -1911,7 +1911,16 @@ resizemouse(const Arg *arg) 16 if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, 17 None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) 18 return; 19 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); 20 + 21 + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { 22 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); 23 + } else { 24 + XWarpPointer(dpy, None, root, 0, 0, 0, 0, 25 + selmon->mx + (selmon->ww * selmon->mfact), 26 + selmon->my + (selmon->wh / 2) 27 + ); 28 + } 29 + 30 do { 31 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); 32 switch(ev.type) { 33 @@ -1927,19 +1936,24 @@ resizemouse(const Arg *arg) 34 35 nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); 36 nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); 37 - if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww 38 - && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) 39 - { 40 - if (!c->isfloating && selmon->lt[selmon->sellt]->arrange 41 - && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) 42 - togglefloating(NULL); 43 - } 44 + 45 if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) 46 resize(c, c->x, c->y, nw, nh, 1); 47 break; 48 } 49 } while (ev.type != ButtonRelease); 50 - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); 51 + 52 + if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) { 53 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); 54 + } else { 55 + selmon->mfact = (double) (ev.xmotion.x_root - selmon->mx) / (double) selmon->ww; 56 + arrange(selmon); 57 + XWarpPointer(dpy, None, root, 0, 0, 0, 0, 58 + selmon->mx + (selmon->ww * selmon->mfact), 59 + selmon->my + (selmon->wh / 2) 60 + ); 61 + } 62 + 63 XUngrabPointer(dpy, CurrentTime); 64 while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 65 if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { 66 -- 67 2.23.0 68