dwm-warp-6.2.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-warp-6.2.diff (1402B)
---
1 diff --git a/dwm.c b/dwm.c
2 index 4465af1..bf74f60 100644
3 --- a/dwm.c
4 +++ b/dwm.c
5 @@ -227,6 +227,7 @@ static void updatetitle(Client *c);
6 static void updatewindowtype(Client *c);
7 static void updatewmhints(Client *c);
8 static void view(const Arg *arg);
9 +static void warp(const Client *c);
10 static Client *wintoclient(Window w);
11 static Monitor *wintomon(Window w);
12 static int xerror(Display *dpy, XErrorEvent *ee);
13 @@ -827,6 +828,7 @@ focusmon(const Arg *arg)
14 unfocus(selmon->sel, 0);
15 selmon = m;
16 focus(NULL);
17 + warp(selmon->sel);
18 }
19
20 void
21 @@ -1367,6 +1369,8 @@ restack(Monitor *m)
22 }
23 XSync(dpy, False);
24 while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
25 + if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2])
26 + warp(m->sel);
27 }
28
29 void
30 @@ -2044,6 +2048,28 @@ view(const Arg *arg)
31 arrange(selmon);
32 }
33
34 +void
35 +warp(const Client *c)
36 +{
37 + int x, y;
38 +
39 + if (!c) {
40 + XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww/2, selmon->wy + selmon->wh/2);
41 + return;
42 + }
43 +
44 + if (!getrootptr(&x, &y) ||
45 + (x > c->x - c->bw &&
46 + y > c->y - c->bw &&
47 + x < c->x + c->w + c->bw*2 &&
48 + y < c->y + c->h + c->bw*2) ||
49 + (y > c->mon->by && y < c->mon->by + bh) ||
50 + (c->mon->topbar && !y))
51 + return;
52 +
53 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
54 +}
55 +
56 Client *
57 wintoclient(Window w)
58 {