Skip the provider helper for native rendering (its awww probe alone took ~0.5s per output), write every output in one go, and start each output's reveal together once all have decoded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94 lines
3.6 KiB
QML
94 lines
3.6 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Effects
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import "../services"
|
|
import "../theme"
|
|
// qmllint disable uncreatable-type
|
|
PanelWindow {
|
|
id:root
|
|
required property var modelData
|
|
screen:modelData
|
|
anchors {top:true;bottom:true;left:true;right:true}
|
|
color:Theme.surface
|
|
exclusionMode:ExclusionMode.Ignore
|
|
WlrLayershell.layer:WlrLayer.Background
|
|
WlrLayershell.namespace:"glassMxrph-wallpaper"
|
|
mask:Region {}
|
|
readonly property string target:ConfigService.ready && ConfigService.data.wallpaper.byMonitor[root.modelData.name] ? "file://"+encodeURI(ConfigService.data.wallpaper.byMonitor[root.modelData.name]).replace(/#/g,"%23").replace(/\?/g,"%3F") : ""
|
|
// 0..1 while a new wallpaper grows in from the centre over the old one.
|
|
property real progress:0
|
|
readonly property bool transitioning:incoming.source.toString()!==""
|
|
// The first wallpaper (and reduced motion) appears directly; later changes
|
|
// load into `incoming` and are revealed once decoded.
|
|
onTargetChanged:{
|
|
if(!shown.source.toString() || Theme.duration===0) {reveal.stop();incoming.source="";shown.source=target;}
|
|
else if(target===shown.source.toString()) {reveal.stop();incoming.source="";}
|
|
else {reveal.stop();progress=0;WallpaperService.revealLoading(modelData.name);incoming.source=target;}
|
|
}
|
|
Component.onCompleted:shown.source=target
|
|
function settle() {
|
|
if(!reveal.running && shown.status===Image.Ready && shown.source.toString()===incoming.source.toString())incoming.source="";
|
|
}
|
|
Image {
|
|
id:shown
|
|
anchors.fill:parent
|
|
sourceSize:Qt.size(parent.width,parent.height)
|
|
asynchronous:true
|
|
retainWhileLoading:true
|
|
fillMode:Image.PreserveAspectCrop
|
|
// Drop the overlay only once the base layer shows the new image.
|
|
onStatusChanged:root.settle()
|
|
}
|
|
Item {
|
|
id:revealMask
|
|
anchors.fill:parent
|
|
visible:false
|
|
layer.enabled:root.transitioning
|
|
Rectangle {
|
|
readonly property real reach:Math.hypot(root.width,root.height)*1.15
|
|
anchors.centerIn:parent
|
|
width:reach*root.progress;height:width;radius:width/2
|
|
color:"black"
|
|
}
|
|
}
|
|
// The mask must be the image's own layer effect: a MultiEffect pointed at a
|
|
// hidden source renders nothing here.
|
|
Image {
|
|
id:incoming
|
|
anchors.fill:parent
|
|
visible:root.transitioning && root.progress>0
|
|
sourceSize:Qt.size(parent.width,parent.height)
|
|
asynchronous:true
|
|
fillMode:Image.PreserveAspectCrop
|
|
// Settles from a slight zoom while the circle widens, like swww/awww "grow".
|
|
scale:1.06-0.06*root.progress
|
|
onStatusChanged:{
|
|
if(status===Image.Ready && source.toString())WallpaperService.revealReady(root.modelData.name);
|
|
else if(status===Image.Error)incoming.source="";
|
|
}
|
|
layer.enabled:root.transitioning
|
|
layer.effect:MultiEffect {
|
|
maskEnabled:true
|
|
maskSource:revealMask
|
|
maskThresholdMin:0.5
|
|
maskSpreadAtMin:1
|
|
}
|
|
}
|
|
Connections {
|
|
target:WallpaperService
|
|
function onRevealSerialChanged() {
|
|
if(incoming.status===Image.Ready && incoming.source.toString() && !reveal.running && root.progress===0)reveal.restart();
|
|
}
|
|
}
|
|
NumberAnimation {
|
|
id:reveal
|
|
target:root;property:"progress"
|
|
from:0;to:1
|
|
duration:1100
|
|
easing.type:Easing.InOutCubic
|
|
onFinished:{shown.source=incoming.source;Qt.callLater(root.settle);}
|
|
}
|
|
}
|