Adding moveresize patch as per #25

pull/32/head
bakkeby 4 years ago
parent df118dc046
commit 2cb3e697e4

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2020-05-21 - Added the moveresize patch
2020-05-03 - Added the shiftviewclients patch and the no transparent borders patch which removes opacity from window borders when the alpha patch is not used
2020-05-02 - Added dwmblocks patch
@ -271,6 +273,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- always display the the monocle-symbol as defined in config.h if the monocle-layout is activated
- do not display the number of open clients in the current tag
- [moveresize](https://dwm.suckless.org/patches/moveresize/)
- allows you to move and resize dwm's clients using keyboard bindings
- [movestack](https://dwm.suckless.org/patches/movestack/)
- allows you to move clients around in the stack and swap them with the master

@ -743,6 +743,16 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_l, setcfact, {.f = -0.25} },
{ MODKEY|ShiftMask, XK_o, setcfact, {0} },
#endif // CFACTS_PATCH
#if MOVERESIZE_PATCH
{ MODKEY|Mod4Mask, XK_Down, moveresize, {.v = "0x 25y 0w 0h" } },
{ MODKEY|Mod4Mask, XK_Up, moveresize, {.v = "0x -25y 0w 0h" } },
{ MODKEY|Mod4Mask, XK_Right, moveresize, {.v = "25x 0y 0w 0h" } },
{ MODKEY|Mod4Mask, XK_Left, moveresize, {.v = "-25x 0y 0w 0h" } },
{ MODKEY|Mod4Mask|ShiftMask, XK_Down, moveresize, {.v = "0x 0y 0w 25h" } },
{ MODKEY|Mod4Mask|ShiftMask, XK_Up, moveresize, {.v = "0x 0y 0w -25h" } },
{ MODKEY|Mod4Mask|ShiftMask, XK_Right, moveresize, {.v = "0x 0y 25w 0h" } },
{ MODKEY|Mod4Mask|ShiftMask, XK_Left, moveresize, {.v = "0x 0y -25w 0h" } },
#endif // MOVERESIZE_PATCH
#if MOVESTACK_PATCH
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },

@ -70,6 +70,9 @@
#if MDPCONTROL_PATCH
#include "mdpcontrol.c"
#endif
#if MOVERESIZE_PATCH
#include "moveresize.c"
#endif
#if MOVESTACK_PATCH
#include "movestack.c"
#endif

@ -73,6 +73,9 @@
#if MDPCONTROL_PATCH
#include "mdpcontrol.h"
#endif
#if MOVERESIZE_PATCH
#include "moveresize.h"
#endif
#if MOVESTACK_PATCH
#include "movestack.h"
#endif

@ -0,0 +1,64 @@
void
moveresize(const Arg *arg) {
/* only floating windows can be moved */
Client *c;
c = selmon->sel;
int x, y, w, h, nx, ny, nw, nh, ox, oy, ow, oh;
char xAbs, yAbs, wAbs, hAbs;
int msx, msy, dx, dy, nmx, nmy;
unsigned int dui;
Window dummy;
if (!c || !arg)
return;
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
return;
if (sscanf((char *)arg->v, "%d%c %d%c %d%c %d%c", &x, &xAbs, &y, &yAbs, &w, &wAbs, &h, &hAbs) != 8)
return;
/* compute new window position; prevent window from be positioned outside the current monitor */
nw = c->w + w;
if (wAbs == 'W')
nw = w < selmon->mw - 2 * c->bw ? w : selmon->mw - 2 * c->bw;
nh = c->h + h;
if (hAbs == 'H')
nh = h < selmon->mh - 2 * c->bw ? h : selmon->mh - 2 * c->bw;
nx = c->x + x;
if (xAbs == 'X') {
if (x < selmon->mx)
nx = selmon->mx;
else if (x > selmon->mx + selmon->mw)
nx = selmon->mx + selmon->mw - nw - 2 * c->bw;
else
nx = x;
}
ny = c->y + y;
if (yAbs == 'Y') {
if (y < selmon->my)
ny = selmon->my;
else if (y > selmon->my + selmon->mh)
ny = selmon->my + selmon->mh - nh - 2 * c->bw;
else
ny = y;
}
ox = c->x;
oy = c->y;
ow = c->w;
oh = c->h;
XRaiseWindow(dpy, c->win);
Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy, &dx, &dy, &dui);
resize(c, nx, ny, nw, nh, True);
/* move cursor along with the window to avoid problems caused by the sloppy focus */
if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + oh) >= msy)
{
nmx = c->x - ox + c->w - ow;
nmy = c->y - oy + c->h - oh;
XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy);
}
}

@ -0,0 +1 @@
static void moveresize(const Arg *arg);

@ -334,6 +334,11 @@
*/
#define MONOCLESYMBOL_PATCH 0
/* This patch allows you to move and resize dwm's clients using keyboard bindings.
* https://dwm.suckless.org/patches/moveresize/
*/
#define MOVERESIZE_PATCH 0
/* This patch allows you to move clients around in the stack and swap them with the master.
* https://dwm.suckless.org/patches/movestack/
*/

Loading…
Cancel
Save