mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 16:02:51 -05:00
dankbar: cooldown timer on scrolling workspaces
This commit is contained in:
@@ -798,8 +798,20 @@ Item {
|
|||||||
|
|
||||||
property real scrollAccumulator: 0
|
property real scrollAccumulator: 0
|
||||||
property real touchpadThreshold: 500
|
property real touchpadThreshold: 500
|
||||||
|
property bool actionInProgress: false
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: cooldownTimer
|
||||||
|
interval: 100
|
||||||
|
onTriggered: parent.actionInProgress = false
|
||||||
|
}
|
||||||
|
|
||||||
onWheel: wheel => {
|
onWheel: wheel => {
|
||||||
|
if (actionInProgress) {
|
||||||
|
wheel.accepted = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const deltaY = wheel.angleDelta.y
|
const deltaY = wheel.angleDelta.y
|
||||||
const deltaX = wheel.angleDelta.x
|
const deltaX = wheel.angleDelta.x
|
||||||
|
|
||||||
@@ -813,22 +825,18 @@ Item {
|
|||||||
const direction = deltaY < 0 ? 1 : -1
|
const direction = deltaY < 0 ? 1 : -1
|
||||||
|
|
||||||
if (isMouseWheel) {
|
if (isMouseWheel) {
|
||||||
if (!SettingsData.workspaceScrolling || !CompositorService.isNiri) {
|
topBarContent.switchWorkspace(direction)
|
||||||
topBarContent.switchWorkspace(direction)
|
actionInProgress = true
|
||||||
} else {
|
cooldownTimer.restart()
|
||||||
topBarContent.switchApp(deltaY)
|
|
||||||
}
|
|
||||||
} 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
|
||||||
if (!SettingsData.workspaceScrolling || !CompositorService.isNiri) {
|
topBarContent.switchWorkspace(touchDirection)
|
||||||
topBarContent.switchWorkspace(touchDirection)
|
|
||||||
} else {
|
|
||||||
topBarContent.switchApp(deltaY)
|
|
||||||
}
|
|
||||||
scrollAccumulator = 0
|
scrollAccumulator = 0
|
||||||
|
actionInProgress = true
|
||||||
|
cooldownTimer.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -280,104 +280,11 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.RightButton
|
acceptedButtons: Qt.RightButton
|
||||||
|
|
||||||
property real scrollAccumulator: 0
|
|
||||||
property real touchpadThreshold: 500
|
|
||||||
|
|
||||||
onClicked: mouse => {
|
onClicked: mouse => {
|
||||||
if (mouse.button === Qt.RightButton && CompositorService.isHyprland && root.hyprlandOverviewLoader?.item) {
|
if (mouse.button === Qt.RightButton && CompositorService.isHyprland && root.hyprlandOverviewLoader?.item) {
|
||||||
root.hyprlandOverviewLoader.item.overviewOpen = !root.hyprlandOverviewLoader.item.overviewOpen
|
root.hyprlandOverviewLoader.item.overviewOpen = !root.hyprlandOverviewLoader.item.overviewOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onWheel: wheel => {
|
|
||||||
const deltaY = wheel.angleDelta.y
|
|
||||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
|
|
||||||
const direction = deltaY < 0 ? 1 : -1
|
|
||||||
|
|
||||||
if (isMouseWheel) {
|
|
||||||
if (!SettingsData.workspaceScrolling || !CompositorService.isNiri) {
|
|
||||||
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
|
|
||||||
if (!SettingsData.workspaceScrolling || !CompositorService.isNiri) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wheel.accepted = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
|
|||||||
@@ -65,17 +65,6 @@ Item {
|
|||||||
checked)
|
checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DankToggle {
|
|
||||||
width: parent.width
|
|
||||||
text: I18n.tr("Window Scrolling")
|
|
||||||
description: I18n.tr("Scroll through windows, rather than workspaces")
|
|
||||||
checked: SettingsData.workspaceScrolling
|
|
||||||
visible: CompositorService.isNiri
|
|
||||||
onToggled: checked => {
|
|
||||||
return SettingsData.setWorkspaceScrolling(checked)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DankToggle {
|
DankToggle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: I18n.tr("Workspace Padding")
|
text: I18n.tr("Workspace Padding")
|
||||||
|
|||||||
Reference in New Issue
Block a user