Skip to content

Commit

Permalink
- Fix fadeout timeouts not being cleanly canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
trigg committed Mar 24, 2024
1 parent c07b87e commit 2ae0b82
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions discover_overlay/voice_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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))
Expand Down

0 comments on commit 2ae0b82

Please sign in to comment.