Fire mouse_up events in monitor.lua (#358)

We schedule a mouse_up event 0.1 seconds after receiving a
monitor_touch event.
This commit is contained in:
Fatboychummy 2020-02-04 10:00:49 -07:00 committed by GitHub
parent 930fd59298
commit 8eae02c037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -39,6 +39,8 @@ local function resume( ... )
return param
end
local timers = {}
local ok, param = pcall( function()
local sFilter = resume()
while coroutine.status( co ) ~= "dead" do
@ -48,6 +50,7 @@ local ok, param = pcall( function()
end
if coroutine.status( co ) ~= "dead" and (sFilter == nil or sFilter == "mouse_click") then
if tEvent[1] == "monitor_touch" and tEvent[2] == sName then
timers[os.startTimer( 0.1 )] = { tEvent[3], tEvent[4] }
sFilter = resume( "mouse_click", 1, table.unpack( tEvent, 3, tEvent.n ) )
end
end
@ -56,6 +59,12 @@ local ok, param = pcall( function()
sFilter = resume( "term_resize" )
end
end
if coroutine.status( co ) ~= "dead" and (sFilter == nil or sFilter == "mouse_up") then
if tEvent[1] == "timer" and timers[tEvent[2]] then
sFilter = resume( "mouse_up", 1, table.unpack( timers[tEvent[2]], 1, 2 ) )
timers[tEvent[2]] = nil
end
end
end
end )