mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat(bar): improve volume scroll handling on bar with smooth accumulation
This commit is contained in:
+22
-13
@@ -442,7 +442,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll on empty bar area to switch workspaces
|
||||
// Scroll on empty bar area action
|
||||
WheelHandler {
|
||||
id: barWheelHandler
|
||||
target: bar
|
||||
@@ -450,8 +450,6 @@ Item {
|
||||
enabled: bar.barWheelAction !== "none"
|
||||
|
||||
onWheel: function (event) {
|
||||
if (bar.barWheelCooldown)
|
||||
return;
|
||||
if (bar.isPointOverWidget(event.x, event.y))
|
||||
return;
|
||||
|
||||
@@ -459,9 +457,29 @@ Item {
|
||||
var dx = event.angleDelta.x;
|
||||
var useDy = Math.abs(dy) >= Math.abs(dx);
|
||||
var delta = useDy ? dy : dx;
|
||||
var step = 120;
|
||||
|
||||
if (bar.barWheelAction === "volume") {
|
||||
if (Settings.data.bar.reverseScroll)
|
||||
delta *= -1;
|
||||
|
||||
bar.barWheelAccumulatedDelta += delta;
|
||||
if (bar.barWheelAccumulatedDelta >= step) {
|
||||
AudioService.increaseVolume();
|
||||
bar.barWheelAccumulatedDelta = 0;
|
||||
event.accepted = true;
|
||||
} else if (bar.barWheelAccumulatedDelta <= -step) {
|
||||
AudioService.decreaseVolume();
|
||||
bar.barWheelAccumulatedDelta = 0;
|
||||
event.accepted = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (bar.barWheelCooldown)
|
||||
return;
|
||||
|
||||
bar.barWheelAccumulatedDelta += delta;
|
||||
var step = 120;
|
||||
if (Math.abs(bar.barWheelAccumulatedDelta) >= step) {
|
||||
var direction = bar.barWheelAccumulatedDelta > 0 ? -1 : 1;
|
||||
if (Settings.data.bar.reverseScroll)
|
||||
@@ -470,15 +488,6 @@ Item {
|
||||
bar.switchWorkspaceByOffset(direction);
|
||||
} else if (bar.barWheelAction === "content") {
|
||||
CompositorService.scrollWorkspaceContent(direction);
|
||||
} else if (bar.barWheelAction === "volume") {
|
||||
var volumeDirection = bar.barWheelAccumulatedDelta > 0 ? 1 : -1;
|
||||
if (Settings.data.bar.reverseScroll)
|
||||
volumeDirection *= -1;
|
||||
if (volumeDirection > 0) {
|
||||
AudioService.increaseVolume();
|
||||
} else {
|
||||
AudioService.decreaseVolume();
|
||||
}
|
||||
}
|
||||
bar.barWheelCooldown = true;
|
||||
barWheelDebounce.restart();
|
||||
|
||||
Reference in New Issue
Block a user