[gnome-shell/gnome-42] status/bluetooth: Fix remembering set up devices
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-42] status/bluetooth: Fix remembering set up devices
- Date: Thu, 11 Aug 2022 12:43:05 +0000 (UTC)
commit 84dc2a5b275a241749207a04ed3fdd84c8bf5373
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Aug 8 03:10:06 2022 +0200
status/bluetooth: Fix remembering set up devices
It is generally not possible to differentiate between systems
without bluetooth support, and systems where a bluetooth adapter
is powered down.
We work around that by tracking whether there are any set up devices,
and keep the bluetooth visible in that case, even when no adapter
is present.
However commit eeabdd150c7 moved updating the setting into the code
that handles adapter changes, which is exactly the place where we
carefully avoid changing the setting because it would be too
unreliable (devices may have already disappeared, or not yet
appeared).
Fix this by changing _setHadSetupDevices() to _syncHadSetupDevices()
and call that everywhere _sync() used to be called, *except* on
adapter changes.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5714
Part-of:
<https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2409>
(cherry picked from commit 4fd4b09919415046e6c56bf955dd3a61a2d0b928)
js/ui/status/bluetooth.js | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index 5e985dd1af..d21770f0c9 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -29,10 +29,6 @@ class Indicator extends PanelMenu.SystemIndicator {
this._client = new GnomeBluetooth.Client();
this._client.connect('notify::default-adapter', () => {
const newAdapter = this._client.default_adapter ?? null;
-
- if (newAdapter && this._adapter)
- this._setHadSetupDevices(this._getDeviceInfos().length > 0);
-
this._adapter = newAdapter;
this._deviceNotifyConnected.clear();
@@ -88,11 +84,17 @@ class Indicator extends PanelMenu.SystemIndicator {
this._sync();
}
- _setHadSetupDevices(value) {
- if (this._hadSetupDevices === value)
+ _syncHadSetupDevices() {
+ const { defaultAdapter } = this._client;
+ if (!defaultAdapter || !this._adapter)
+ return; // ignore changes while powering up/down
+
+ const hadSetupDevices = this._getDeviceInfos().length > 0;
+
+ if (this._hadSetupDevices === hadSetupDevices)
return;
- this._hadSetupDevices = value;
+ this._hadSetupDevices = hadSetupDevices;
global.settings.set_boolean(
HAD_BLUETOOTH_DEVICES_SETUP, this._hadSetupDevices);
}
@@ -150,6 +152,7 @@ class Indicator extends PanelMenu.SystemIndicator {
this._indicator.visible = nConnectedDevices > 0;
const adapterPowered = this._client.default_adapter_powered;
+ this._syncHadSetupDevices();
// Remember if there were setup devices and show the menu
// if we've seen setup devices and we're not hard blocked
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]