mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-31 08:52:49 -05:00
feat: Add mouse wheel support for app/workspace switching (#143)
This commit is contained in:
@@ -51,6 +51,46 @@ Rectangle {
|
|||||||
baseColor.a * Theme.widgetTransparency)
|
baseColor.a * Theme.widgetTransparency)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
onWheel: {
|
||||||
|
var windows = root.sortedToplevels;
|
||||||
|
if (windows.length < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentIndex = -1;
|
||||||
|
for (var i = 0; i < windows.length; i++) {
|
||||||
|
if (windows[i].activated) {
|
||||||
|
currentIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var nextIndex;
|
||||||
|
if (wheel.angleDelta.y < 0) {
|
||||||
|
if (currentIndex === -1) {
|
||||||
|
nextIndex = 0;
|
||||||
|
} else {
|
||||||
|
nextIndex = (currentIndex + 1) % windows.length;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (currentIndex === -1) {
|
||||||
|
nextIndex = windows.length - 1;
|
||||||
|
} else {
|
||||||
|
nextIndex = (currentIndex - 1 + windows.length) % windows.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var nextWindow = windows[nextIndex];
|
||||||
|
if (nextWindow) {
|
||||||
|
nextWindow.activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: windowRow
|
id: windowRow
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,48 @@ Rectangle {
|
|||||||
target: SettingsData
|
target: SettingsData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
onWheel: {
|
||||||
|
if (CompositorService.isNiri) {
|
||||||
|
var realWorkspaces = [];
|
||||||
|
for (var i = 0; i < root.workspaceList.length; i++) {
|
||||||
|
if (root.workspaceList[i] !== -1) {
|
||||||
|
realWorkspaces.push(root.workspaceList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (realWorkspaces.length < 2) return;
|
||||||
|
|
||||||
|
var currentIndex = -1;
|
||||||
|
for (var i = 0; i < realWorkspaces.length; i++) {
|
||||||
|
if (realWorkspaces[i] === root.currentWorkspace) {
|
||||||
|
currentIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentIndex === -1) currentIndex = 0;
|
||||||
|
|
||||||
|
var nextIndex;
|
||||||
|
if (wheel.angleDelta.y < 0) {
|
||||||
|
nextIndex = (currentIndex + 1) % realWorkspaces.length;
|
||||||
|
} else {
|
||||||
|
nextIndex = (currentIndex - 1 + realWorkspaces.length) % realWorkspaces.length;
|
||||||
|
}
|
||||||
|
NiriService.switchToWorkspace(realWorkspaces[nextIndex] - 1);
|
||||||
|
|
||||||
|
} else if (CompositorService.isHyprland) {
|
||||||
|
if (wheel.angleDelta.y < 0) {
|
||||||
|
Hyprland.dispatch("workspace r+1");
|
||||||
|
} else {
|
||||||
|
Hyprland.dispatch("workspace r-1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: workspaceRow
|
id: workspaceRow
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user