this version should also work with cornercases (like unmanage during !issel, etc.)
17ec726b
1 file(s) · +7 −7
| 79 | 79 | ||
| 80 | 80 | void |
|
| 81 | 81 | focus(Client *c) { |
|
| 82 | - | Client *old = sel; |
|
| 83 | - | ||
| 84 | 82 | if(c && !isvisible(c)) |
|
| 85 | 83 | return; |
|
| 86 | 84 | ||
| 87 | - | if(old && old != c) { |
|
| 88 | - | grabbuttons(old, False); |
|
| 89 | - | XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]); |
|
| 85 | + | if(sel && sel != c) { |
|
| 86 | + | grabbuttons(sel, False); |
|
| 87 | + | XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); |
|
| 90 | 88 | } |
|
| 89 | + | sel = c; |
|
| 90 | + | if(!issel) |
|
| 91 | + | return; |
|
| 91 | 92 | if(c) { |
|
| 92 | 93 | detachstack(c); |
|
| 93 | 94 | c->snext = stack; |
|
| 96 | 97 | XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); |
|
| 97 | 98 | XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
|
| 98 | 99 | } |
|
| 99 | - | else if(issel) |
|
| 100 | + | else |
|
| 100 | 101 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
|
| 101 | - | sel = c; |
|
| 102 | 102 | drawstatus(); |
|
| 103 | 103 | } |
|
| 104 | 104 | ||