mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
Add Workspace Indicator scrolling (#475)
This commit is contained in:
@@ -99,6 +99,7 @@ Singleton {
|
|||||||
|
|
||||||
property bool showWorkspaceIndex: false
|
property bool showWorkspaceIndex: false
|
||||||
property bool showWorkspacePadding: false
|
property bool showWorkspacePadding: false
|
||||||
|
property bool workspaceScrolling: false
|
||||||
property bool showWorkspaceApps: false
|
property bool showWorkspaceApps: false
|
||||||
property int maxWorkspaceIcons: 3
|
property int maxWorkspaceIcons: 3
|
||||||
property bool workspacesPerMonitor: true
|
property bool workspacesPerMonitor: true
|
||||||
@@ -362,6 +363,7 @@ Singleton {
|
|||||||
]
|
]
|
||||||
showWorkspaceIndex = settings.showWorkspaceIndex !== undefined ? settings.showWorkspaceIndex : false
|
showWorkspaceIndex = settings.showWorkspaceIndex !== undefined ? settings.showWorkspaceIndex : false
|
||||||
showWorkspacePadding = settings.showWorkspacePadding !== undefined ? settings.showWorkspacePadding : false
|
showWorkspacePadding = settings.showWorkspacePadding !== undefined ? settings.showWorkspacePadding : false
|
||||||
|
workspaceScrolling = settings.workspaceScrolling !== undefined ? settings.workspaceScrolling : false
|
||||||
showWorkspaceApps = settings.showWorkspaceApps !== undefined ? settings.showWorkspaceApps : false
|
showWorkspaceApps = settings.showWorkspaceApps !== undefined ? settings.showWorkspaceApps : false
|
||||||
maxWorkspaceIcons = settings.maxWorkspaceIcons !== undefined ? settings.maxWorkspaceIcons : 3
|
maxWorkspaceIcons = settings.maxWorkspaceIcons !== undefined ? settings.maxWorkspaceIcons : 3
|
||||||
workspaceNameIcons = settings.workspaceNameIcons !== undefined ? settings.workspaceNameIcons : ({})
|
workspaceNameIcons = settings.workspaceNameIcons !== undefined ? settings.workspaceNameIcons : ({})
|
||||||
@@ -563,6 +565,7 @@ Singleton {
|
|||||||
"controlCenterShowAudioIcon": controlCenterShowAudioIcon,
|
"controlCenterShowAudioIcon": controlCenterShowAudioIcon,
|
||||||
"controlCenterWidgets": controlCenterWidgets,
|
"controlCenterWidgets": controlCenterWidgets,
|
||||||
"showWorkspaceIndex": showWorkspaceIndex,
|
"showWorkspaceIndex": showWorkspaceIndex,
|
||||||
|
"workspaceScrolling": workspaceScrolling,
|
||||||
"showWorkspacePadding": showWorkspacePadding,
|
"showWorkspacePadding": showWorkspacePadding,
|
||||||
"showWorkspaceApps": showWorkspaceApps,
|
"showWorkspaceApps": showWorkspaceApps,
|
||||||
"maxWorkspaceIcons": maxWorkspaceIcons,
|
"maxWorkspaceIcons": maxWorkspaceIcons,
|
||||||
@@ -695,7 +698,7 @@ Singleton {
|
|||||||
"selectedGpuIndex", "enabledGpuPciIds", "showSystemTray", "showClock",
|
"selectedGpuIndex", "enabledGpuPciIds", "showSystemTray", "showClock",
|
||||||
"showNotificationButton", "showBattery", "showControlCenterButton",
|
"showNotificationButton", "showBattery", "showControlCenterButton",
|
||||||
"controlCenterShowNetworkIcon", "controlCenterShowBluetoothIcon", "controlCenterShowAudioIcon",
|
"controlCenterShowNetworkIcon", "controlCenterShowBluetoothIcon", "controlCenterShowAudioIcon",
|
||||||
"controlCenterWidgets", "showWorkspaceIndex", "showWorkspacePadding", "showWorkspaceApps",
|
"controlCenterWidgets", "showWorkspaceIndex", "workspaceScrolling", "showWorkspacePadding", "showWorkspaceApps",
|
||||||
"maxWorkspaceIcons", "workspacesPerMonitor", "workspaceNameIcons", "waveProgressEnabled",
|
"maxWorkspaceIcons", "workspacesPerMonitor", "workspaceNameIcons", "waveProgressEnabled",
|
||||||
"clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode",
|
"clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode",
|
||||||
"runningAppsCurrentWorkspace", "clockDateFormat", "lockDateFormat", "mediaSize",
|
"runningAppsCurrentWorkspace", "clockDateFormat", "lockDateFormat", "mediaSize",
|
||||||
@@ -1158,6 +1161,11 @@ Singleton {
|
|||||||
showWorkspaceIndex = enabled
|
showWorkspaceIndex = enabled
|
||||||
saveSettings()
|
saveSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setWorkspaceScrolling(enabled) {
|
||||||
|
workspaceScrolling = enabled
|
||||||
|
saveSettings()
|
||||||
|
}
|
||||||
|
|
||||||
function setShowWorkspacePadding(enabled) {
|
function setShowWorkspacePadding(enabled) {
|
||||||
showWorkspacePadding = enabled
|
showWorkspacePadding = enabled
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ Rectangle {
|
|||||||
property string screenName: ""
|
property string screenName: ""
|
||||||
property real widgetHeight: 30
|
property real widgetHeight: 30
|
||||||
property real barThickness: 48
|
property real barThickness: 48
|
||||||
|
readonly property var sortedToplevels: {
|
||||||
|
return CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, parentScreen?.name);
|
||||||
|
}
|
||||||
property int currentWorkspace: {
|
property int currentWorkspace: {
|
||||||
if (CompositorService.isNiri) {
|
if (CompositorService.isNiri) {
|
||||||
return getNiriActiveWorkspace()
|
return getNiriActiveWorkspace()
|
||||||
@@ -252,14 +255,84 @@ Rectangle {
|
|||||||
const direction = deltaY < 0 ? 1 : -1
|
const direction = deltaY < 0 ? 1 : -1
|
||||||
|
|
||||||
if (isMouseWheel) {
|
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 {
|
} else {
|
||||||
scrollAccumulator += deltaY
|
scrollAccumulator += deltaY
|
||||||
|
|
||||||
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
|
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
|
||||||
const touchDirection = scrollAccumulator < 0 ? 1 : -1
|
const touchDirection = scrollAccumulator < 0 ? 1 : -1
|
||||||
switchWorkspace(touchDirection)
|
if (!SettingsData.workspaceScrolling) {
|
||||||
scrollAccumulator = 0
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,15 @@ Item {
|
|||||||
checked)
|
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 {
|
DankToggle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|||||||
Reference in New Issue
Block a user