summaryrefslogtreecommitdiffhomepage
path: root/patch/warp.c
blob: 1cbf4b9cfa14ff46c3687c2c1157d16458ee5889 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void
warp(const Client *c)
{
	int x, y;

	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) ||
	    x < c->mon->wx ||
	    x > c->mon->wx + c->mon->ww ||
	    y < c->mon->wy ||
	    y > c->mon->wy + c->mon->wh
	)
		return;

	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
}