Adding resizepoint patch

This commit is contained in:
bakkeby 2020-06-24 14:49:30 +02:00
parent af30c7a735
commit 04906b4ddf
3 changed files with 44 additions and 12 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### Changelog:
2020-06-24 - Added resizepoint patch
2020-06-21 - Added floatpos and bar_height patches 2020-06-21 - Added floatpos and bar_height patches
2020-06-19 - Added tagothermonitor patch 2020-06-19 - Added tagothermonitor patch
@ -341,6 +343,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- by default, windows only resize from the bottom right corner - by default, windows only resize from the bottom right corner
- with this patch the mouse is warped to the nearest corner and you resize from there - with this patch the mouse is warped to the nearest corner and you resize from there
- [resizepoint](https://github.com/bakkeby/patches/blob/master/dwm/dwm-resizepoint-6.2.diff)
- practically the same as resizecorners, but the cursor does not warp to any of the window corners
- [restartsig](https://dwm.suckless.org/patches/restartsig/) - [restartsig](https://dwm.suckless.org/patches/restartsig/)
- adds a keyboard shortcut to restart dwm or alternatively by using kill -HUP dwmpid - adds a keyboard shortcut to restart dwm or alternatively by using kill -HUP dwmpid
- additionally dwm can quit cleanly by using kill -TERM dwmpid - additionally dwm can quit cleanly by using kill -TERM dwmpid

45
dwm.c
View File

@ -2647,13 +2647,18 @@ void
resizemouse(const Arg *arg) resizemouse(const Arg *arg)
{ {
int ocx, ocy, nw, nh; int ocx, ocy, nw, nh;
#if RESIZECORNERS_PATCH #if RESIZEPOINT_PATCH
int opx, opy, och, ocw, nx, ny;
int horizcorner, vertcorner;
unsigned int dui;
Window dummy;
#elif RESIZECORNERS_PATCH
int ocx2, ocy2, nx, ny; int ocx2, ocy2, nx, ny;
int horizcorner, vertcorner; int horizcorner, vertcorner;
int di; int di;
unsigned int dui; unsigned int dui;
Window dummy; Window dummy;
#endif // RESIZECORNERS_PATCH #endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
Client *c; Client *c;
Monitor *m; Monitor *m;
XEvent ev; XEvent ev;
@ -2673,14 +2678,22 @@ resizemouse(const Arg *arg)
restack(selmon); restack(selmon);
ocx = c->x; ocx = c->x;
ocy = c->y; ocy = c->y;
#if RESIZECORNERS_PATCH #if RESIZEPOINT_PATCH
och = c->h;
ocw = c->w;
#elif RESIZECORNERS_PATCH
ocx2 = c->x + c->w; ocx2 = c->x + c->w;
ocy2 = c->y + c->h; ocy2 = c->y + c->h;
#endif // RESIZECORNERS_PATCH #endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
return; return;
#if RESIZECORNERS_PATCH #if RESIZEPOINT_PATCH
if (!XQueryPointer(dpy, c->win, &dummy, &dummy, &opx, &opy, &nx, &ny, &dui))
return;
horizcorner = nx < c->w / 2;
vertcorner = ny < c->h / 2;
#elif RESIZECORNERS_PATCH
if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui)) if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
return; return;
horizcorner = nx < c->w / 2; horizcorner = nx < c->w / 2;
@ -2690,7 +2703,7 @@ resizemouse(const Arg *arg)
vertcorner ? (-c->bw) : (c->h + c->bw - 1)); vertcorner ? (-c->bw) : (c->h + c->bw - 1));
#else #else
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, c->w + c->bw - 1, c->h + c->bw - 1);
#endif // RESIZECORNERS_PATCH #endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
do { do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) { switch(ev.type) {
@ -2704,14 +2717,20 @@ resizemouse(const Arg *arg)
continue; continue;
lasttime = ev.xmotion.time; lasttime = ev.xmotion.time;
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); #if RESIZEPOINT_PATCH
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); nx = horizcorner ? (ocx + ev.xmotion.x - opx) : c->x;
#if RESIZECORNERS_PATCH ny = vertcorner ? (ocy + ev.xmotion.y - opy) : c->y;
nw = MAX(horizcorner ? (ocx + ocw - nx) : (ocw + (ev.xmotion.x - opx)), 1);
nh = MAX(vertcorner ? (ocy + och - ny) : (och + (ev.xmotion.y - opy)), 1);
#elif RESIZECORNERS_PATCH
nx = horizcorner ? ev.xmotion.x : c->x; nx = horizcorner ? ev.xmotion.x : c->x;
ny = vertcorner ? ev.xmotion.y : c->y; ny = vertcorner ? ev.xmotion.y : c->y;
nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1); 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); nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
#endif // RESIZECORNERS_PATCH #else
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
#endif // RESIZEPOINT_PATCH | RESIZECORNERS_PATCH
if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww 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) && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
{ {
@ -2720,8 +2739,8 @@ resizemouse(const Arg *arg)
togglefloating(NULL); togglefloating(NULL);
} }
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) { if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) {
#if RESIZECORNERS_PATCH #if RESIZECORNERS_PATCH || RESIZEPOINT_PATCH
resize(c, nx, ny, nw, nh, 1); resizeclient(c, nx, ny, nw, nh);
#if SAVEFLOATS_PATCH || EXRESIZE_PATCH #if SAVEFLOATS_PATCH || EXRESIZE_PATCH
/* save last known float dimensions */ /* save last known float dimensions */
c->sfx = nx; c->sfx = nx;
@ -2745,6 +2764,7 @@ resizemouse(const Arg *arg)
break; break;
} }
} while (ev.type != ButtonRelease); } while (ev.type != ButtonRelease);
#if !RESIZEPOINT_PATCH
#if RESIZECORNERS_PATCH #if RESIZECORNERS_PATCH
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
horizcorner ? (-c->bw) : (c->w + c->bw - 1), horizcorner ? (-c->bw) : (c->w + c->bw - 1),
@ -2752,6 +2772,7 @@ resizemouse(const Arg *arg)
#else #else
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, c->w + c->bw - 1, c->h + c->bw - 1);
#endif // RESIZECORNERS_PATCH #endif // RESIZECORNERS_PATCH
#endif // RESIZEPOINT_PATCH
XUngrabPointer(dpy, CurrentTime); XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {

View File

@ -450,6 +450,12 @@
*/ */
#define RESIZECORNERS_PATCH 0 #define RESIZECORNERS_PATCH 0
/* Practically the same as resizecorners, but the cursor does not warp to corners.
* This takes precedence over the resizecorners patch.
* https://github.com/bakkeby/patches/blob/master/dwm/dwm-resizepoint-6.2.diff
*/
#define RESIZEPOINT_PATCH 0
/* Adds a keyboard shortcut to restart dwm or alternatively by using kill -HUP dwmpid. /* Adds a keyboard shortcut to restart dwm or alternatively by using kill -HUP dwmpid.
* Additionally dwm can quit cleanly by using kill -TERM dwmpid. * Additionally dwm can quit cleanly by using kill -TERM dwmpid.
* https://dwm.suckless.org/patches/restartsig/ * https://dwm.suckless.org/patches/restartsig/