From 3cdc1a9c817b03bc7b5ed4e0ecc3389f407ec06f Mon Sep 17 00:00:00 2001 From: maggster165 <69034405+maggster165@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:37:28 +0200 Subject: [PATCH] Add Workspace Indicator scrolling (#475) --- Common/SettingsData.qml | 10 ++- Modules/DankBar/Widgets/WorkspaceSwitcher.qml | 79 ++++++++++++++++++- Modules/Settings/WidgetTweaksTab.qml | 9 +++ 3 files changed, 94 insertions(+), 4 deletions(-) diff --git a/Common/SettingsData.qml b/Common/SettingsData.qml index 4c13db4d..f7c1d872 100644 --- a/Common/SettingsData.qml +++ b/Common/SettingsData.qml @@ -99,6 +99,7 @@ Singleton { property bool showWorkspaceIndex: false property bool showWorkspacePadding: false + property bool workspaceScrolling: false property bool showWorkspaceApps: false property int maxWorkspaceIcons: 3 property bool workspacesPerMonitor: true @@ -362,6 +363,7 @@ Singleton { ] showWorkspaceIndex = settings.showWorkspaceIndex !== undefined ? settings.showWorkspaceIndex : false showWorkspacePadding = settings.showWorkspacePadding !== undefined ? settings.showWorkspacePadding : false + workspaceScrolling = settings.workspaceScrolling !== undefined ? settings.workspaceScrolling : false showWorkspaceApps = settings.showWorkspaceApps !== undefined ? settings.showWorkspaceApps : false maxWorkspaceIcons = settings.maxWorkspaceIcons !== undefined ? settings.maxWorkspaceIcons : 3 workspaceNameIcons = settings.workspaceNameIcons !== undefined ? settings.workspaceNameIcons : ({}) @@ -563,6 +565,7 @@ Singleton { "controlCenterShowAudioIcon": controlCenterShowAudioIcon, "controlCenterWidgets": controlCenterWidgets, "showWorkspaceIndex": showWorkspaceIndex, + "workspaceScrolling": workspaceScrolling, "showWorkspacePadding": showWorkspacePadding, "showWorkspaceApps": showWorkspaceApps, "maxWorkspaceIcons": maxWorkspaceIcons, @@ -695,7 +698,7 @@ Singleton { "selectedGpuIndex", "enabledGpuPciIds", "showSystemTray", "showClock", "showNotificationButton", "showBattery", "showControlCenterButton", "controlCenterShowNetworkIcon", "controlCenterShowBluetoothIcon", "controlCenterShowAudioIcon", - "controlCenterWidgets", "showWorkspaceIndex", "showWorkspacePadding", "showWorkspaceApps", + "controlCenterWidgets", "showWorkspaceIndex", "workspaceScrolling", "showWorkspacePadding", "showWorkspaceApps", "maxWorkspaceIcons", "workspacesPerMonitor", "workspaceNameIcons", "waveProgressEnabled", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "runningAppsCurrentWorkspace", "clockDateFormat", "lockDateFormat", "mediaSize", @@ -1158,6 +1161,11 @@ Singleton { showWorkspaceIndex = enabled saveSettings() } + + function setWorkspaceScrolling(enabled) { + workspaceScrolling = enabled + saveSettings() + } function setShowWorkspacePadding(enabled) { showWorkspacePadding = enabled diff --git a/Modules/DankBar/Widgets/WorkspaceSwitcher.qml b/Modules/DankBar/Widgets/WorkspaceSwitcher.qml index 23d96d38..6f87b923 100644 --- a/Modules/DankBar/Widgets/WorkspaceSwitcher.qml +++ b/Modules/DankBar/Widgets/WorkspaceSwitcher.qml @@ -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 } } diff --git a/Modules/Settings/WidgetTweaksTab.qml b/Modules/Settings/WidgetTweaksTab.qml index b89e3b40..3def64c7 100644 --- a/Modules/Settings/WidgetTweaksTab.qml +++ b/Modules/Settings/WidgetTweaksTab.qml @@ -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