dwm-warp-6.1.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.1.diff (1328B)
---
1 diff -ruN dwm-6.1-orig/dwm.c dwm-6.1/dwm.c
2 --- dwm-6.1-orig/dwm.c 2015-11-08 16:39:37.000000000 -0600
3 +++ dwm-6.1/dwm.c 2015-12-14 19:17:19.656091228 -0600
4 @@ -227,6 +227,7 @@
5 static void updatetitle(Client *c);
6 static void updatewmhints(Client *c);
7 static void view(const Arg *arg);
8 +static void warp(const Client *c);
9 static Client *wintoclient(Window w);
10 static Monitor *wintomon(Window w);
11 static int xerror(Display *dpy, XErrorEvent *ee);
12 @@ -840,6 +841,7 @@
13 in gedit and anjuta */
14 selmon = m;
15 focus(NULL);
16 + warp(selmon->sel);
17 }
18
19 void
20 @@ -1384,6 +1386,8 @@
21 }
22 XSync(dpy, False);
23 while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
24 + if (m == selmon && (m->tagset[m->seltags] & m->sel->tags))
25 + warp(m->sel);
26 }
27
28 void
29 @@ -2040,6 +2044,28 @@
30 arrange(selmon);
31 }
32
33 +void
34 +warp(const Client *c)
35 +{
36 + int x, y;
37 +
38 + if (!c) {
39 + XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww/2, selmon->wy + selmon->wh/2);
40 + return;
41 + }
42 +
43 + if (!getrootptr(&x, &y) ||
44 + (x > c->x - c->bw &&
45 + y > c->y - c->bw &&
46 + x < c->x + c->w + c->bw*2 &&
47 + y < c->y + c->h + c->bw*2) ||
48 + (y > c->mon->by && y < c->mon->by + bh) ||
49 + (c->mon->topbar && !y))
50 + return;
51 +
52 + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
53 +}
54 +
55 Client *
56 wintoclient(Window w)
57 {