From 23c0397764f6d49350e1cc722865edeb66b0c493 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Sat, 22 Feb 2020 07:42:10 -0500 Subject: [PATCH] listener: mark device as inactive after resume so that settings are correctly pushed --- lib/solaar/gtk.py | 2 +- lib/solaar/listener.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py index 41aa9084..321e9cef 100755 --- a/lib/solaar/gtk.py +++ b/lib/solaar/gtk.py @@ -106,7 +106,7 @@ def main(): if args.restart_on_wake_up: _upower.watch(listener.start_all, listener.stop_all) else: - _upower.watch(listener.ping_all) + _upower.watch(lambda: listener.ping_all(True)) # main UI event loop ui.run_loop(listener.start_all, listener.stop_all, args.window!='only', args.window!='hide') diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py index ebaed4f4..f75dccb3 100644 --- a/lib/solaar/listener.py +++ b/lib/solaar/listener.py @@ -291,12 +291,16 @@ def stop_all(): for l in listeners: l.join() - -def ping_all(): +# ping all devices to find out whether they are connected +# after a resume, the device may have been off +# so mark its saved status to ensure that the status is pushed to the device when it comes back +def ping_all(resuming = False): for l in _all_listeners.values(): count = l.receiver.count() if count: for dev in l.receiver: + if resuming: + dev.status._active = False dev.ping() l._status_changed(dev) count -= 1