From 2ae0b8204c2c91407baf7b409171aca144b4018d Mon Sep 17 00:00:00 2001 From: trigg Date: Sun, 24 Mar 2024 23:27:30 +0000 Subject: [PATCH] - Fix fadeout timeouts not being cleanly canceled --- discover_overlay/voice_overlay.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/discover_overlay/voice_overlay.py b/discover_overlay/voice_overlay.py index d8f461c..815d703 100644 --- a/discover_overlay/voice_overlay.py +++ b/discover_overlay/voice_overlay.py @@ -133,15 +133,18 @@ def reset_action_timer(self): self.fade_opacity = 1.0 if self.inactive_timeout: GLib.source_remove(self.inactive_timeout) + self.inactive_timeout = None if self.fadeout_timeout: - GLib.source_remove(self.fade_opacity) + GLib.source_remove(self.fadeout_timeout) + self.fadeout_timeout = None if self.fade_out_inactive: - GLib.timeout_add_seconds(self.inactive_time, self.overlay_inactive) + self.inactive_timeout = GLib.timeout_add_seconds(self.inactive_time, self.overlay_inactive) def overlay_inactive(self): self.fade_start= perf_counter() - GLib.timeout_add(self.inactive_fade_time/200 * 1000, self.overlay_fadeout) + self.fadeout_timeout = GLib.timeout_add(self.inactive_fade_time/200 * 1000, self.overlay_fadeout) + self.inactive_timeout = None return False def overlay_fadeout(self): @@ -150,6 +153,7 @@ def overlay_fadeout(self): time_percent = (now - self.fade_start) / self.inactive_fade_time if time_percent>=1.0: self.fade_opacity = self.fade_out_limit + self.fadeout_timeout = None return False self.fade_opacity = self.fade_out_limit + ((1.0 - self.fade_out_limit) * (1.0 - time_percent))