mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 16:32:50 -05:00
dankbar: add scroll wheel behavior configuration
This commit is contained in:
@@ -396,7 +396,10 @@ Singleton {
|
|||||||
visible: true,
|
visible: true,
|
||||||
popupGapsAuto: true,
|
popupGapsAuto: true,
|
||||||
popupGapsManual: 4,
|
popupGapsManual: 4,
|
||||||
maximizeDetection: true
|
maximizeDetection: true,
|
||||||
|
scrollEnabled: true,
|
||||||
|
scrollXBehavior: "column",
|
||||||
|
scrollYBehavior: "workspace"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,10 @@ var SPEC = {
|
|||||||
visible: true,
|
visible: true,
|
||||||
popupGapsAuto: true,
|
popupGapsAuto: true,
|
||||||
popupGapsManual: 4,
|
popupGapsManual: 4,
|
||||||
maximizeDetection: true
|
maximizeDetection: true,
|
||||||
|
scrollEnabled: true,
|
||||||
|
scrollXBehavior: "column",
|
||||||
|
scrollYBehavior: "workspace"
|
||||||
}], onChange: "updateBarConfigs" }
|
}], onChange: "updateBarConfigs" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -594,7 +594,8 @@ PanelWindow {
|
|||||||
propagateComposedEvents: true
|
propagateComposedEvents: true
|
||||||
z: -1
|
z: -1
|
||||||
|
|
||||||
property real scrollAccumulator: 0
|
property real scrollAccumulatorY: 0
|
||||||
|
property real scrollAccumulatorX: 0
|
||||||
property real touchpadThreshold: 500
|
property real touchpadThreshold: 500
|
||||||
property bool actionInProgress: false
|
property bool actionInProgress: false
|
||||||
|
|
||||||
@@ -604,7 +605,30 @@ PanelWindow {
|
|||||||
onTriggered: parent.actionInProgress = false
|
onTriggered: parent.actionInProgress = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleScrollAction(behavior, direction) {
|
||||||
|
switch (behavior) {
|
||||||
|
case "workspace":
|
||||||
|
topBarContent.switchWorkspace(direction);
|
||||||
|
return true;
|
||||||
|
case "column":
|
||||||
|
if (!CompositorService.isNiri)
|
||||||
|
return false;
|
||||||
|
if (direction > 0)
|
||||||
|
NiriService.moveColumnRight();
|
||||||
|
else
|
||||||
|
NiriService.moveColumnLeft();
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onWheel: wheel => {
|
onWheel: wheel => {
|
||||||
|
if (!(barConfig?.scrollEnabled ?? true)) {
|
||||||
|
wheel.accepted = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (actionInProgress) {
|
if (actionInProgress) {
|
||||||
wheel.accepted = false;
|
wheel.accepted = false;
|
||||||
return;
|
return;
|
||||||
@@ -612,9 +636,34 @@ PanelWindow {
|
|||||||
|
|
||||||
const deltaY = wheel.angleDelta.y;
|
const deltaY = wheel.angleDelta.y;
|
||||||
const deltaX = wheel.angleDelta.x;
|
const deltaX = wheel.angleDelta.x;
|
||||||
|
const xBehavior = barConfig?.scrollXBehavior ?? "column";
|
||||||
|
const yBehavior = barConfig?.scrollYBehavior ?? "workspace";
|
||||||
|
|
||||||
if (CompositorService.isNiri && Math.abs(deltaX) > Math.abs(deltaY)) {
|
if (CompositorService.isNiri && xBehavior !== "none" && Math.abs(deltaX) > Math.abs(deltaY)) {
|
||||||
topBarContent.switchApp(deltaX);
|
const isMouseWheel = Math.abs(deltaX) >= 120 && (Math.abs(deltaX) % 120) === 0;
|
||||||
|
const direction = deltaX < 0 ? 1 : -1;
|
||||||
|
|
||||||
|
if (isMouseWheel) {
|
||||||
|
if (handleScrollAction(xBehavior, direction)) {
|
||||||
|
actionInProgress = true;
|
||||||
|
cooldownTimer.restart();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scrollAccumulatorX += deltaX;
|
||||||
|
if (Math.abs(scrollAccumulatorX) >= touchpadThreshold) {
|
||||||
|
const touchDirection = scrollAccumulatorX < 0 ? 1 : -1;
|
||||||
|
if (handleScrollAction(xBehavior, touchDirection)) {
|
||||||
|
actionInProgress = true;
|
||||||
|
cooldownTimer.restart();
|
||||||
|
}
|
||||||
|
scrollAccumulatorX = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wheel.accepted = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yBehavior === "none") {
|
||||||
wheel.accepted = false;
|
wheel.accepted = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -623,19 +672,20 @@ PanelWindow {
|
|||||||
const direction = deltaY < 0 ? 1 : -1;
|
const direction = deltaY < 0 ? 1 : -1;
|
||||||
|
|
||||||
if (isMouseWheel) {
|
if (isMouseWheel) {
|
||||||
topBarContent.switchWorkspace(direction);
|
if (handleScrollAction(yBehavior, direction)) {
|
||||||
actionInProgress = true;
|
actionInProgress = true;
|
||||||
cooldownTimer.restart();
|
cooldownTimer.restart();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
scrollAccumulator += deltaY;
|
scrollAccumulatorY += deltaY;
|
||||||
|
if (Math.abs(scrollAccumulatorY) >= touchpadThreshold) {
|
||||||
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
|
const touchDirection = scrollAccumulatorY < 0 ? 1 : -1;
|
||||||
const touchDirection = scrollAccumulator < 0 ? 1 : -1;
|
if (handleScrollAction(yBehavior, touchDirection)) {
|
||||||
topBarContent.switchWorkspace(touchDirection);
|
|
||||||
scrollAccumulator = 0;
|
|
||||||
actionInProgress = true;
|
actionInProgress = true;
|
||||||
cooldownTimer.restart();
|
cooldownTimer.restart();
|
||||||
}
|
}
|
||||||
|
scrollAccumulatorY = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wheel.accepted = false;
|
wheel.accepted = false;
|
||||||
|
|||||||
@@ -237,7 +237,10 @@ Item {
|
|||||||
visible: defaultBar.visible ?? true,
|
visible: defaultBar.visible ?? true,
|
||||||
popupGapsAuto: defaultBar.popupGapsAuto ?? true,
|
popupGapsAuto: defaultBar.popupGapsAuto ?? true,
|
||||||
popupGapsManual: defaultBar.popupGapsManual ?? 4,
|
popupGapsManual: defaultBar.popupGapsManual ?? 4,
|
||||||
maximizeDetection: defaultBar.maximizeDetection ?? true
|
maximizeDetection: defaultBar.maximizeDetection ?? true,
|
||||||
|
scrollEnabled: defaultBar.scrollEnabled ?? true,
|
||||||
|
scrollXBehavior: defaultBar.scrollXBehavior ?? "column",
|
||||||
|
scrollYBehavior: defaultBar.scrollYBehavior ?? "workspace"
|
||||||
};
|
};
|
||||||
SettingsData.addBarConfig(newBar);
|
SettingsData.addBarConfig(newBar);
|
||||||
selectedBarId = newId;
|
selectedBarId = newId;
|
||||||
@@ -751,6 +754,90 @@ Item {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsToggleCard {
|
||||||
|
iconName: "mouse"
|
||||||
|
title: I18n.tr("Scroll Wheel")
|
||||||
|
description: I18n.tr("Control workspaces and columns by scrolling on the bar")
|
||||||
|
visible: selectedBarConfig?.enabled
|
||||||
|
checked: selectedBarConfig?.scrollEnabled ?? true
|
||||||
|
onToggled: checked => SettingsData.updateBarConfig(selectedBarId, {
|
||||||
|
scrollEnabled: checked
|
||||||
|
})
|
||||||
|
|
||||||
|
SettingsButtonGroupRow {
|
||||||
|
text: I18n.tr("Y Axis")
|
||||||
|
model: CompositorService.isNiri ? [I18n.tr("None"), I18n.tr("Workspace"), I18n.tr("Column")] : [I18n.tr("None"), I18n.tr("Workspace")]
|
||||||
|
currentIndex: {
|
||||||
|
switch (selectedBarConfig?.scrollYBehavior || "workspace") {
|
||||||
|
case "none":
|
||||||
|
return 0;
|
||||||
|
case "workspace":
|
||||||
|
return 1;
|
||||||
|
case "column":
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onSelectionChanged: (index, selected) => {
|
||||||
|
if (!selected)
|
||||||
|
return;
|
||||||
|
let behavior = "workspace";
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
behavior = "none";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
behavior = "workspace";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
behavior = "column";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SettingsData.updateBarConfig(selectedBarId, {
|
||||||
|
scrollYBehavior: behavior
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsButtonGroupRow {
|
||||||
|
text: I18n.tr("X Axis")
|
||||||
|
visible: CompositorService.isNiri
|
||||||
|
model: [I18n.tr("None"), I18n.tr("Workspace"), I18n.tr("Column")]
|
||||||
|
currentIndex: {
|
||||||
|
switch (selectedBarConfig?.scrollXBehavior || "column") {
|
||||||
|
case "none":
|
||||||
|
return 0;
|
||||||
|
case "workspace":
|
||||||
|
return 1;
|
||||||
|
case "column":
|
||||||
|
return 2;
|
||||||
|
default:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onSelectionChanged: (index, selected) => {
|
||||||
|
if (!selected)
|
||||||
|
return;
|
||||||
|
let behavior = "column";
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
behavior = "none";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
behavior = "workspace";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
behavior = "column";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SettingsData.updateBarConfig(selectedBarId, {
|
||||||
|
scrollXBehavior: behavior
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SettingsCard {
|
SettingsCard {
|
||||||
iconName: "space_bar"
|
iconName: "space_bar"
|
||||||
title: I18n.tr("Spacing")
|
title: I18n.tr("Spacing")
|
||||||
|
|||||||
Reference in New Issue
Block a user