add back warp cursor

This commit is contained in:
speedie 2022-12-04 21:43:15 +01:00
parent 01dcf72c10
commit a4a71d8189

View file

@ -702,9 +702,13 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
/* tag functions */
static void toggleview(const Arg *arg);
static void tag(const Arg *arg);
/* warp functions */
static void warp(const Client *c);
/* view functions */
static void view(const Arg *arg);
static void viewtoleft(const Arg *arg);
@ -1273,6 +1277,29 @@ attachtop(Client *c)
c->mon->clients = c;
}
void
warp(const Client *c)
{
int x, y;
if (!warpcursor)
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;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
}
void
attachstack(Client *c)
{
@ -2441,6 +2468,7 @@ focusmon(const Arg *arg)
unfocus(selmon->sel, 0);
selmon = m;
focus(NULL);
warp(selmon->sel);
}
void
@ -4630,7 +4658,7 @@ restack(Monitor *m)
}
}
XSync(dpy, False);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
warp(m->sel);
}
void