this variant is known to work, but focus() is ugly - we need in general a better way to handle multihead, this issel-stuff looks awkward (maybe it might be a good idea to set sel to NULL but to introduce a Client *revert which is set if a screen is unfocused, have to think about it further). fcd98308
Anselm R. Garbe · 2007-01-22 10:35 2 file(s) · +13 −9
client.c +12 −8
81 81
focus(Client *c) {
82 82
	Client *old = sel;
83 83
84 -
	if(!issel || (c && !isvisible(c)))
84 +
	if(c && !isvisible(c))
85 85
		return;
86 86
87 87
	if(old && old != c) {
89 89
		XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]);
90 90
	}
91 91
	if(c) {
92 -
		detachstack(c);
93 -
		c->snext = stack;
94 -
		stack = c;
95 -
		grabbuttons(c, True);
96 -
		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
97 -
		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
92 +
		if(issel) {
93 +
			detachstack(c);
94 +
			c->snext = stack;
95 +
			stack = c;
96 +
			grabbuttons(c, True);
97 +
			XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
98 +
			XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
99 +
		}
100 +
		else
101 +
			XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
98 102
	}
99 -
	else
103 +
	else if(issel)
100 104
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
101 105
	sel = c;
102 106
	drawstatus();
event.c +1 −1
269 269
	XCrossingEvent *ev = &e->xcrossing;
270 270
271 271
	if((ev->window == root) && !ev->same_screen) {
272 -
		focus(NULL);
273 272
		issel = False;
273 +
		focus(sel);
274 274
	}
275 275
}
276 276