summaryrefslogtreecommitdiff
path: root/dwm
diff options
context:
space:
mode:
Diffstat (limited to 'dwm')
-rw-r--r--dwm/dwm.c70
1 files changed, 58 insertions, 12 deletions
diff --git a/dwm/dwm.c b/dwm/dwm.c
index dc06c07..c22e808 100644
--- a/dwm/dwm.c
+++ b/dwm/dwm.c
@@ -1875,11 +1875,59 @@ movemouse(const Arg *arg)
ny = selmon->wy;
else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
ny = selmon->wy + selmon->wh - HEIGHT(c);
- if (!c->isfloating && selmon->lt[selmon->sellt]->arrange &&
- (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
- togglefloating(NULL);
if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
resize(c, nx, ny, c->w, c->h, 1);
+ else if (selmon->lt[selmon->sellt]->arrange || !c->isfloating) {
+ if ((m = recttomon(ev.xmotion.x_root, ev.xmotion.y_root, 1, 1)) != selmon) {
+ sendmon(c, m);
+ selmon = m;
+ focus(NULL);
+ }
+
+ Client *cc = c->mon->clients;
+ while (1) {
+ if (cc == 0) break;
+ if(
+ cc != c && !cc->isfloating && ISVISIBLE(cc) &&
+ ev.xmotion.x_root > cc->x &&
+ ev.xmotion.x_root < cc->x + cc->w &&
+ ev.xmotion.y_root > cc->y &&
+ ev.xmotion.y_root < cc->y + cc->h ) {
+ break;
+ }
+ cc = cc->next;
+ }
+
+ if (cc) {
+ Client *cl1, *cl2, ocl1;
+
+ if (!selmon->lt[selmon->sellt]->arrange) return;
+
+ cl1 = c;
+ cl2 = cc;
+ ocl1 = *cl1;
+ strcpy(cl1->name, cl2->name);
+ cl1->win = cl2->win;
+ cl1->x = cl2->x;
+ cl1->y = cl2->y;
+ cl1->w = cl2->w;
+ cl1->h = cl2->h;
+
+ cl2->win = ocl1.win;
+ strcpy(cl2->name, ocl1.name);
+ cl2->x = ocl1.x;
+ cl2->y = ocl1.y;
+ cl2->w = ocl1.w;
+ cl2->h = ocl1.h;
+
+ selmon->sel = cl2;
+
+ c = cc;
+ focus(c);
+
+ arrange(cl1->mon);
+ }
+ }
}
break;
}
@@ -2034,7 +2082,7 @@ resizeclient(Client *c, int x, int y, int w, int h)
void
resizemouse(const Arg *arg)
{
- int ocx, ocy, nw, nh;
+ int x, y, ocw, och, nw, nh;
Client *c;
Monitor *m;
XEvent ev;
@@ -2044,13 +2092,13 @@ resizemouse(const Arg *arg)
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
return;
restack(selmon);
- ocx = c->x;
- ocy = c->y;
+ ocw = c->w;
+ och = c->h;
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
return;
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1,
- c->h + c->bw - 1);
+ if(!getrootptr(&x, &y))
+ return;
do
{
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
@@ -2062,8 +2110,8 @@ resizemouse(const Arg *arg)
handler[ev.type](&ev);
break;
case MotionNotify:
- nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
- nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
+ nw = MAX(ocw + (ev.xmotion.x - x), 1);
+ nh = MAX(och + (ev.xmotion.y - y), 1);
if ((m = recttomon(c->x, c->y, nw, nh)))
{
if (m != selmon)
@@ -2076,8 +2124,6 @@ resizemouse(const Arg *arg)
break;
}
} while (ev.type != ButtonRelease);
- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1,
- c->h + c->bw - 1);
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev))
;