diff options
| author | bakkeby <[email protected]> | 2020-05-21 18:55:47 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2020-05-21 18:55:47 +0200 |
| commit | 2cb3e697e41c09059dbff9ec903875a95d019a7f (patch) | |
| tree | 410d14a5da59f613a7c0515f6f8fa3e0ed370ae0 /patch | |
| parent | df118dc04668793b974def1f607d41f72d0e0d03 (diff) | |
| download | dwm-flexipatch-2cb3e697e41c09059dbff9ec903875a95d019a7f.tar.gz dwm-flexipatch-2cb3e697e41c09059dbff9ec903875a95d019a7f.zip | |
Adding moveresize patch as per #25
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/include.c | 3 | ||||
| -rw-r--r-- | patch/include.h | 3 | ||||
| -rw-r--r-- | patch/moveresize.c | 64 | ||||
| -rw-r--r-- | patch/moveresize.h | 1 |
4 files changed, 71 insertions, 0 deletions
diff --git a/patch/include.c b/patch/include.c index 098d3eb..0b696cf 100644 --- a/patch/include.c +++ b/patch/include.c @@ -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 diff --git a/patch/include.h b/patch/include.h index aa40071..38821fa 100644 --- a/patch/include.h +++ b/patch/include.h @@ -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 diff --git a/patch/moveresize.c b/patch/moveresize.c new file mode 100644 index 0000000..35f0a2f --- /dev/null +++ b/patch/moveresize.c @@ -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); + } +}
\ No newline at end of file diff --git a/patch/moveresize.h b/patch/moveresize.h new file mode 100644 index 0000000..5d963ff --- /dev/null +++ b/patch/moveresize.h @@ -0,0 +1 @@ +static void moveresize(const Arg *arg);
\ No newline at end of file |
