diff options
| author | Octavian Cerna <octavian.cerna@gmail.com> | 2013-01-16 01:03:22 +0200 |
|---|---|---|
| committer | Octavian Cerna <octavian.cerna@gmail.com> | 2013-01-16 01:03:22 +0200 |
| commit | 18bf01c9b269ae81849a4189327b4b63aaf35893 (patch) | |
| tree | 9449c77b8bb2100d39416e46d5560abd65d42027 | |
| parent | 957861648346d885e403753fcd970635d7a5bfc9 (diff) | |
Add dwm-5.9-warp.diff
| -rw-r--r-- | dwm.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -285,6 +285,7 @@ static void updatewindowtype(Client *c); static void updatetitle(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); +static void warp(const Client *c); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static Client *wintosystrayicon(Window w); @@ -1142,6 +1143,7 @@ focusmon(const Arg *arg) { unfocus(selmon->sel, True); selmon = m; focus(NULL); + warp(selmon->sel); } void @@ -1768,6 +1770,8 @@ restack(Monitor *m) { } XSync(dpy, False); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); + if (m == selmon && (m->tagset[m->seltags] & m->sel->tags)) + warp(m->sel); } void @@ -2555,6 +2559,26 @@ view(const Arg *arg) { arrange(selmon); } +void +warp(const Client *c) { + Window dummy; + int x, y, di; + unsigned int dui; + + if (!c) { + XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh/2); + return; + } + + XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); + + if((x > c->x && y > c->y && x < c->x + c->w && y < c->y + c->h) || + (y > c->mon->by && y < c->mon->by + bh)) + return; + + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); +} + Client * wintoclient(Window w) { Client *c; |
