From 27600ffd371debd7f05e697c028f9005cbf406ff Mon Sep 17 00:00:00 2001 From: mx Date: Tue, 13 Oct 2026 15:56:23 +0200 Subject: [PATCH] Handle the picker's mouse wheel on the tiles The ListView's WheelHandler never fired: the tiles' MouseAreas receive wheel events first. Co-Authored-By: Claude Opus 5.5 --- quickshell/wallpaper/WallpaperPicker.qml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/quickshell/wallpaper/WallpaperPicker.qml b/quickshell/wallpaper/WallpaperPicker.qml index 44c566f..bb68deb 100644 --- a/quickshell/wallpaper/WallpaperPicker.qml +++ b/quickshell/wallpaper/WallpaperPicker.qml @@ -29,6 +29,16 @@ PanelWindow { Component.onDestruction:ShellState.wallpaperWindow=null property string filter:"all" readonly property var results:WallpaperService.images.filter(i=>(filter!=="history" || ConfigService.data.wallpaper.history.includes(i.path)) && (!search.text || i.name.toLowerCase().includes(search.text.toLowerCase()))) + // A vertical mouse wheel steps through the horizontal strip, one tile per notch. + // Handled on the tiles: their MouseAreas take wheel events before the ListView. + property real wheelPending:0 + function wheelStep(event) { + wheelPending+=event.angleDelta.y || event.angleDelta.x; + const steps=Math.trunc(wheelPending/120); + if(!steps)return; + wheelPending-=steps*120; + view.currentIndex=Math.max(0,Math.min(view.count-1,view.currentIndex-steps)); + } function applyCurrent() {if(root.results[view.currentIndex])WallpaperService.apply(root.results[view.currentIndex].path);} Connections { target:ShellState @@ -91,18 +101,6 @@ PanelWindow { Keys.onReturnPressed:root.applyCurrent() Keys.onEnterPressed:root.applyCurrent() Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false - // A vertical mouse wheel steps through the horizontal strip, one tile per notch. - WheelHandler { - property real pending:0 - acceptedDevices:PointerDevice.Mouse - onWheel:event=>{ - pending+=event.angleDelta.y || event.angleDelta.x; - const steps=Math.trunc(pending/120); - if(!steps)return; - pending-=steps*120; - view.currentIndex=Math.max(0,Math.min(view.count-1,view.currentIndex-steps)); - } - } delegate:GlassPanel { id:tile required property var modelData @@ -115,7 +113,7 @@ PanelWindow { Rectangle {anchors.bottom:parent.bottom;anchors.left:parent.left;anchors.right:parent.right;anchors.margins:6;height:42;color:Qt.alpha(Theme.surface,0.85) Text {anchors.fill:parent;anchors.margins:10;text:(WallpaperService.currentPath===tile.modelData.path?"✓ ":"")+tile.modelData.name;color:Theme.text;elide:Text.ElideMiddle} } - MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();WallpaperService.apply(tile.modelData.path);}} + MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();WallpaperService.apply(tile.modelData.path);}onWheel:event=>root.wheelStep(event)} } } Text {visible:!root.results.length;text:WallpaperService.scanning ? "Loading wallpapers…" : "No wallpapers here. Choose a folder in Wallpaper settings.";color:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}