Update saved mouse position on screen focus change
Signed-off-by: lesell_b <lesell_b@epitech.eu>
This commit is contained in:
parent
23b2fae6a9
commit
f2b6aa105c
|
@ -57,10 +57,8 @@ function screen.focus(_screen)
|
||||||
local s = capi.mouse.screen
|
local s = capi.mouse.screen
|
||||||
local pos
|
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,
|
-- This is the first time we enter this screen,
|
||||||
mouse_per_screen[s] = capi.mouse.coords()
|
|
||||||
|
|
||||||
-- keep relative mouse position on the new screen
|
-- keep relative mouse position on the new screen
|
||||||
local relx = (pos.x - capi.screen[s].geometry.x) / capi.screen[s].geometry.width
|
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
|
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
|
pos.y = capi.screen[_screen].geometry.y + rely * capi.screen[_screen].geometry.height
|
||||||
else
|
else
|
||||||
-- restore mouse position
|
-- restore mouse position
|
||||||
pos = mouse_per_screen[s]
|
pos = mouse_per_screen[_screen]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- save pointer position of current screen
|
||||||
|
mouse_per_screen[s] = capi.mouse.coords()
|
||||||
|
|
||||||
-- move cursor without triggering signals mouse::enter and mouse::leave
|
-- move cursor without triggering signals mouse::enter and mouse::leave
|
||||||
capi.mouse.coords(pos, true)
|
capi.mouse.coords(pos, true)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue