From f6961e4edf6e7f5d53260737b663f5c4428dc304 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Tue, 22 Apr 2025 22:51:53 +0100 Subject: [PATCH] request close --- system/ui/lib/application.py | 6 +++++- system/ui/text.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index 23f9316c3a..f5a238b81e 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -38,6 +38,10 @@ class GuiApplication: self._textures: list[rl.Texture] = [] self._target_fps: int = DEFAULT_FPS self._last_fps_log_time: float = time.monotonic() + self._window_close_requested = False + + def request_close(self): + self._window_close_requested = True def init_window(self, title: str, fps: int=DEFAULT_FPS): atexit.register(self.close) # Automatically call close() on exit @@ -80,7 +84,7 @@ class GuiApplication: rl.close_window() def render(self): - while not rl.window_should_close(): + while not (self._window_close_requested or rl.window_should_close()): rl.begin_drawing() rl.clear_background(rl.BLACK) diff --git a/system/ui/text.py b/system/ui/text.py index 9c7101dfe8..8c43da7071 100755 --- a/system/ui/text.py +++ b/system/ui/text.py @@ -61,7 +61,7 @@ class TextWindow: ret = gui_button(button_bounds, "Exit" if PC else "Reboot", button_style=ButtonStyle.TRANSPARENT) if ret: if PC: - gui_app.close() + gui_app.request_close() else: HARDWARE.reboot() return ret