aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dwm.c26
-rw-r--r--patches/dwm-warp-6.2.diff58
2 files changed, 84 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 23fb7a1..e0d2f45 100644
--- a/dwm.c
+++ b/dwm.c
@@ -228,6 +228,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 int xerror(Display *dpy, XErrorEvent *ee);
@@ -834,6 +835,7 @@ focusmon(const Arg *arg)
unfocus(selmon->sel, 0);
selmon = m;
focus(NULL);
+ warp(selmon->sel);
}
void
@@ -1378,6 +1380,8 @@ restack(Monitor *m)
}
XSync(dpy, False);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2])
+ warp(m->sel);
}
void
@@ -2072,6 +2076,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);
+}
+
Client *
wintoclient(Window w)
{
diff --git a/patches/dwm-warp-6.2.diff b/patches/dwm-warp-6.2.diff
new file mode 100644
index 0000000..813c41d
--- /dev/null
+++ b/patches/dwm-warp-6.2.diff
@@ -0,0 +1,58 @@
+diff --git a/dwm.c b/dwm.c
+index 4465af1..bf74f60 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -227,6 +227,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 int xerror(Display *dpy, XErrorEvent *ee);
+@@ -827,6 +828,7 @@ focusmon(const Arg *arg)
+ unfocus(selmon->sel, 0);
+ selmon = m;
+ focus(NULL);
++ warp(selmon->sel);
+ }
+
+ void
+@@ -1367,6 +1369,8 @@ restack(Monitor *m)
+ }
+ XSync(dpy, False);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
++ if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2])
++ warp(m->sel);
+ }
+
+ void
+@@ -2044,6 +2048,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);
++}
++
+ Client *
+ wintoclient(Window w)
+ {
remember that computers suck.