mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-02 04:42:33 +00:00

This avoids problems with large timeouts causing the scheduler queue to think the time counter has overflown, and ordering the autolock task before immediate tasks. The maximum reasonable time difference is 0x20000000, which in microseconds is ~8 minutes, but in milliseconds a more reasonable ~6 days.
24 lines
689 B
Python
24 lines
689 B
Python
from trezor import loop, ui, utils
|
|
|
|
if False:
|
|
from typing import Tuple
|
|
|
|
|
|
class Popup(ui.Layout):
|
|
def __init__(self, content: ui.Component, time_ms: int = 0) -> None:
|
|
self.content = content
|
|
if utils.DISABLE_ANIMATION:
|
|
self.time_ms = 0
|
|
else:
|
|
self.time_ms = time_ms
|
|
|
|
def dispatch(self, event: int, x: int, y: int) -> None:
|
|
self.content.dispatch(event, x, y)
|
|
|
|
def create_tasks(self) -> Tuple[loop.Task, ...]:
|
|
return self.handle_input(), self.handle_rendering(), self.handle_timeout()
|
|
|
|
def handle_timeout(self) -> loop.Task: # type: ignore
|
|
yield loop.sleep(self.time_ms)
|
|
raise ui.Result(None)
|