mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
status/backlight: Fix keyboard backlight infinite loop
The logic could enter an infinite loop because it tried to propagate local changes to g-s-d that were caused by signals sent by g-s-d. For example: 1. slider is set to 50 2. Set(50) dbus call is sent 3. slider is set to 51 4. Set(51) dbus call is sent 5. PropertiesChanged arrives due to Set(50) 6. this._sliderItem.value is set to 50 7. notify::value is emitted from this._sliderItem 8. Set(50) dbus call is sent 9. PropertiesChanged arrives due to Set(51) 10. this._sliderItem.value is set to 51 11. notify::value is emitted from this._sliderItem 12. Set(51) dbus call is sent To alleviate this issue, block signal handlers when the local state is changed due to a remote event. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7111 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3086>
This commit is contained in:
parent
f2e51cb722
commit
be944ff2dc
1 changed files with 8 additions and 2 deletions
|
|
@ -177,10 +177,10 @@ class KeyboardBrightnessToggle extends QuickMenuToggle {
|
|||
this._discreteItem, 'value',
|
||||
GObject.BindingFlags.SYNC_CREATE);
|
||||
|
||||
this._sliderItem.connect('notify::value',
|
||||
this._sliderItemChangedId = this._sliderItem.connect('notify::value',
|
||||
() => (this._proxy.Brightness = this._sliderItem.value));
|
||||
|
||||
this._discreteItem.connect('notify::value',
|
||||
this._discreteItemChangedId = this._discreteItem.connect('notify::value',
|
||||
() => (this._proxy.Brightness = this._discreteItem.value));
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +194,9 @@ class KeyboardBrightnessToggle extends QuickMenuToggle {
|
|||
this.checked = brightness > 0;
|
||||
const useSlider = this._proxy.Steps >= 4;
|
||||
|
||||
this._sliderItem.block_signal_handler(this._sliderItemChangedId);
|
||||
this._discreteItem.block_signal_handler(this._discreteItemChangedId);
|
||||
|
||||
this._sliderItem.set({
|
||||
visible: useSlider,
|
||||
value: brightness,
|
||||
|
|
@ -201,6 +204,9 @@ class KeyboardBrightnessToggle extends QuickMenuToggle {
|
|||
|
||||
if (!useSlider)
|
||||
this._discreteItem.nLevels = this._proxy.Steps;
|
||||
|
||||
this._sliderItem.unblock_signal_handler(this._sliderItemChangedId);
|
||||
this._discreteItem.unblock_signal_handler(this._discreteItemChangedId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue