sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-warp-5.9.diff (1288B)


      1 diff -r cfcfa05033e3 dwm.c
      2 --- a/dwm.c	Fri Oct 28 23:45:12 2011 +0100
      3 +++ b/dwm.c	Fri Oct 28 18:43:14 2011 -0700
      4 @@ -240,6 +240,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 @@ -898,6 +899,7 @@
     13  	unfocus(selmon->sel, True);
     14  	selmon = m;
     15  	focus(NULL);
     16 +	warp(selmon->sel);
     17  }
     18  
     19  void
     20 @@ -1418,6 +1420,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 @@ -1994,6 +1998,26 @@
     30  	arrange(selmon);
     31  }
     32  
     33 +void
     34 +warp(const Client *c) {
     35 +	Window dummy;
     36 +	int x, y, di;
     37 +	unsigned int dui;
     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 +	XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
     45 +
     46 +	if((x > c->x && y > c->y && x < c->x + c->w && y < c->y + c->h) ||
     47 +	   (y > c->mon->by && y < c->mon->by + bh))
     48 +		return;
     49 +
     50 +	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
     51 +}
     52 +
     53  Client *
     54  wintoclient(Window w) {
     55  	Client *c;