fix: touchscreen interactions don't require extra presses
previously activating a control meant tapping it once to enable proximity, then tapping it again to do the actual interaction. now a single tap will do that. previously the following glitch was present: - interact with a slider - release touch on that slider - touch a different control ->input would be received by the old control now the input is received by the correct control
This commit is contained in:
@@ -328,7 +328,7 @@ cursor = {
|
|||||||
mbtn_left_enabled = nil,
|
mbtn_left_enabled = nil,
|
||||||
wheel_enabled = nil,
|
wheel_enabled = nil,
|
||||||
decide_keybinds = function()
|
decide_keybinds = function()
|
||||||
local enable_mbtn_left = (cursor.on_primary_down or cursor.on_primary_up) ~= nil
|
local enable_mbtn_left = true -- (cursor.on_primary_down or cursor.on_primary_up) ~= nil
|
||||||
local enable_wheel = (cursor.on_wheel_down or cursor.on_wheel_up) ~= nil
|
local enable_wheel = (cursor.on_wheel_down or cursor.on_wheel_up) ~= nil
|
||||||
if enable_mbtn_left ~= cursor.mbtn_left_enabled then
|
if enable_mbtn_left ~= cursor.mbtn_left_enabled then
|
||||||
local flags = cursor.allow_dragging and 'allow-vo-dragging' or nil
|
local flags = cursor.allow_dragging and 'allow-vo-dragging' or nil
|
||||||
@@ -548,7 +548,7 @@ function update_cursor_position(x, y)
|
|||||||
-- displays the top bar, so we hardcode cursor position as infinity until
|
-- displays the top bar, so we hardcode cursor position as infinity until
|
||||||
-- we receive a first real mouse move event with coordinates other than 0,0.
|
-- we receive a first real mouse move event with coordinates other than 0,0.
|
||||||
if not state.first_real_mouse_move_received then
|
if not state.first_real_mouse_move_received then
|
||||||
if x > 0 and y > 0 then state.first_real_mouse_move_received = true
|
if x > 0 and y > 0 and x < INFINITY and y < INFINITY then state.first_real_mouse_move_received = true
|
||||||
else x, y = INFINITY, INFINITY end
|
else x, y = INFINITY, INFINITY end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -556,15 +556,18 @@ function update_cursor_position(x, y)
|
|||||||
cursor.x, cursor.y = (x + 0.5) / display.scale_x, (y + 0.5) / display.scale_y
|
cursor.x, cursor.y = (x + 0.5) / display.scale_x, (y + 0.5) / display.scale_y
|
||||||
|
|
||||||
if old_x ~= cursor.x or old_y ~= cursor.y then
|
if old_x ~= cursor.x or old_y ~= cursor.y then
|
||||||
Elements:update_proximities()
|
is_leave = cursor.x == INFINITY or cursor.y == INFINITY
|
||||||
|
is_enter = cursor.hidden and not is_leave;
|
||||||
if cursor.x == INFINITY or cursor.y == INFINITY then
|
if is_enter then
|
||||||
cursor.hidden, cursor.history = true, {}
|
|
||||||
Elements:trigger('global_mouse_leave')
|
|
||||||
elseif cursor.hidden then
|
|
||||||
cursor.hidden, cursor.history = false, {}
|
cursor.hidden, cursor.history = false, {}
|
||||||
Elements:trigger('global_mouse_enter')
|
Elements:trigger('global_mouse_enter')
|
||||||
else
|
end
|
||||||
|
Elements:update_proximities()
|
||||||
|
|
||||||
|
if is_leave then
|
||||||
|
cursor.hidden, cursor.history = true, {}
|
||||||
|
Elements:trigger('global_mouse_leave')
|
||||||
|
elseif not is_enter then
|
||||||
-- Update cursor history
|
-- Update cursor history
|
||||||
for i = 1, cursor.history_size - 1, 1 do
|
for i = 1, cursor.history_size - 1, 1 do
|
||||||
cursor.history[i] = cursor.history[i + 1]
|
cursor.history[i] = cursor.history[i + 1]
|
||||||
@@ -576,7 +579,7 @@ function update_cursor_position(x, y)
|
|||||||
cursor.queue_autohide()
|
cursor.queue_autohide()
|
||||||
end
|
end
|
||||||
|
|
||||||
request_render()
|
render()
|
||||||
end
|
end
|
||||||
|
|
||||||
function handle_mouse_leave()
|
function handle_mouse_leave()
|
||||||
@@ -673,7 +676,9 @@ function handle_mouse_pos(_, mouse)
|
|||||||
else
|
else
|
||||||
update_cursor_position(mouse.x, mouse.y)
|
update_cursor_position(mouse.x, mouse.y)
|
||||||
end
|
end
|
||||||
|
if state.first_real_mouse_move_received then
|
||||||
cursor.hover_raw = mouse.hover
|
cursor.hover_raw = mouse.hover
|
||||||
|
end
|
||||||
end
|
end
|
||||||
mp.observe_property('mouse-pos', 'native', handle_mouse_pos)
|
mp.observe_property('mouse-pos', 'native', handle_mouse_pos)
|
||||||
mp.observe_property('osc', 'bool', function(name, value) if value == true then mp.set_property('osc', 'no') end end)
|
mp.observe_property('osc', 'bool', function(name, value) if value == true then mp.set_property('osc', 'no') end end)
|
||||||
@@ -869,11 +874,13 @@ mp.observe_property('core-idle', 'native', create_state_setter('core_idle'))
|
|||||||
|
|
||||||
--[[ KEY BINDS ]]
|
--[[ KEY BINDS ]]
|
||||||
|
|
||||||
|
cursor.decide_keybinds()
|
||||||
|
|
||||||
-- Pointer related binding groups
|
-- Pointer related binding groups
|
||||||
function make_cursor_handler(event, cb)
|
function make_cursor_handler(event, cb)
|
||||||
return function(...)
|
return function(...)
|
||||||
call_maybe(cursor[event], ...)
|
|
||||||
call_maybe(cb, ...)
|
call_maybe(cb, ...)
|
||||||
|
call_maybe(cursor[event], ...)
|
||||||
cursor.queue_autohide() -- refresh cursor autohide timer
|
cursor.queue_autohide() -- refresh cursor autohide timer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user