mirror of
https://github.com/mpv-player/mpv
synced 2025-01-30 11:42:04 +00:00
osc: reset mouse position when leaving window
and store it freshly on first mouse_move event when entering again
This commit is contained in:
parent
dd3e52fe68
commit
97770473d0
@ -21,7 +21,7 @@ local user_opts = {
|
|||||||
hidetimeout = 500, -- duration in ms until the OSC hides if no mouse movement, negative value disables autohide
|
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
|
fadeduration = 200, -- duration of fade out in ms, 0 = no fade
|
||||||
deadzonesize = 0, -- size of deadzone
|
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)
|
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()
|
function mouse_leave()
|
||||||
hide_osc()
|
hide_osc()
|
||||||
|
-- reset mouse position
|
||||||
|
state.last_mouseX, state.last_mouseY = nil, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function request_init()
|
function request_init()
|
||||||
@ -1176,9 +1178,12 @@ function process_event(source, what)
|
|||||||
|
|
||||||
elseif source == "mouse_move" then
|
elseif source == "mouse_move" then
|
||||||
local mouseX, mouseY = mp.get_mouse_pos()
|
local mouseX, mouseY = mp.get_mouse_pos()
|
||||||
if (user_opts.minmousemove == 0)
|
if (user_opts.minmousemove == 0) or
|
||||||
or ((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove)
|
(not ((state.last_mouseX == nil) or (state.last_mouseY == nil)) and
|
||||||
or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove)) then
|
((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove)
|
||||||
|
or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove)
|
||||||
|
)
|
||||||
|
) then
|
||||||
show_osc()
|
show_osc()
|
||||||
end
|
end
|
||||||
state.last_mouseX, state.last_mouseY = mouseX, mouseY
|
state.last_mouseX, state.last_mouseY = mouseX, mouseY
|
||||||
|
Loading…
Reference in New Issue
Block a user