From 4ef63d94162e5b5fedf8781a407f7c6e4d921703 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Oct 2016 21:00:47 +0200 Subject: [PATCH] awful.screen: Save last mouse position as screen property Instead of using a weak table to save the last mouse position, this is now saved directly as a property under the screen. Signed-off-by: Uli Schlachter --- lib/awful/screen.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 9d593029..64fd6d54 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -31,8 +31,6 @@ local screen = {object={}} local data = {} data.padding = {} -screen.mouse_per_screen = setmetatable({}, {__mode="k"}) - --- Take an input geometry and substract/add a delta. -- @tparam table geo A geometry (width, height, x, y) table. -- @tparam table delta A delta table (top, bottom, x, y). @@ -99,7 +97,7 @@ function screen.focus(_screen) local s = get_screen(capi.mouse.screen) local pos - if not screen.mouse_per_screen[_screen] then + if not _screen.mouse_per_screen then -- This is the first time we enter this screen, -- keep relative mouse position on the new screen. pos = capi.mouse.coords() @@ -110,11 +108,11 @@ function screen.focus(_screen) pos.y = _screen.geometry.y + rely * _screen.geometry.height else -- restore mouse position - pos = screen.mouse_per_screen[_screen] + pos = _screen.mouse_per_screen end -- save pointer position of current screen - screen.mouse_per_screen[s] = capi.mouse.coords() + s.mouse_per_screen = capi.mouse.coords() -- move cursor without triggering signals mouse::enter and mouse::leave capi.mouse.coords(pos, true)