shims: Add a better error message when mouse.screen is called too early.

This commit is contained in:
Emmanuel Lepage Vallee 2019-08-14 01:43:04 -04:00
parent d3a0dcffcd
commit ef508462b8
1 changed files with 8 additions and 1 deletions

View File

@ -61,7 +61,14 @@ return setmetatable(mouse, {
if forced_screen and screen._deleted[forced_screen] then
forced_screen = nil
end
return screen[1]
-- Using capi.mouse.screen is *not* supported when there is zero
-- screen. Nearly all the code uses `mouse.screen` as its ultimate
-- fallback. Having no screens is tolerated during early
-- initialization and that's it.
return screen.count() > 0 and screen[1] or assert(
false, "Calling `mouse.screen` without screens isn't supported"
)
end
local h = rawget(mouse,"_i_handler")
if h then