aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2020-08-09 10:05:44 +0200
committerOmar Polo <op@omarpolo.com>2020-08-09 10:05:44 +0200
commit4e5ae52ad3165380108ea2985456804baf73125a (patch)
tree199b18c369f1aa41b5f236a741a2c8d6d050e38d
parentddf9ad88e613627b50c7ac697d63c3fc0d129865 (diff)
downloaddwm-retake-4e5ae52ad3165380108ea2985456804baf73125a.tar.gz
dwm-retake-4e5ae52ad3165380108ea2985456804baf73125a.tar.bz2
added warp patch
-rw-r--r--dwm.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index a1381e5..601c5f5 100644
--- a/dwm.c
+++ b/dwm.c
@@ -275,6 +275,7 @@ static void updatetitle(Client *c);
static void updatewindowtype(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);
@@ -1006,6 +1007,7 @@ focusmon(const Arg *arg)
unfocus(selmon->sel, 0);
selmon = m;
focus(NULL);
+ warp(selmon->sel);
}
void
@@ -1666,6 +1668,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
@@ -2535,6 +2539,28 @@ view(const Arg *arg)
arrange(selmon);
}
+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) ||
+ (y > c->mon->by && y < c->mon->by + bh) ||
+ (c->mon->topbar && !y))
+ return;
+
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
+}
+
pid_t
winpid(Window w)
{