entirely rework event handling take 7

This commit is contained in:
2025-12-29 01:37:17 -05:00
parent 1383a697ae
commit 9a11a20e5a

View File

@ -53,10 +53,6 @@ function handlers.handlePasswordInput()
local password = "" local password = ""
state.enteringPassword = true 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 -- Register high-priority click handler for password input
local function passwordClickHandler(eventType, side, x, y) local function passwordClickHandler(eventType, side, x, y)
if not state.enteringPassword then if not state.enteringPassword then
@ -100,9 +96,9 @@ function handlers.handlePasswordInput()
return true -- Consume all clicks during password entry return true -- Consume all clicks during password entry
end end
-- Clear monitor_touch handlers and register only password handler -- Clear all monitor_touch handlers and register only password handler
eventHandlers["monitor_touch"] = { passwordClickHandler } events.clearHandlers("monitor_touch")
handlerPriorities["monitor_touch"] = { events.PRIORITY.PASSWORD_INPUT } events.registerHandler("monitor_touch", passwordClickHandler, events.PRIORITY.PASSWORD_INPUT)
-- Wait for password submission -- Wait for password submission
while state.enteringPassword do while state.enteringPassword do
@ -113,14 +109,10 @@ function handlers.handlePasswordInput()
-- Don't process the result here - the handler already did it -- Don't process the result here - the handler already did it
end end
-- Restore old handlers -- Re-register connection handlers after password entry completes
eventHandlers["monitor_touch"] = oldHandlers
handlerPriorities["monitor_touch"] = oldPriorities
-- If no handlers to restore, re-register connection handlers
if #oldHandlers == 0 then
handlers.setupConnectionHandlers() handlers.setupConnectionHandlers()
end -- Send password attempt
-- Send password attempt
utils.sendPasswordAttempt(password) utils.sendPasswordAttempt(password)
return password return password