ui: dismiss screensaver on wake instead of on awake transition (#1907)

* fix wake-up behavior

* ui: dismiss screensaver on wake instead of on awake transition

---------

Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
Nayan
2026-08-14 17:21:34 -04:00
committed by GitHub
parent 6e69da4037
commit d48cfa730b
2 changed files with 16 additions and 5 deletions
+12 -5
View File
@@ -241,19 +241,26 @@ class DeviceSP:
def _set_awake(self, on: bool, _ui_state=None):
self._blocked_by_screensaver = False
if _ui_state.boot_offroad_mode == 1 and not on:
_ui_state.params.put_bool("OffroadMode", True)
if not on and _ui_state.screensaver_enabled:
if _ui_state.screensaver.was_dismissed:
if gui_app.get_active_widget() == _ui_state.screensaver:
gui_app.pop_widget()
self.dismiss_screensaver(_ui_state)
elif _ui_state.screensaver.is_active:
self._blocked_by_screensaver = True
else:
_ui_state.screensaver.initialize()
gui_app.push_widget(_ui_state.screensaver)
self._blocked_by_screensaver = True
else:
self.dismiss_screensaver(_ui_state)
# blocked runs every frame, so write only when actually sleeping
if _ui_state.boot_offroad_mode == 1 and not on and not self._blocked_by_screensaver:
_ui_state.params.put_bool("OffroadMode", True)
def dismiss_screensaver(self, _ui_state) -> None:
if gui_app.get_active_widget() == _ui_state.screensaver:
gui_app.pop_widget()
self._blocked_by_screensaver = False
@staticmethod
def set_onroad_brightness(_ui_state, awake: bool, cur_brightness: float) -> float:
+4
View File
@@ -347,6 +347,10 @@ class Device(DeviceSP):
self._set_awake(ui_state.ignition or not interaction_timeout or PC)
def _set_awake(self, on: bool, _ui_state=None):
# screensaver holds _awake True, so waking is not a state change
if on and self._blocked_by_screensaver:
self.dismiss_screensaver(_ui_state or ui_state)
if on != self._awake:
super()._set_awake(on, _ui_state or ui_state)
if self._blocked_by_screensaver: