From c227d0b38e69e4e9d628264a6e8644bd148d7061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Tue, 16 Jan 2024 23:41:24 +0100 Subject: [PATCH] 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: --- js/ui/status/backlight.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/ui/status/backlight.js b/js/ui/status/backlight.js index ca901d547..686ed3361 100644 --- a/js/ui/status/backlight.js +++ b/js/ui/status/backlight.js @@ -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() {