status/backlight: Do only one dbus call per local change

The values of the two control widgets are syncronized, meaning
that both emit signals when the local value changes, regardless
which one is visible and is actually used by the user.

This is not ideal because it leads to two dbus calls
per local change. To alleviate this, only consider
changes from the widget that is visible.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3086>
This commit is contained in:
Barnabás Pőcze 2024-01-16 23:41:24 +01:00 committed by Marge Bot
parent be944ff2dc
commit c227d0b38e

View File

@ -177,11 +177,15 @@ class KeyboardBrightnessToggle extends QuickMenuToggle {
this._discreteItem, 'value',
GObject.BindingFlags.SYNC_CREATE);
this._sliderItemChangedId = this._sliderItem.connect('notify::value',
() => (this._proxy.Brightness = this._sliderItem.value));
this._sliderItemChangedId = this._sliderItem.connect('notify::value', () => {
if (this._sliderItem.visible)
this._proxy.Brightness = this._sliderItem.value;
});
this._discreteItemChangedId = this._discreteItem.connect('notify::value',
() => (this._proxy.Brightness = this._discreteItem.value));
this._discreteItemChangedId = this._discreteItem.connect('notify::value', () => {
if (this._discreteItem.visible)
this._proxy.Brightness = this._discreteItem.value;
});
}
_sync() {