awful.screen.getbycoord(): Always return a valid screen
No callers expect a nil result from this function. In fact, this broke awful.tooltip because it tried to get the workarea of screen nil. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
1fa23fef81
commit
987c2b9b30
|
@ -29,14 +29,18 @@ data.padding = {}
|
||||||
-- `screen` table/object.
|
-- `screen` table/object.
|
||||||
-- @param x The x coordinate
|
-- @param x The x coordinate
|
||||||
-- @param y The y coordinate
|
-- @param y The y coordinate
|
||||||
function screen.getbycoord(x, y)
|
-- @param default Optional default return value. If unspecified, 1 is returned.
|
||||||
|
function screen.getbycoord(x, y, default)
|
||||||
for i = 1, capi.screen:count() do
|
for i = 1, capi.screen:count() do
|
||||||
local geometry = capi.screen[i].geometry
|
local geometry = capi.screen[i].geometry
|
||||||
if((x < 0 or (x >= geometry.x and x < geometry.x + geometry.width))
|
if((x < 0 or (x >= geometry.x and x < geometry.x + geometry.width))
|
||||||
and (y < 0 or (y >= geometry.y and y < geometry.y + geometry.height))) then
|
and (y < 0 or (y >= geometry.y and y < geometry.y + geometry.height))) then
|
||||||
return i;
|
return i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- No caller expects a nil result here, so just make something up
|
||||||
|
if default == nil then return 1 end
|
||||||
|
return default
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Give the focus to a screen, and move pointer. Keeps relative position of the pointer on the screen.
|
--- Give the focus to a screen, and move pointer. Keeps relative position of the pointer on the screen.
|
||||||
|
|
Loading…
Reference in New Issue