entirely rework event handling take 6

This commit is contained in:
2025-12-29 01:36:18 -05:00
parent b37fff262d
commit 1383a697ae

View File

@ -53,6 +53,10 @@ function handlers.handlePasswordInput()
local password = ""
state.enteringPassword = true
-- Store old handlers to restore later
local oldHandlers = eventHandlers["monitor_touch"] or {}
local oldPriorities = handlerPriorities["monitor_touch"] or {}
-- Register high-priority click handler for password input
local function passwordClickHandler(eventType, side, x, y)
if not state.enteringPassword then
@ -96,10 +100,9 @@ function handlers.handlePasswordInput()
return true -- Consume all clicks during password entry
end
-- Register the password handler with highest priority
-- First, clear all monitor_touch handlers to avoid duplicates
events.clearHandlers("monitor_touch")
events.registerHandler("monitor_touch", passwordClickHandler, events.PRIORITY.PASSWORD_INPUT)
-- Clear monitor_touch handlers and register only password handler
eventHandlers["monitor_touch"] = { passwordClickHandler }
handlerPriorities["monitor_touch"] = { events.PRIORITY.PASSWORD_INPUT }
-- Wait for password submission
while state.enteringPassword do
@ -107,15 +110,17 @@ function handlers.handlePasswordInput()
if result == "submit" then
break
end
-- Don't process the result here - the handler already did it
end
-- Unregister the password handler
events.clearHandlers("monitor_touch")
-- Restore old handlers
eventHandlers["monitor_touch"] = oldHandlers
handlerPriorities["monitor_touch"] = oldPriorities
-- Re-register connection handlers after password entry completes
-- If no handlers to restore, re-register connection handlers
if #oldHandlers == 0 then
handlers.setupConnectionHandlers()
-- Send password attempt
end -- Send password attempt
utils.sendPasswordAttempt(password)
return password