dwm-moveresize-20160731-56a31dc.diff - sites - public wiki contents of suckless… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-moveresize-20160731-56a31dc.diff (2012B) | |
--- | |
1 Author: Jan Christoph Ebersbach <[email protected]> | |
2 URL: http://dwm.suckless.org/patches/moveresize | |
3 These patches provide helper functions for moving and resizing floating … | |
4 using keybindings. | |
5 | |
6 Index: dwm/moveresize.c | |
7 =================================================================== | |
8 --- /dev/null | |
9 +++ dwm/moveresize.c | |
10 @@ -0,0 +1,64 @@ | |
11 +void | |
12 +moveresize(const Arg *arg) { | |
13 + /* only floating windows can be moved */ | |
14 + Client *c; | |
15 + c = selmon->sel; | |
16 + int x, y, w, h, nx, ny, nw, nh, ox, oy, ow, oh; | |
17 + char xAbs, yAbs, wAbs, hAbs; | |
18 + int msx, msy, dx, dy, nmx, nmy; | |
19 + unsigned int dui; | |
20 + Window dummy; | |
21 + | |
22 + if (!c || !arg) | |
23 + return; | |
24 + if (selmon->lt[selmon->sellt]->arrange && !c->isfloating) | |
25 + return; | |
26 + if(sscanf((char *)arg->v, "%d%c %d%c %d%c %d%c", &x, &xAbs, &y,… | |
27 + return; | |
28 + /* compute new window position; prevent window from be position… | |
29 + nw = c->w + w; | |
30 + if(wAbs == 'W') | |
31 + nw = w < selmon->mw - 2 * c->bw ? w : selmon->mw - 2 * … | |
32 + | |
33 + nh = c->h + h; | |
34 + if(hAbs == 'H') | |
35 + nh = h < selmon->mh - 2 * c->bw ? h : selmon->mh - 2 * … | |
36 + | |
37 + nx = c->x + x; | |
38 + if(xAbs == 'X') { | |
39 + if(x < selmon->mx) | |
40 + nx = selmon->mx; | |
41 + else if(x > selmon->mx + selmon->mw) | |
42 + nx = selmon->mx + selmon->mw - nw - 2 * c->bw; | |
43 + else | |
44 + nx = x; | |
45 + } | |
46 + | |
47 + ny = c->y + y; | |
48 + if(yAbs == 'Y') { | |
49 + if(y < selmon->my) | |
50 + ny = selmon->my; | |
51 + else if(y > selmon->my + selmon->mh) | |
52 + ny = selmon->my + selmon->mh - nh - 2 * c->bw; | |
53 + else | |
54 + ny = y; | |
55 + } | |
56 + | |
57 + ox = c->x; | |
58 + oy = c->y; | |
59 + ow = c->w; | |
60 + oh = c->h; | |
61 + | |
62 + XRaiseWindow(dpy, c->win); | |
63 + Bool xqp = XQueryPointer(dpy, root, &dummy, &dummy, &msx, &msy,… | |
64 + resize(c, nx, ny, nw, nh, True); | |
65 + | |
66 + /* move cursor along with the window to avoid problems caused b… | |
67 + if (xqp && ox <= msx && (ox + ow) >= msx && oy <= msy && (oy + … | |
68 + { | |
69 + nmx = c->x - ox + c->w - ow; | |
70 + nmy = c->y - oy + c->h - oh; | |
71 + XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy); | |
72 + } | |
73 +} | |
74 + |