diff options
author | ChrisK2 <spam@kalania.de> | 2013-10-15 21:49:06 +0200 |
---|---|---|
committer | ChrisK2 <spam@kalania.de> | 2013-10-15 21:49:06 +0200 |
commit | 97770473d0bd8f31f7fe6ff38259be1585c05e44 (patch) | |
tree | ba9cefc521e7950f7e0af3e090472e71369f7928 /mpvcore | |
parent | dd3e52fe681baac81981ff49234a405a34beedc8 (diff) | |
download | mpv-97770473d0bd8f31f7fe6ff38259be1585c05e44.tar.bz2 mpv-97770473d0bd8f31f7fe6ff38259be1585c05e44.tar.xz |
osc: reset mouse position when leaving window
and store it freshly on first mouse_move event when entering again
Diffstat (limited to 'mpvcore')
-rw-r--r-- | mpvcore/lua/osc.lua | 13 |
1 files changed, 9 insertions, 4 deletions
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 |