diff options
Diffstat (limited to 'find.go')
| -rw-r--r-- | find.go | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -5,6 +5,7 @@ package main import ( "github.com/awesome-gocui/gocui" + log "go.wit.com/log" "go.wit.com/widget" ) @@ -108,6 +109,27 @@ func (tk *guiWidget) findBG() *guiWidget { return nil } +func findNextWindow() *guiWidget { + var found bool + if len(me.allwin) == 0 { + return nil + } + for _, win := range me.allwin { + if win.activeWindow { + found = true + win.activeWindow = false + continue + } + if found { + win.activeWindow = true + return win + } + } + me.allwin[0].activeWindow = true + // at the end, loop to the beginning + return me.allwin[0] +} + func findWindowUnderMouse() *guiWidget { w, h := me.baseGui.MousePosition() @@ -117,6 +139,30 @@ func findWindowUnderMouse() *guiWidget { return me.stdout.tk } } + + // now check if the active window is below the mouse + for _, win := range me.allwin { + if win.activeWindow { + if win.full.inRect(w, h) { + return win + } + } + } + + // well, just find any window then + for _, win := range me.allwin { + if win.full.inRect(w, h) { + return win + } + } + + // okay, no window. maybe the stdout is there? + if me.stdout.tk.full.inRect(w, h) { + return me.stdout.tk + } + + // geez. nothing! maybe auto return stdout? + log.Info("no window found at", w, h) return nil } |
