From: Marco Peereboom Date: Sat, 3 Oct 2009 21:43:07 +0000 (+0000) Subject: Focus the right window when cycling through visible screens. X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=d13a63373bf77913c330105fa048a044a67f8969;hp=0b529de4f6130d73f2ee7b98b23b7e9938c39b41;p=spectrwm.git Focus the right window when cycling through visible screens. Since we are warping the pointer put it in the right windows as well. --- diff --git a/scrotwm.c b/scrotwm.c index 380eaf1..e8361a7 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -1353,8 +1353,10 @@ cyclews(struct swm_region *r, union arg *args) void cyclescr(struct swm_region *r, union arg *args) { - struct swm_region *rr; - int i; + struct swm_region *rr = NULL; + struct workspace *ws = NULL; + struct ws_win *winfocus = NULL; + int i, x, y; /* do nothing if we don't have more than one screen */ if (!(ScreenCount(display) > 1 || outputs > 1)) @@ -1375,10 +1377,28 @@ cyclescr(struct swm_region *r, union arg *args) default: return; }; + if (rr == NULL) + return; + + ws = rr->ws; + winfocus = ws->focus; + if (winfocus == NULL) + winfocus = ws->focus_prev; + if (winfocus) { + /* use window coordinates */ + x = winfocus->g.x + 1; + y = winfocus->g.y + 1; + } else { + /* use region coordinates */ + x = rr->g.x + 1; + y = rr->g.y + 1 + bar_enabled ? bar_height : 0; + } + unfocus_all(); XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime); - XWarpPointer(display, None, rr->s[i].root, 0, 0, 0, 0, rr->g.x + 1, - rr->g.y + bar_enabled + 1 ? bar_height : 0); + XWarpPointer(display, None, rr->s[i].root, 0, 0, 0, 0, x, y); + + focus_win(winfocus); } void