@@ -65,16 +65,36 @@ function Stack:deleteAllIndicators() -- {{{
65
65
end )
66
66
end -- }}}
67
67
68
- function Stack :getWindowByPoint (point ) -- {{{
69
- local foundWin = u .filter (self .windows , function (w )
70
- local frame = w .indicator and w .indicator :canvasElements ()[1 ].frame
71
- if not frame then return false end
72
- return point :inside (frame ) -- NOTE: frame *must* be a hs.geometry.rect instance
73
- end )
68
+ function Stack :getWindowByPoint (p )
69
+ if p .x < 0 or p .y < 0 then
70
+ -- FIX: https://github.com/AdamWagner/stackline/issues/62
71
+ -- NOTE: Window indicator frame coordinates are relative to the window's screen.
72
+ -- So, if click point has negative X or Y vals, then convert its coordinates
73
+ -- to relative to the clicked screen before comparing to window indicator frames.
74
+ -- TODO: Clean this up after fix is confirmed
75
+
76
+ -- Get the screen with frame that contains point 'p'
77
+ local function findClickedScreen (_p ) -- {{{
78
+ return table.unpack (
79
+ u .filter (hs .screen .allScreens (), function (s )
80
+ return _p :inside (s :frame ())
81
+ end )
82
+ )
83
+ end -- }}}
74
84
75
- if # foundWin > 0 then
76
- return foundWin [1 ]
85
+ local clickedScren = findClickedScreen (p )
86
+ p = clickedScren
87
+ and clickedScren :absoluteToLocal (p )
88
+ or p
77
89
end
90
+
91
+ return table.unpack (
92
+ u .filter (self .windows , function (w )
93
+ local indicatorFrame = w .indicator and w .indicator :canvasElements ()[1 ].frame
94
+ if not indicatorFrame then return false end
95
+ return p :inside (indicatorFrame ) -- NOTE: frame *must* be a hs.geometry.rect instance
96
+ end )
97
+ )
78
98
end
79
99
80
100
return Stack
0 commit comments