summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-10-06 08:45:17 +0200
committerbakkeby <[email protected]>2020-10-06 08:45:17 +0200
commit56c81ddbfa8f133d6690977f6ea01d16185538a2 (patch)
treeac1b2fe3f52b7f1b5bd12eab94a699f325fec837 /patch
parentc47f61387da7c85aff9d3db00081053965e2e0dc (diff)
downloaddwm-flexipatch-56c81ddbfa8f133d6690977f6ea01d16185538a2.tar.gz
dwm-flexipatch-56c81ddbfa8f133d6690977f6ea01d16185538a2.zip
warp: dragmfact + dragcfact compatibility
These set of changes introduce: a) a flag to ignore warp from happening while dragmfact or dragcfact is being used and b) a flag to force warp when killclient or showhideclient is used, to make for a more intuitive experience ref. https://github.com/bakkeby/patches/issues/11
Diffstat (limited to 'patch')
-rw-r--r--patch/bar_wintitleactions.c3
-rw-r--r--patch/dragcfact.c8
-rw-r--r--patch/dragmfact.c9
-rw-r--r--patch/warp.c34
4 files changed, 40 insertions, 14 deletions
diff --git a/patch/bar_wintitleactions.c b/patch/bar_wintitleactions.c
index a9ae3e1..e94fe06 100644
--- a/patch/bar_wintitleactions.c
+++ b/patch/bar_wintitleactions.c
@@ -80,6 +80,9 @@ showhideclient(const Arg *arg)
if (!c)
return;
+ #if WARP_PATCH
+ force_warp = 1;
+ #endif // WARP_PATCH
if (HIDDEN(c)) {
show(c);
focus(c);
diff --git a/patch/dragcfact.c b/patch/dragcfact.c
index a99f046..fce5c92 100644
--- a/patch/dragcfact.c
+++ b/patch/dragcfact.c
@@ -27,6 +27,11 @@ dragcfact(const Arg *arg)
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurIronCross]->cursor, CurrentTime) != GrabSuccess)
return;
+
+ #if WARP_PATCH
+ ignore_warp = 1;
+ #endif // WARP_PATCH
+
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
prev_x = prev_y = -999999;
@@ -66,6 +71,9 @@ dragcfact(const Arg *arg)
}
} while (ev.type != ButtonRelease);
+ #if WARP_PATCH
+ ignore_warp = 0;
+ #endif // WARP_PATCH
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
diff --git a/patch/dragmfact.c b/patch/dragmfact.c
index 1bcf38c..257b5c1 100644
--- a/patch/dragmfact.c
+++ b/patch/dragmfact.c
@@ -152,6 +152,11 @@ dragmfact(const Arg *arg)
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[horizontal ? CurResizeVertArrow : CurResizeHorzArrow]->cursor, CurrentTime) != GrabSuccess)
return;
+
+ #if WARP_PATCH
+ ignore_warp = 1;
+ #endif // WARP_PATCH
+
XWarpPointer(dpy, None, root, 0, 0, 0, 0, px, py);
do {
@@ -217,6 +222,10 @@ dragmfact(const Arg *arg)
}
} while (ev.type != ButtonRelease);
+ #if WARP_PATCH
+ ignore_warp = 0;
+ #endif // WARP_PATCH
+
XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
} \ No newline at end of file
diff --git a/patch/warp.c b/patch/warp.c
index 45048e2..e266656 100644
--- a/patch/warp.c
+++ b/patch/warp.c
@@ -5,26 +5,32 @@ warp(const Client *c)
Bar *bar;
int x, y;
+ if (ignore_warp)
+ return;
+
if (!c) {
XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2);
return;
}
- if (!getrootptr(&x, &y) ||
- (x > c->x - c->bw &&
- y > c->y - c->bw &&
- x < c->x + c->w + c->bw*2 &&
- y < c->y + c->h + c->bw*2)
- )
- return;
+ if (!force_warp) {
+ if (!getrootptr(&x, &y) ||
+ (x > c->x - c->bw &&
+ y > c->y - c->bw &&
+ x < c->x + c->w + c->bw*2 &&
+ y < c->y + c->h + c->bw*2)
+ )
+ return;
- for (m = mons; m; m = m->next)
- for (bar = m->bar; bar; bar = bar->next)
- if (x > bar->bx &&
- x < bar->bx + bar->bw &&
- y > bar->by &&
- y < bar->by + bar->bh)
- return;
+ for (m = mons; m; m = m->next)
+ for (bar = m->bar; bar; bar = bar->next)
+ if (x > bar->bx &&
+ x < bar->bx + bar->bw &&
+ y > bar->by &&
+ y < bar->by + bar->bh)
+ return;
+ } else
+ force_warp = 0;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
}