@@ -3,6 +3,8 @@ package accessibility
33import (
44 "fmt"
55 "image"
6+
7+ "github.com/y3owk1n/govim/internal/logger"
68)
79
810func rectFromInfo (info * ElementInfo ) image.Rectangle {
@@ -49,10 +51,27 @@ func GetClickableElements() ([]*TreeNode, error) {
4951 }
5052 defer window .Release ()
5153
54+ windowInfo , err := window .GetInfo ()
55+ if err != nil {
56+ return nil , fmt .Errorf ("failed to get window info: %w" , err )
57+ }
58+
59+ // Check if this is an Electron app
60+ var isElectron bool
61+ if app := GetApplicationByPID (windowInfo .PID ); app != nil {
62+ bundleID := app .GetBundleIdentifier ()
63+ isElectron = ShouldEnableElectronSupport (bundleID , nil )
64+ app .Release ()
65+ }
66+
5267 opts := DefaultTreeOptions ()
53- // Increase depth for Electron/web apps which have deeply nested content
54- opts .MaxDepth = 25
55- // visibleBounds := expandRectangle(rectFromInfo(windowInfo), 0)
68+ if isElectron {
69+ // For Electron apps, go deeper to find web content
70+ opts .MaxDepth = 25
71+ logger .Debug ("Detected Electron app, using deeper tree traversal for scroll areas" )
72+ } else {
73+ opts .MaxDepth = 10
74+ }
5675 opts .FilterFunc = func (info * ElementInfo ) bool {
5776 // Filter out very small elements
5877 if info .Size .X < 10 || info .Size .Y < 10 {
@@ -83,13 +102,21 @@ func GetScrollableElements() ([]*TreeNode, error) {
83102 return nil , fmt .Errorf ("failed to get window info: %w" , err )
84103 }
85104
105+ // Check if this is an Electron app
106+ var isElectron bool
107+ if app := GetApplicationByPID (windowInfo .PID ); app != nil {
108+ bundleID := app .GetBundleIdentifier ()
109+ isElectron = ShouldEnableElectronSupport (bundleID , nil )
110+ app .Release ()
111+ }
112+
86113 opts := DefaultTreeOptions ()
87- opts . MaxDepth = 5
88- visibleBounds := expandRectangle ( rectFromInfo ( windowInfo ), 200 )
89- opts .FilterFunc = func ( info * ElementInfo ) bool {
90- // Allow only elements overlapping the visible window bounds
91- elementRect := rectFromInfo ( info )
92- return elementRect . Overlaps ( visibleBounds )
114+ if isElectron {
115+ // For Electron apps, go deeper to find web content
116+ opts .MaxDepth = 15
117+ logger . Debug ( "Detected Electron app, using deeper tree traversal for scroll areas" )
118+ } else {
119+ opts . MaxDepth = 5
93120 }
94121
95122 tree , err := BuildTree (window , opts )
0 commit comments