From 152b0e2a8cb0f3c93de163a39e9c665cb515923f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 16 May 2020 13:45:16 +0200 Subject: osc: fix hovering timestamp sticking around when moving mouse away The OSC calls this "tooltip" (and although a general mechanism, there's only one instance using it). One particular problem was that with the default OSC layout, moving the mouse down and out of the window, the tooltip stuck around, because the returned mouse position was the last pixel row in the window, which still overlaps with the seek bar. Instead of introducing mouse_in_window, you could check last_mouse_X for nil, but I think this is clearer. This returns (-1, -1) to the caller if the mouse is outside. Kind of random, but works. --- player/lua/osc.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'player') diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 2c0375c7ed..af59470335 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -102,6 +102,7 @@ local state = { mp_screen_sizeX, mp_screen_sizeY, -- last screen-resolution, to detect resolution changes to issue reINITs initREQ = false, -- is a re-init request pending? last_mouseX, last_mouseY, -- last mouse position, to detect significant mouse movement + mouse_in_window = false, message_text, message_hide_timer, fullscreen = false, @@ -160,9 +161,13 @@ end -- return mouse position in virtual ASS coordinates (playresx/y) function get_virt_mouse_pos() - local sx, sy = get_virt_scale_factor() - local x, y = mp.get_mouse_pos() - return x * sx, y * sy + if state.mouse_in_window then + local sx, sy = get_virt_scale_factor() + local x, y = mp.get_mouse_pos() + return x * sx, y * sy + else + return -1, -1 + end end function set_virt_mouse_area(x0, y0, x1, y1, name) @@ -2212,6 +2217,7 @@ function mouse_leave() end -- reset mouse position state.last_mouseX, state.last_mouseY = nil, nil + state.mouse_in_window = false end function request_init() @@ -2449,6 +2455,8 @@ function process_event(source, what) elseif source == "mouse_move" then + state.mouse_in_window = true + local mouseX, mouseY = get_virt_mouse_pos() if (user_opts.minmousemove == 0) or (not ((state.last_mouseX == nil) or (state.last_mouseY == nil)) and -- cgit v1.2.3