feat(bar-scroll-actions): implement Niri content scrolling for mouse wheel action

This commit is contained in:
tibssy
2026-02-18 16:55:04 +00:00
parent 41c383d89b
commit 6a16e43298
6 changed files with 25 additions and 16 deletions
-1
View File
@@ -68,7 +68,6 @@
}
]
},
"enableWorkspaceScroll": false,
"mouseWheelAction": "none",
"screenOverrides": []
},
-1
View File
@@ -252,7 +252,6 @@ Singleton {
}
]
}
property bool enableWorkspaceScroll: false
property string mouseWheelAction: "none"
// Per-screen overrides for position and widgets
// Format: [{ "name": "HDMI-1", "position": "left" }, { "name": "DP-1", "position": "bottom", "widgets": {...} }]
+6 -4
View File
@@ -185,9 +185,7 @@ Item {
property int barWheelAccumulatedDelta: 0
property bool barWheelCooldown: false
readonly property string barWheelAction: {
if (Settings.data.bar.mouseWheelAction !== undefined && Settings.data.bar.mouseWheelAction !== "")
return Settings.data.bar.mouseWheelAction;
return Settings.data.bar.enableWorkspaceScroll ? "workspace" : "none";
return Settings.data.bar.mouseWheelAction || "none";
}
// Position and size the bar content based on orientation
@@ -367,7 +365,7 @@ Item {
id: barWheelHandler
target: bar
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
enabled: bar.barWheelAction === "workspace"
enabled: bar.barWheelAction !== "none"
onWheel: function (event) {
if (bar.barWheelCooldown)
@@ -386,7 +384,11 @@ Item {
var direction = bar.barWheelAccumulatedDelta > 0 ? -1 : 1;
if (Settings.data.general.reverseScroll)
direction *= -1;
if (bar.barWheelAction === "workspace") {
bar.switchWorkspaceByOffset(direction);
} else if (bar.barWheelAction === "content") {
CompositorService.scrollWorkspaceContent(direction);
}
bar.barWheelCooldown = true;
barWheelDebounce.restart();
bar.barWheelAccumulatedDelta = 0;
@@ -10,11 +10,7 @@ ColumnLayout {
spacing: Style.marginL
Layout.fillWidth: true
readonly property string effectiveWheelAction: {
if (Settings.data.bar.mouseWheelAction !== undefined && Settings.data.bar.mouseWheelAction !== "")
return Settings.data.bar.mouseWheelAction;
return Settings.data.bar.enableWorkspaceScroll ? "workspace" : "none";
}
readonly property string effectiveWheelAction: Settings.data.bar.mouseWheelAction || "none"
NComboBox {
Layout.fillWidth: true
@@ -41,9 +37,6 @@ ColumnLayout {
}
currentKey: root.effectiveWheelAction
defaultValue: Settings.getDefaultValue("bar.mouseWheelAction")
onSelected: key => {
Settings.data.bar.mouseWheelAction = key;
Settings.data.bar.enableWorkspaceScroll = (key === "workspace");
}
onSelected: key => Settings.data.bar.mouseWheelAction = key
}
}
@@ -375,6 +375,13 @@ Singleton {
}
}
// Scrollable workspace content (Niri)
function scrollWorkspaceContent(direction) {
if (backend && backend.scrollWorkspaceContent) {
backend.scrollWorkspaceContent(direction);
}
}
// Get current workspace
function getCurrentWorkspace() {
for (var i = 0; i < workspaces.count; i++) {
+9
View File
@@ -456,6 +456,15 @@ Item {
}
}
function scrollWorkspaceContent(direction) {
try {
var action = direction < 0 ? "focus-column-left" : "focus-column-right";
Quickshell.execDetached(["niri", "msg", "action", action]);
} catch (e) {
Logger.e("NiriService", "Failed to scroll workspace content:", e);
}
}
function focusWindow(window) {
try {
Quickshell.execDetached(["niri", "msg", "action", "focus-window", "--id", window.id.toString()]);