[gnome-shell/wip/grab-helper-top-panel: 4/20] volume: Add smooth scrolling support to adjust output volume
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/grab-helper-top-panel: 4/20] volume: Add smooth scrolling support to adjust output volume
- Date: Mon, 26 Nov 2012 21:39:43 +0000 (UTC)
commit 871ae3f9b2a198312056a1227d9d6f27a6f5f225
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Nov 4 10:53:23 2012 -0500
volume: Add smooth scrolling support to adjust output volume
https://bugzilla.gnome.org/show_bug.cgi?id=687573
js/ui/status/volume.js | 36 ++++++++++++++++++++++--------------
1 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index 7f91e66..0dcc880 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -66,24 +66,32 @@ const VolumeMenu = new Lang.Class({
this._onControlStateChanged();
},
- scroll: function(direction) {
+ scroll: function(event) {
+ let direction = event.get_scroll_direction();
let currentVolume = this._output.volume;
+ let delta;
+
+ if (event.is_pointer_emulated())
+ return;
if (direction == Clutter.ScrollDirection.DOWN) {
- let prev_muted = this._output.is_muted;
- this._output.volume = Math.max(0, currentVolume - this._volumeMax * VOLUME_ADJUSTMENT_STEP);
- if (this._output.volume < 1) {
- this._output.volume = 0;
- if (!prev_muted)
- this._output.change_is_muted(true);
- }
- this._output.push_volume();
+ delta = -VOLUME_ADJUSTMENT_STEP;
+ } else if (direction == Clutter.ScrollDirection.UP) {
+ delta = +VOLUME_ADJUSTMENT_STEP;
+ } else if (direction == Clutter.ScrollDirection.SMOOTH) {
+ let [dx, dy] = event.get_scroll_delta();
+ // Use the same math as in the slider.
+ delta = -dy / 10;
}
- else if (direction == Clutter.ScrollDirection.UP) {
- this._output.volume = Math.min(this._volumeMax, currentVolume + this._volumeMax * VOLUME_ADJUSTMENT_STEP);
- this._output.change_is_muted(false);
- this._output.push_volume();
+
+ let prev_muted = this._output.is_muted;
+ this._output.volume = Math.max(0, currentVolume + this._volumeMax * delta);
+ if (this._output.volume < 1) {
+ this._output.volume = 0;
+ if (!prev_muted)
+ this._output.change_is_muted(true);
}
+ this._output.push_volume();
this._notifyVolumeChange();
},
@@ -242,6 +250,6 @@ const Indicator = new Lang.Class({
},
_onScrollEvent: function(actor, event) {
- this._volumeMenu.scroll(event.get_scroll_direction());
+ this._volumeMenu.scroll(event);
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]