mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding resizecorners patch
This commit is contained in:
parent
9ccc131284
commit
2f4916a64e
@ -55,6 +55,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
- [pertag](https://dwm.suckless.org/patches/pertag/)
|
||||
- adds nmaster, mfact, layouts and more per tag rather than per monitor
|
||||
|
||||
- [resizecorners](https://dwm.suckless.org/patches/resizecorners/)
|
||||
- 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
|
||||
|
||||
- [systray](https://dwm.suckless.org/patches/systray/)
|
||||
- adds system tray in the status bar
|
||||
|
||||
|
40
dwm.c
40
dwm.c
@ -1573,6 +1573,13 @@ void
|
||||
resizemouse(const Arg *arg)
|
||||
{
|
||||
int ocx, ocy, nw, nh;
|
||||
#if RESIZECORNERS_PATCH
|
||||
int ocx2, ocy2, nx, ny;
|
||||
int horizcorner, vertcorner;
|
||||
int di;
|
||||
unsigned int dui;
|
||||
Window dummy;
|
||||
#endif // RESIZECORNERS_PATCH
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
XEvent ev;
|
||||
@ -1585,10 +1592,24 @@ resizemouse(const Arg *arg)
|
||||
restack(selmon);
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
#if RESIZECORNERS_PATCH
|
||||
ocx2 = c->x + c->w;
|
||||
ocy2 = c->y + c->h;
|
||||
#endif // RESIZECORNERS_PATCH
|
||||
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
#if RESIZECORNERS_PATCH
|
||||
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));
|
||||
#else
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
|
||||
#endif // RESIZECORNERS_PATCH
|
||||
do {
|
||||
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
|
||||
switch(ev.type) {
|
||||
@ -1604,6 +1625,12 @@ 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 RESIZECORNERS_PATCH
|
||||
nx = horizcorner ? ev.xmotion.x : c->x;
|
||||
ny = vertcorner ? 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);
|
||||
#endif // RESIZECORNERS_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)
|
||||
{
|
||||
@ -1611,12 +1638,23 @@ resizemouse(const Arg *arg)
|
||||
&& (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
|
||||
togglefloating(NULL);
|
||||
}
|
||||
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
|
||||
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) {
|
||||
#if RESIZECORNERS_PATCH
|
||||
resize(c, nx, ny, nw, nh, 1);
|
||||
#else
|
||||
resize(c, c->x, c->y, nw, nh, 1);
|
||||
#endif // RESIZECORNERS_PATCH
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (ev.type != ButtonRelease);
|
||||
#if RESIZECORNERS_PATCH
|
||||
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, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
|
||||
#endif // RESIZECORNERS_PATCH
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
||||
|
@ -81,6 +81,12 @@
|
||||
*/
|
||||
#define PERTAGBAR_PATCH 0
|
||||
|
||||
/* 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.
|
||||
* https://dwm.suckless.org/patches/resizecorners/
|
||||
*/
|
||||
#define RESIZECORNERS_PATCH 0
|
||||
|
||||
/* The systray patch adds systray for the status bar.
|
||||
* https://dwm.suckless.org/patches/systray/
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user