1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

fix(core): prevent unnecessary display refreshing

[no changelog]
This commit is contained in:
tychovrahe 2024-05-23 13:21:24 +02:00 committed by TychoVrahe
parent 0c4b1d6213
commit 5f30194a34
9 changed files with 26 additions and 23 deletions

View File

@ -52,7 +52,8 @@ class RustLayout(ui.Layout):
painted = self.layout.paint()
ui.refresh()
if painted:
ui.refresh()
if storage_cache.homescreen_shown is not None and painted:
storage_cache.homescreen_shown = None

View File

@ -36,8 +36,8 @@ if __debug__:
(io.TOUCH_END, 220, 220),
):
msg = self.layout.touch_event(event, x, y)
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
if msg is not None:
raise Result(msg)

View File

@ -19,8 +19,8 @@ class HomescreenBase(RustLayout):
super().__init__(layout=layout)
def _paint(self) -> None:
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
def _first_paint(self) -> None:
if storage_cache.homescreen_shown is not self.RENDER_INDICATOR:
@ -76,8 +76,8 @@ class Homescreen(HomescreenBase):
while True:
is_connected = await usbcheck
self.layout.usb_event(is_connected)
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
def create_tasks(self) -> Tuple[loop.AwaitableTask, ...]:
return super().create_tasks() + (self.usb_checker_task(),)

View File

@ -36,8 +36,8 @@ class RustProgress:
self.layout = layout
ui.backlight_fade(ui.BacklightLevels.DIM)
self.layout.attach_timer_fn(self.set_timer)
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
ui.backlight_fade(ui.BacklightLevels.NORMAL)
def set_timer(self, token: int, deadline: int) -> None:
@ -46,8 +46,8 @@ class RustProgress:
def report(self, value: int, description: str | None = None):
msg = self.layout.progress_event(value, description or "")
assert msg is None
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
def progress(

View File

@ -56,7 +56,8 @@ class RustLayout(LayoutParentType[T]):
painted = self.layout.paint()
ui.refresh()
if painted:
ui.refresh()
if storage_cache.homescreen_shown is not None and painted:
storage_cache.homescreen_shown = None

View File

@ -19,8 +19,8 @@ class HomescreenBase(RustLayout):
super().__init__(layout=layout)
def _paint(self) -> None:
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
def _first_paint(self) -> None:
if storage_cache.homescreen_shown is not self.RENDER_INDICATOR:
@ -65,8 +65,8 @@ class Homescreen(HomescreenBase):
while True:
is_connected = await usbcheck
self.layout.usb_event(is_connected)
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
def create_tasks(self) -> Tuple[loop.AwaitableTask, ...]:
return super().create_tasks() + (self.usb_checker_task(),)

View File

@ -58,7 +58,8 @@ class RustLayout(LayoutParentType[T]):
painted = self.layout.paint()
ui.refresh()
if painted:
ui.refresh()
if storage_cache.homescreen_shown is not None and painted:
storage_cache.homescreen_shown = None

View File

@ -36,8 +36,8 @@ if __debug__:
(io.TOUCH_END, 220, 220),
):
msg = self.layout.touch_event(event, x, y)
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
if msg is not None:
raise Result(msg)

View File

@ -19,8 +19,8 @@ class HomescreenBase(RustLayout):
super().__init__(layout=layout)
def _paint(self) -> None:
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
def _first_paint(self) -> None:
if storage_cache.homescreen_shown is not self.RENDER_INDICATOR:
@ -76,8 +76,8 @@ class Homescreen(HomescreenBase):
while True:
is_connected = await usbcheck
self.layout.usb_event(is_connected)
self.layout.paint()
ui.refresh()
if self.layout.paint():
ui.refresh()
def create_tasks(self) -> Tuple[loop.AwaitableTask, ...]:
return super().create_tasks() + (self.usb_checker_task(),)