2 Commits

Author SHA1 Message Date
80b767e966 more debug logging 2023-08-30 05:51:52 +00:00
8998e63123 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
2023-08-30 05:51:51 +00:00
3 changed files with 26 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
msg = require('mp.msg')
local Element = require('elements/Element')
--[[ MuteButton ]]
@@ -73,7 +74,9 @@ function VolumeSlider:render()
if width <= 0 or height <= 0 or visibility <= 0 then return end
msg.trace("VolumeSlider: proximity_raw:", self.proximity_raw)
if self.proximity_raw == 0 then
msg.trace("VolumeSlider: setting on_primary_down")
cursor.on_primary_down = function()
self.pressed = true
self:set_from_cursor()

View File

@@ -1,4 +1,5 @@
--[[ UI specific utilities that might or might not depend on its state or options ]]
msg = require('mp.msg')
--- In place sorting of filenames
---@param filenames string[]
@@ -621,6 +622,7 @@ end
function render()
if not display.initialized then return end
msg.trace("render")
state.render_last_time = mp.get_time()
cursor.reset_handlers()

View File

@@ -327,7 +327,7 @@ cursor = {
mbtn_left_enabled = nil,
wheel_enabled = nil,
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
if enable_mbtn_left ~= cursor.mbtn_left_enabled then
local flags = cursor.allow_dragging and 'allow-vo-dragging' or nil
@@ -366,7 +366,7 @@ cursor = {
-- 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.
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
end
@@ -374,9 +374,16 @@ cursor = {
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
is_leave = cursor.x == INFINITY or cursor.y == INFINITY
is_enter = cursor.hidden and not is_leave;
if is_enter then
cursor.hidden = false
cursor.history:clear()
Elements:trigger('global_mouse_enter')
end
Elements:update_proximities()
if cursor.x == INFINITY or cursor.y == INFINITY then
if is_leave then
cursor.hidden = true
cursor.history:clear()
@@ -391,11 +398,7 @@ cursor = {
end
Elements:trigger('global_mouse_leave')
elseif cursor.hidden then
cursor.hidden = false
cursor.history:clear()
Elements:trigger('global_mouse_enter')
else
elseif not is_enter then
-- Update history
cursor.history:insert({x = cursor.x, y = cursor.y, time = mp.get_time()})
end
@@ -404,7 +407,7 @@ cursor = {
cursor.queue_autohide()
end
request_render()
render()
end,
leave = function () cursor.move(INFINITY, INFINITY) end,
-- Cursor auto-hiding after period of inactivity
@@ -680,12 +683,15 @@ end
function handle_mouse_pos(_, mouse)
if not mouse then return end
msg.trace("handle_mouse_pos: x:", mouse.x, ", y:", mouse.y, ", hover:", mouse.hover, ", hover_raw:", cursor.hover_raw, "first_real_received:", state.first_real_mouse_move_received)
if cursor.hover_raw and not mouse.hover then
cursor.leave()
else
cursor.move(mouse.x, mouse.y)
end
cursor.hover_raw = mouse.hover
if state.first_real_mouse_move_received then
cursor.hover_raw = mouse.hover
end
end
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)
@@ -881,11 +887,15 @@ mp.observe_property('core-idle', 'native', create_state_setter('core_idle'))
--[[ KEY BINDS ]]
cursor.decide_keybinds()
-- Pointer related binding groups
function make_cursor_handler(event, cb)
return function(...)
call_maybe(cursor[event], ...)
msg.trace("UOSC EVENT:", event)
call_maybe(cb, ...)
msg.trace("calling cursor[event]", cursor[event])
call_maybe(cursor[event], ...)
cursor.queue_autohide() -- refresh cursor autohide timer
end
end