diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 73 |
1 files changed, 67 insertions, 6 deletions
@@ -201,6 +201,7 @@ static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); static void monocle(Monitor *m); static void motionnotify(XEvent *e); +static void moveresize(const Arg *arg); static void movemouse(const Arg *arg); static unsigned int nexttag(void); static unsigned int prevtag(void); @@ -1324,8 +1325,6 @@ manage(Window w, XWindowAttributes *wa) if (term) { swallow(term, c); } - if (c && c->mon == selmon) - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); focus(NULL); } @@ -1439,6 +1438,71 @@ movemouse(const Arg *arg) } } +void +moveresize(const Arg *arg) { + 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; + + 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 */ + 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; + /* make sure the cursor stays inside the window */ + if ((msx + nmx) > c->x && (msy + nmy) > c->y) + XWarpPointer(dpy, None, None, 0, 0, 0, 0, nmx, nmy); + } +} + unsigned int nexttag(void) { @@ -2079,7 +2143,7 @@ tile(Monitor *m) Client *c; for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 1) + if (n <= gaplesscount) m->gappx = 0; else m->gappx = gappx; @@ -2215,9 +2279,6 @@ unmanage(Client *c, int destroyed) focus(NULL); updateclientlist(); } - if (m == selmon && m->sel) - XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0, - m->sel->w/2, m->sel->h/2); } void |
