1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

Add Workspace Indicator scrolling (#475)

This commit is contained in:
maggster165
2025-10-17 14:37:28 +02:00
committed by GitHub
parent b095fb9005
commit 3cdc1a9c81
3 changed files with 94 additions and 4 deletions

View File

@@ -15,6 +15,9 @@ Rectangle {
property string screenName: ""
property real widgetHeight: 30
property real barThickness: 48
readonly property var sortedToplevels: {
return CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, parentScreen?.name);
}
property int currentWorkspace: {
if (CompositorService.isNiri) {
return getNiriActiveWorkspace()
@@ -252,14 +255,84 @@ Rectangle {
const direction = deltaY < 0 ? 1 : -1
if (isMouseWheel) {
switchWorkspace(direction)
if (!SettingsData.workspaceScrolling) {
switchWorkspace(direction)
}
else {
const windows = root.sortedToplevels;
if (windows.length < 2) {
return;
}
let currentIndex = -1;
for (let i = 0; i < windows.length; i++) {
if (windows[i].activated) {
currentIndex = i;
break;
}
}
let nextIndex;
if (deltaY < 0) {
if (currentIndex === -1) {
nextIndex = 0;
} else {
nextIndex = currentIndex +1;
}
} else {
if (currentIndex === -1) {
nextIndex = windows.length -1;
} else {
nextIndex = currentIndex - 1
}
}
const nextWindow = windows[nextIndex];
if (nextWindow) {
nextWindow.activate();
}
}
} else {
scrollAccumulator += deltaY
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
const touchDirection = scrollAccumulator < 0 ? 1 : -1
switchWorkspace(touchDirection)
scrollAccumulator = 0
if (!SettingsData.workspaceScrolling) {
switchWorkspace(touchDirection)
}
else {
const windows = root.sortedToplevels;
if (windows.length < 2) {
return;
}
let currentIndex = -1;
for (let i = 0; i < windows.length; i++) {
if (windows[i].activated) {
currentIndex = i;
break;
}
}
let nextIndex;
if (deltaY < 0) {
if (currentIndex === -1) {
nextIndex = 0;
} else {
nextIndex = currentIndex +1;
}
} else {
if (currentIndex === -1) {
nextIndex = windows.length -1;
} else {
nextIndex = currentIndex - 1
}
}
const nextWindow = windows[nextIndex];
if (nextWindow) {
nextWindow.activate();
}
}
scrollAccumulator = 0
}
}

View File

@@ -65,6 +65,15 @@ Item {
checked)
}
}
DankToggle {
width: parent.width
text: I18n.tr("Window Scrolling")
description: "Scroll through windows, rather than workspaces"
checked: SettingsData.workspaceScrolling
onToggled: checked => {
return SettingsData.setWorkspaceScrolling(checked)
}
}
DankToggle {
width: parent.width