From 97770473d0bd8f31f7fe6ff38259be1585c05e44 Mon Sep 17 00:00:00 2001 From: ChrisK2 Date: Tue, 15 Oct 2013 21:49:06 +0200 Subject: osc: reset mouse position when leaving window and store it freshly on first mouse_move event when entering again --- mpvcore/lua/osc.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'mpvcore') diff --git a/mpvcore/lua/osc.lua b/mpvcore/lua/osc.lua index 3ce66df2d9..19bd8c90fe 100644 --- a/mpvcore/lua/osc.lua +++ b/mpvcore/lua/osc.lua @@ -21,7 +21,7 @@ local user_opts = { hidetimeout = 500, -- duration in ms until the OSC hides if no mouse movement, negative value disables autohide fadeduration = 200, -- duration of fade out in ms, 0 = no fade deadzonesize = 0, -- size of deadzone - minmousemove = 3, -- minimum amount of pixeles the mouse has to move between ticks to make the OSC show up + minmousemove = 3, -- minimum amount of pixels the mouse has to move between ticks to make the OSC show up iAmAProgrammer = false, -- use native mpv values and disable OSC internal playlist management (and some functions that depend on it) } @@ -1022,6 +1022,8 @@ end function mouse_leave() hide_osc() + -- reset mouse position + state.last_mouseX, state.last_mouseY = nil, nil end function request_init() @@ -1176,9 +1178,12 @@ function process_event(source, what) elseif source == "mouse_move" then local mouseX, mouseY = mp.get_mouse_pos() - if (user_opts.minmousemove == 0) - or ((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove) - or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove)) then + if (user_opts.minmousemove == 0) or + (not ((state.last_mouseX == nil) or (state.last_mouseY == nil)) and + ((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove) + or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove) + ) + ) then show_osc() end state.last_mouseX, state.last_mouseY = mouseX, mouseY -- cgit v1.2.3