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
This commit is contained in:
bakkeby
2020-10-06 08:45:17 +02:00
parent c47f61387d
commit 56c81ddbfa
5 changed files with 50 additions and 16 deletions

View File

@@ -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);
}