[wiki] [sites] [dwm][patch][resizecorners] Update to 6.5 and add anchor points || Chris Noxz
commit ad49298b7f643743dd314f844e28769936d953cd
Author: Chris Noxz <chris_AT_noxz.tech>
Date: Fri Jun 21 14:14:51 2024 +0200
[dwm][patch][resizecorners] Update to 6.5 and add anchor points
diff --git a/dwm.suckless.org/patches/resizecorners/dwm-resizecorners-6.5.diff b/dwm.suckless.org/patches/resizecorners/dwm-resizecorners-6.5.diff
new file mode 100644
index 00000000..17e32d68
--- /dev/null
+++ b/dwm.suckless.org/patches/resizecorners/dwm-resizecorners-6.5.diff
_AT_@ -0,0 +1,75 @@
+Author: Chris Noxz <chris_AT_noxz.tech>
+
+diff -up ../dwm-6.5/dwm.c ./dwm.c
+--- ../dwm-6.5/dwm.c 2024-03-19 12:24:52.000000000 +0100
++++ ./dwm.c 2024-06-21 14:06:47.127064311 +0200
+_AT_@ -1301,9 +1301,14 @@ void
+ resizemouse(const Arg *arg)
+ {
+ int ocx, ocy, nw, nh;
++ int ocx2, ocy2, nx, ny;
+ Client *c;
+ Monitor *m;
+ XEvent ev;
++ int horizcorner, vertcorner;
++ int di;
++ unsigned int dui;
++ Window dummy;
+ Time lasttime = 0;
+
+ if (!(c = selmon->sel))
+_AT_@ -1313,10 +1318,18 @@ resizemouse(const Arg *arg)
+ restack(selmon);
+ ocx = c->x;
+ ocy = c->y;
++ ocx2 = c->x + c->w;
++ ocy2 = c->y + c->h;
+ 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 (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
++ return;
++ horizcorner = nx < c->w / 2;
++ vertcorner = ny < c->h / 2;
++ 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));
+ do {
+ XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
+ switch(ev.type) {
+_AT_@ -1330,8 +1343,16 @@ resizemouse(const Arg *arg)
+ continue;
+ lasttime = ev.xmotion.time;
+
+- nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
+- nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
++ nx = horizcorner && ocx2 - ev.xmotion.x >= c->minw ? ev.xmotion.x : c->x;
++ ny = vertcorner && ocy2 - ev.xmotion.y >= c->minh ? ev.xmotion.y : c->y;
++ 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);
++
++ if (horizcorner && ev.xmotion.x > ocx2)
++ nx = ocx2 - (nw = c->minw);
++ if (vertcorner && ev.xmotion.y > ocy2)
++ ny = ocy2 - (nh = c->minh);
++
+ 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)
+ {
+_AT_@ -1340,11 +1361,13 @@ resizemouse(const Arg *arg)
+ togglefloating(NULL);
+ }
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+- resize(c, c->x, c->y, nw, nh, 1);
++ resize(c, nx, ny, 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);
++ 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));
+ XUngrabPointer(dpy, CurrentTime);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
diff --git a/dwm.suckless.org/patches/resizecorners/index.md b/dwm.suckless.org/patches/resizecorners/index.md
index 84ca822a..e4bbcbd6 100644
--- a/dwm.suckless.org/patches/resizecorners/index.md
+++ b/dwm.suckless.org/patches/resizecorners/index.md
_AT_@ -6,8 +6,12 @@ Description
By default, windows can only be resized from the bottom right corner. With this Patch, the
mouse is warped to the nearest corner and you resize it from there.
+Version 6.5 includes anchoring of opposite corners to the corner you resize
+from.
+
Download
--------
+* [dwm-resizecorners-6.5.diff](dwm-resizecorners-6.5.diff) (2024-06-21)
* [dwm-resizecorners-6.2.diff](dwm-resizecorners-6.2.diff) (2019-02-03)
* [dwm-resizecorners-6.1.diff](dwm-resizecorners-6.1.diff) (2016-02-17)
* [dwm-resizecorners-6.0.diff](dwm-resizecorners-6.0.diff) (2015-05-12)
_AT_@ -17,3 +21,4 @@ Author
* dusty - <dusty_AT_teknik.io>
* Klemens Nanni <kl3_AT_posteo.org> (6.1 version)
* doodoo <doodoo_AT_cock.li> (6.2 version)
+* Chris Noxz <chris_AT_noxz.tech> (6.5 version)
Received on Fri Jun 21 2024 - 14:16:13 CEST
This archive was generated by hypermail 2.3.0
: Fri Jun 21 2024 - 14:24:52 CEST