Commits

Anonymous committed ccf5a5f

add warp

  • Participants
  • Parent commits dd2ce1f
  • Branches emg

Comments (0)

Files changed (1)

 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 int xerror(Display *dpy, XErrorEvent *ee);
 	unfocus(selmon->sel, True);
 	selmon = m;
 	focus(NULL);
+	warp(selmon->sel);
 }
 
 void
 	}
 	XSync(dpy, False);
 	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+	if (m == selmon && (m->tagset[m->seltags] & m->sel->tags))
+		warp(m->sel);
 }
 
 void
 	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;