bluetooth: Do not update hadSetupDevices on adapter changes
While we now deal more gracefully with adapter removals, we can still mess up the hadSetupDevices tracking: As adapters become available before any devices, we'll always reset the setting to false when Bluetooth is turned on. And if no set up device happens to be in range, it will still be false when Bluetooth is turned off again. To address that, only update the setting if we have an adapter (like we do now) and we had one before (so it wasn't the adapter itself that changed). https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1174
This commit is contained in:
parent
456ca3d3e0
commit
21de88c3ba
@ -50,6 +50,7 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
this.menu.addMenuItem(this._item);
|
this.menu.addMenuItem(this._item);
|
||||||
|
|
||||||
this._syncId = 0;
|
this._syncId = 0;
|
||||||
|
this._adapter = null;
|
||||||
|
|
||||||
this._client = new GnomeBluetooth.Client();
|
this._client = new GnomeBluetooth.Client();
|
||||||
this._model = this._client.get_model();
|
this._model = this._client.get_model();
|
||||||
@ -60,6 +61,15 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
this._sync();
|
this._sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setHadSetupDevices(value) {
|
||||||
|
if (this._hadSetupDevices === value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._hadSetupDevices = value;
|
||||||
|
global.settings.set_boolean(
|
||||||
|
HAD_BLUETOOTH_DEVICES_SETUP, this._hadSetupDevices);
|
||||||
|
}
|
||||||
|
|
||||||
_getDefaultAdapter() {
|
_getDefaultAdapter() {
|
||||||
let [ret, iter] = this._model.get_iter_first();
|
let [ret, iter] = this._model.get_iter_first();
|
||||||
while (ret) {
|
while (ret) {
|
||||||
@ -98,11 +108,6 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
ret = this._model.iter_next(iter);
|
ret = this._model.iter_next(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._hadSetupDevices !== (deviceInfos.length > 0)) {
|
|
||||||
this._hadSetupDevices = !this._hadSetupDevices;
|
|
||||||
global.settings.set_boolean(HAD_BLUETOOTH_DEVICES_SETUP, this._hadSetupDevices);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deviceInfos;
|
return deviceInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +127,10 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
const connectedDevices = devices.filter(dev => dev.connected);
|
const connectedDevices = devices.filter(dev => dev.connected);
|
||||||
const nConnectedDevices = connectedDevices.length;
|
const nConnectedDevices = connectedDevices.length;
|
||||||
|
|
||||||
|
if (adapter && this._adapter)
|
||||||
|
this._setHadSetupDevices(devices.length > 0);
|
||||||
|
this._adapter = adapter;
|
||||||
|
|
||||||
let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
|
let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
|
||||||
|
|
||||||
this.menu.setSensitive(sensitive);
|
this.menu.setSensitive(sensitive);
|
||||||
|
Loading…
Reference in New Issue
Block a user