[gnome-shell/wip/fmuellner/volume-change-feedback: 57/59] volume: Add back sound feedback on scroll



commit c493fe25a35311d7c72ec2386e1590db5755ff5d
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 23 23:58:22 2018 +0100

    volume: Add back sound feedback on scroll
    
    Commit 8d4855f1008 accidentally removed the volume change feedback
    for scroll events. Add it back to be consistent again with moving
    the slider via arrow keys, slider drags/clicks and gsd's media keys
    handling.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/53

 js/ui/status/volume.js | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index d814ef665..08fb1ccae 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -4,6 +4,7 @@ const Clutter = imports.gi.Clutter;
 const Lang = imports.lang;
 const Gio = imports.gi.Gio;
 const Gvc = imports.gi.Gvc;
+const Mainloop = imports.mainloop;
 const St = imports.gi.St;
 const Signals = imports.signals;
 
@@ -35,9 +36,16 @@ var StreamSlider = new Lang.Class({
 
         this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
 
+        this._inDrag = false;
+        this._notifyVolumeChangeId = 0;
+
         this._slider = new Slider.Slider(0);
+        this._slider.connect('drag-begin', () => { this._inDrag = true; });
         this._slider.connect('value-changed', this._sliderChanged.bind(this));
-        this._slider.connect('drag-end', this._notifyVolumeChange.bind(this));
+        this._slider.connect('drag-end', () => {
+            this._inDrag = false;
+            this._notifyVolumeChange();
+        });
 
         this._icon = new St.Icon({ style_class: 'popup-menu-icon' });
         this.item.actor.add(this._icon);
@@ -119,6 +127,13 @@ var StreamSlider = new Lang.Class({
                 this._stream.change_is_muted(false);
         }
         this._stream.push_volume();
+
+        if (!this._notifyVolumeChangeId && !this._inDrag)
+            this._notifyVolumeChangeId = Mainloop.timeout_add(30, () => {
+                this._notifyVolumeChange();
+                this._notifyVolumeChangeId = 0;
+                return GLib.SOURCE_REMOVE;
+            });
     },
 
     _notifyVolumeChange() {


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