making enternotify less focus hungry
3a392b85
2 file(s) · +4 −21
| 8 | 8 | ||
| 9 | 9 | --- |
|
| 10 | 10 | ||
| 11 | - | > enternotify is handled even when the entered window is already focused |
|
| 12 | - | > (eg moving the mouse to the bar and back, scrolling on the border..) |
|
| 13 | - | > |
|
| 14 | - | > focusing might be expensive for some clients (eg dim/light up) |
|
| 15 | - | > |
|
| 16 | - | > a possible solution is to modify enternotify: |
|
| 17 | - | > |
|
| 18 | - | > + c = wintoclient(ev->window); |
|
| 19 | - | > if((m = wintomon(ev->window)) && m != selmon) { |
|
| 20 | - | > unfocus(selmon->sel); |
|
| 21 | - | > selmon = m; |
|
| 22 | - | > } |
|
| 23 | - | > + else if (c == selmon->sel || c == NULL) |
|
| 24 | - | > + return; |
|
| 25 | - | ||
| 26 | - | --- |
|
| 27 | - | ||
| 28 | - | dmenu appears on the monitor where the pointer is and not on selmon |
|
| 29 | - | ||
| 30 | - | --- |
|
| 31 | - | ||
| 32 | 11 | yet another corner case: |
|
| 33 | 12 | open a terminal, focus another monitor, but without moving the mouse |
|
| 34 | 13 | pointer there |
| 820 | 820 | ||
| 821 | 821 | void |
|
| 822 | 822 | enternotify(XEvent *e) { |
|
| 823 | + | Client *c; |
|
| 823 | 824 | Monitor *m; |
|
| 824 | 825 | XCrossingEvent *ev = &e->xcrossing; |
|
| 825 | 826 | ||
| 826 | 827 | if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) |
|
| 827 | 828 | return; |
|
| 829 | + | c = wintoclient(ev->window); |
|
| 828 | 830 | if((m = wintomon(ev->window)) && m != selmon) { |
|
| 829 | 831 | unfocus(selmon->sel, True); |
|
| 830 | 832 | selmon = m; |
|
| 831 | 833 | } |
|
| 834 | + | else if(c == selmon->sel || c == NULL) |
|
| 835 | + | return; |
|
| 832 | 836 | focus((wintoclient(ev->window))); |
|
| 833 | 837 | } |
|
| 834 | 838 |