volume: Add smooth scrolling support to adjust output volume
https://bugzilla.gnome.org/show_bug.cgi?id=687573
This commit is contained in:
parent
8ebbf442cd
commit
871ae3f9b2
@ -66,24 +66,32 @@ const VolumeMenu = new Lang.Class({
|
|||||||
this._onControlStateChanged();
|
this._onControlStateChanged();
|
||||||
},
|
},
|
||||||
|
|
||||||
scroll: function(direction) {
|
scroll: function(event) {
|
||||||
|
let direction = event.get_scroll_direction();
|
||||||
let currentVolume = this._output.volume;
|
let currentVolume = this._output.volume;
|
||||||
|
let delta;
|
||||||
|
|
||||||
|
if (event.is_pointer_emulated())
|
||||||
|
return;
|
||||||
|
|
||||||
if (direction == Clutter.ScrollDirection.DOWN) {
|
if (direction == Clutter.ScrollDirection.DOWN) {
|
||||||
let prev_muted = this._output.is_muted;
|
delta = -VOLUME_ADJUSTMENT_STEP;
|
||||||
this._output.volume = Math.max(0, currentVolume - this._volumeMax * VOLUME_ADJUSTMENT_STEP);
|
} else if (direction == Clutter.ScrollDirection.UP) {
|
||||||
if (this._output.volume < 1) {
|
delta = +VOLUME_ADJUSTMENT_STEP;
|
||||||
this._output.volume = 0;
|
} else if (direction == Clutter.ScrollDirection.SMOOTH) {
|
||||||
if (!prev_muted)
|
let [dx, dy] = event.get_scroll_delta();
|
||||||
this._output.change_is_muted(true);
|
// Use the same math as in the slider.
|
||||||
}
|
delta = -dy / 10;
|
||||||
this._output.push_volume();
|
|
||||||
}
|
}
|
||||||
else if (direction == Clutter.ScrollDirection.UP) {
|
|
||||||
this._output.volume = Math.min(this._volumeMax, currentVolume + this._volumeMax * VOLUME_ADJUSTMENT_STEP);
|
let prev_muted = this._output.is_muted;
|
||||||
this._output.change_is_muted(false);
|
this._output.volume = Math.max(0, currentVolume + this._volumeMax * delta);
|
||||||
this._output.push_volume();
|
if (this._output.volume < 1) {
|
||||||
|
this._output.volume = 0;
|
||||||
|
if (!prev_muted)
|
||||||
|
this._output.change_is_muted(true);
|
||||||
}
|
}
|
||||||
|
this._output.push_volume();
|
||||||
|
|
||||||
this._notifyVolumeChange();
|
this._notifyVolumeChange();
|
||||||
},
|
},
|
||||||
@ -242,6 +250,6 @@ const Indicator = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onScrollEvent: function(actor, event) {
|
_onScrollEvent: function(actor, event) {
|
||||||
this._volumeMenu.scroll(event.get_scroll_direction());
|
this._volumeMenu.scroll(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user