From f2b6aa105c9b0b14eecb49984f388df7d47bc10c Mon Sep 17 00:00:00 2001 From: lesell_b Date: Thu, 8 Oct 2015 04:40:59 +0200 Subject: [PATCH] Update saved mouse position on screen focus change Signed-off-by: lesell_b --- lib/awful/screen.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 399265605..f00874dbd 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -57,10 +57,8 @@ function screen.focus(_screen) local s = capi.mouse.screen local pos - if not mouse_per_screen[s] then + if not mouse_per_screen[_screen] then -- This is the first time we enter this screen, - mouse_per_screen[s] = capi.mouse.coords() - -- keep relative mouse position on the new screen local relx = (pos.x - capi.screen[s].geometry.x) / capi.screen[s].geometry.width local rely = (pos.y - capi.screen[s].geometry.y) / capi.screen[s].geometry.height @@ -69,9 +67,12 @@ function screen.focus(_screen) pos.y = capi.screen[_screen].geometry.y + rely * capi.screen[_screen].geometry.height else -- restore mouse position - pos = mouse_per_screen[s] + pos = mouse_per_screen[_screen] end + -- save pointer position of current screen + mouse_per_screen[s] = capi.mouse.coords() + -- move cursor without triggering signals mouse::enter and mouse::leave capi.mouse.coords(pos, true)