Hide the UI on cursor-autohide, closes #2

This commit is contained in:
Tomas Sardyha
2020-04-02 18:40:07 +02:00
parent 09b2b147b7
commit 86068623bb

View File

@@ -101,6 +101,16 @@ local config = {
background_opacity = 0.8, background_opacity = 0.8,
} }
} }
local display = {
width = 1280,
height = 720,
aspect = 1.77778,
}
local cursor = {
hidden = true, -- true when autohidden or outside of the player window
x = nil,
y = nil,
}
local state = { local state = {
filename = "", filename = "",
border = mp.get_property_native("border"), border = mp.get_property_native("border"),
@@ -111,18 +121,13 @@ local state = {
maximized = mp.get_property_native("window-maximized"), maximized = mp.get_property_native("window-maximized"),
render_timer = nil, render_timer = nil,
render_last_time = 0, render_last_time = 0,
cursor_autohide_timer = mp.add_timeout(mp.get_property_native("cursor-autohide") / 1000, function()
cursor.hidden = true
update_proximities()
request_render()
end),
mouse_bindings_enabled = false mouse_bindings_enabled = false
} }
local display = {
width = 1280,
height = 720,
aspect = 1.77778,
}
local cursor = {
hidden = true, -- true when autohidden or outside of the player window
x = nil,
y = nil,
}
local infinity = 1e309 local infinity = 1e309
local elements = { local elements = {
progressbar = { progressbar = {
@@ -698,6 +703,10 @@ function handle_mouse_move()
cursor.hidden = false cursor.hidden = false
update_cursor_position() update_cursor_position()
request_render() request_render()
-- Restart timer that hides UI when mouse is autohidden
state.cursor_autohide_timer:kill()
state.cursor_autohide_timer:resume()
end end
function handle_toggle_progress() function handle_toggle_progress()