diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -112,9 +112,11 @@ func handleEvent(conn *xgb.Conn, ev xgb.Event) { drawBar(conn) } case xproto.EnterNotifyEvent: // change focused window event - focused = e.Event - setInputFocus(conn, focused) - drawBar(conn) + if _, ok := clients[e.Event]; ok && e.Event != focused { + focused = e.Event + setInputFocus(conn, focused) + drawBar(conn) + } case xproto.ExposeEvent: if e.Window == barWindow { drawBar(conn) @@ -785,6 +787,20 @@ func trimTitle(value []byte) string { return string(value) } +func refocus(conn *xgb.Conn) { + for _, c := range ActiveClients { + if c.Win == focused { + return + } + } + focused = 0 + if len(ActiveClients) > 0 { + focused = ActiveClients[0].Win + } + setInputFocus(conn, focused) + drawBar(conn) +} + func updateWindows(conn *xgb.Conn) { ActiveClients = ActiveClients[:0] for _, client := range clientList { @@ -806,4 +822,6 @@ func updateWindows(conn *xgb.Conn) { default: log.Fatal("Unknown layout ", layout) } + + refocus(conn) } |