[gnome-shell/wip/laney/volume-slider-ignore-own-changes] volume: Ignore slider changes we initiated ourselves



commit fda6d301bfef9eb731aea555cf74ef1db861bb2d
Author: Iain Lane <iainl gnome org>
Date:   Thu Sep 5 10:45:37 2019 +0100

    volume: Ignore slider changes we initiated ourselves
    
    Commit 21e14bd46f9774e6c0146cb2169d938e782dba3c fixed this for the
    brightness slider, but we have the same problem for volume too. When the
    volume is muted - for example in Settings or via a media key, we update
    the slider to '0' to indicate this visually. But we also actually invoke
    the slider's callback to *set* the volume to zero. That means that the
    previous level is overwritten so it can't be restored when unmuting.
    
    The fix is the same - when we update the slider internally ourselves,
    don't call the signal handler.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/703

 js/ui/status/volume.js | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index 470e1f7b44..7d9c4ecadc 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported Indicator */
 
-const { Clutter, Gio, Gvc, St } = imports.gi;
+const { Clutter, Gio, GObject, Gvc, St } = imports.gi;
 const Signals = imports.signals;
 
 const Main = imports.ui.main;
@@ -36,7 +36,8 @@ var StreamSlider = class {
         this._soundSettings.connect(`changed::${ALLOW_AMPLIFIED_VOLUME_KEY}`, 
this._amplifySettingsChanged.bind(this));
         this._amplifySettingsChanged();
 
-        this._slider.connect('notify::value', this._sliderChanged.bind(this));
+        this._sliderChangedId = this._slider.connect('notify::value',
+                                                     this._sliderChanged.bind(this));
         this._slider.connect('drag-end', this._notifyVolumeChange.bind(this));
 
         this._icon = new St.Icon({ style_class: 'popup-menu-icon' });
@@ -129,10 +130,16 @@ var StreamSlider = class {
                                this._volumeCancellable);
     }
 
+    _changeSlider(value) {
+        GObject.signal_handler_block(this._slider, this._sliderChangedId);
+        this._slider.value = value;
+        GObject.signal_handler_unblock(this._slider, this._sliderChangedId);
+    }
+
     _updateVolume() {
         let muted = this._stream.is_muted;
-        this._slider.value = muted
-            ? 0 : (this._stream.volume / this._control.get_vol_max_norm());
+        this._changeSlider (muted
+            ? 0 : (this._stream.volume / this._control.get_vol_max_norm()));
         this.emit('stream-updated');
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]