From f0b6e36ac1ccbc0a5eace507223d4b4f7ee072ce Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 18 Jul 2019 00:25:16 -0400 Subject: [PATCH] tests: Implement mouse.screen properly --- tests/examples/shims/mouse.lua | 7 +++++++ tests/examples/shims/screen.lua | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/examples/shims/mouse.lua b/tests/examples/shims/mouse.lua index f6fd4ff3a..128e49e67 100644 --- a/tests/examples/shims/mouse.lua +++ b/tests/examples/shims/mouse.lua @@ -62,6 +62,13 @@ return setmetatable(mouse, { forced_screen = nil end + for s in screen do + if coords.x > s.geometry.x and coords.x < s.geometry.x +s.geometry.width + and coords.y > s.geometry.y and coords.y < s.geometry.y +s.geometry.height then + return s + end + end + -- 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 diff --git a/tests/examples/shims/screen.lua b/tests/examples/shims/screen.lua index a1e2cf767..76e62ff78 100644 --- a/tests/examples/shims/screen.lua +++ b/tests/examples/shims/screen.lua @@ -35,12 +35,6 @@ local function create_screen(args) local wa = args.workarea_sides or 10 - -- This will happen if `clear()` is called - if mouse and (screen.count() > 0 and not mouse.screen) then - screen[s] = s - mouse.screen = s - end - return setmetatable(s,{ __index = function(_, key) assert(s.valid)