summaryrefslogtreecommitdiff
path: root/find.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-06 07:39:31 -0600
committerJeff Carr <[email protected]>2025-02-06 07:39:31 -0600
commitc4095ef7aa24abe780ae49cd674b7187c39cd995 (patch)
treeb2ef730479c25c896cef6234ae56be2570a9aef2 /find.go
parentc136ca2b4c33ae639af0f62f604ecdf73ea38d3e (diff)
not sure why mouse clicks are working weird
Diffstat (limited to 'find.go')
-rw-r--r--find.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/find.go b/find.go
index 6fd84a7..a248a09 100644
--- a/find.go
+++ b/find.go
@@ -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
}