mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-05 05:12:05 -04:00
wallpaper: handle initial load better, add dms randr command for quick
physical scale retrieval
This commit is contained in:
@@ -85,22 +85,20 @@ Variants {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (typeof blurWallpaperWindow.updatesEnabled !== "undefined")
|
||||
blurWallpaperWindow.updatesEnabled = Qt.binding(() => root.effectActive || root._renderSettling || currentWallpaper.status === Image.Loading || nextWallpaper.status === Image.Loading);
|
||||
|
||||
if (!source) {
|
||||
isInitialized = true;
|
||||
updatesBindingTimer.start();
|
||||
return;
|
||||
root._renderSettling = false;
|
||||
}
|
||||
const formattedSource = source.startsWith("file://") ? source : encodeFileUrl(source);
|
||||
setWallpaperImmediate(formattedSource);
|
||||
isInitialized = true;
|
||||
updatesBindingTimer.start();
|
||||
}
|
||||
|
||||
property bool isInitialized: false
|
||||
property real transitionProgress: 0
|
||||
readonly property bool transitioning: transitionAnimation.running
|
||||
property bool effectActive: false
|
||||
property bool _renderSettling: false
|
||||
property bool _renderSettling: true
|
||||
property bool useNextForEffect: false
|
||||
|
||||
Connections {
|
||||
@@ -119,15 +117,6 @@ Variants {
|
||||
onTriggered: root._renderSettling = false
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: updatesBindingTimer
|
||||
interval: 500
|
||||
onTriggered: {
|
||||
if (typeof blurWallpaperWindow.updatesEnabled !== "undefined")
|
||||
blurWallpaperWindow.updatesEnabled = Qt.binding(() => root.effectActive || root._renderSettling || currentWallpaper.status === Image.Loading || nextWallpaper.status === Image.Loading);
|
||||
}
|
||||
}
|
||||
|
||||
onSourceChanged: {
|
||||
if (!source || source.startsWith("#")) {
|
||||
setWallpaperImmediate("");
|
||||
|
||||
@@ -83,9 +83,10 @@ Variants {
|
||||
|
||||
readonly property bool transitioning: transitionAnimation.running
|
||||
property bool effectActive: false
|
||||
property bool _renderSettling: false
|
||||
property bool _renderSettling: true
|
||||
property bool useNextForEffect: false
|
||||
property string pendingWallpaper: ""
|
||||
property string _deferredSource: ""
|
||||
|
||||
Connections {
|
||||
target: currentWallpaper
|
||||
@@ -97,21 +98,47 @@ Variants {
|
||||
}
|
||||
}
|
||||
|
||||
function _recheckScreenScale() {
|
||||
const newScale = CompositorService.getScreenScale(modelData);
|
||||
if (newScale !== root.screenScale) {
|
||||
console.info("WallpaperBackground: screen scale corrected for", modelData.name + ":", root.screenScale, "->", newScale);
|
||||
root.screenScale = newScale;
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: NiriService
|
||||
function onDisplayScalesChanged() {
|
||||
root._recheckScreenScale();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: WlrOutputService
|
||||
function onWlrOutputAvailableChanged() {
|
||||
root._recheckScreenScale();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: CompositorService
|
||||
function onRandrDataReady() {
|
||||
if (root._deferredSource) {
|
||||
const src = root._deferredSource;
|
||||
root._deferredSource = "";
|
||||
root.setWallpaperImmediate(src);
|
||||
} else {
|
||||
root._recheckScreenScale();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: renderSettleTimer
|
||||
interval: 100
|
||||
onTriggered: root._renderSettling = false
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: updatesBindingTimer
|
||||
interval: 500
|
||||
onTriggered: {
|
||||
if (typeof wallpaperWindow.updatesEnabled !== "undefined")
|
||||
wallpaperWindow.updatesEnabled = Qt.binding(() => root.effectActive || root._renderSettling || currentWallpaper.status === Image.Loading || nextWallpaper.status === Image.Loading);
|
||||
}
|
||||
}
|
||||
|
||||
function getFillMode(modeName) {
|
||||
switch (modeName) {
|
||||
case "Stretch":
|
||||
@@ -136,15 +163,13 @@ Variants {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (typeof wallpaperWindow.updatesEnabled !== "undefined")
|
||||
wallpaperWindow.updatesEnabled = Qt.binding(() => root.effectActive || root._renderSettling || currentWallpaper.status === Image.Loading || nextWallpaper.status === Image.Loading);
|
||||
|
||||
if (!source) {
|
||||
isInitialized = true;
|
||||
updatesBindingTimer.start();
|
||||
return;
|
||||
root._renderSettling = false;
|
||||
}
|
||||
const formattedSource = source.startsWith("file://") ? source : encodeFileUrl(source);
|
||||
setWallpaperImmediate(formattedSource);
|
||||
isInitialized = true;
|
||||
updatesBindingTimer.start();
|
||||
}
|
||||
|
||||
onSourceChanged: {
|
||||
@@ -156,8 +181,11 @@ Variants {
|
||||
const formattedSource = source.startsWith("file://") ? source : encodeFileUrl(source);
|
||||
|
||||
if (!isInitialized || !currentWallpaper.source) {
|
||||
if (!CompositorService.randrReady) {
|
||||
_deferredSource = formattedSource;
|
||||
return;
|
||||
}
|
||||
setWallpaperImmediate(formattedSource);
|
||||
isInitialized = true;
|
||||
return;
|
||||
}
|
||||
if (CompositorService.isNiri && SessionData.isSwitchingMode) {
|
||||
@@ -173,6 +201,7 @@ Variants {
|
||||
root.effectActive = false;
|
||||
root._renderSettling = true;
|
||||
renderSettleTimer.restart();
|
||||
root.screenScale = CompositorService.getScreenScale(modelData);
|
||||
currentWallpaper.source = newSource;
|
||||
nextWallpaper.source = "";
|
||||
}
|
||||
@@ -201,6 +230,7 @@ Variants {
|
||||
return;
|
||||
if (!newPath || newPath.startsWith("#"))
|
||||
return;
|
||||
root.screenScale = CompositorService.getScreenScale(modelData);
|
||||
if (root.transitioning || root.effectActive) {
|
||||
root.pendingWallpaper = newPath;
|
||||
return;
|
||||
@@ -252,7 +282,7 @@ Variants {
|
||||
}
|
||||
|
||||
readonly property int maxTextureSize: 8192
|
||||
property real screenScale: CompositorService.getScreenScale(modelData)
|
||||
property real screenScale: 1
|
||||
property int textureWidth: Math.min(Math.round(modelData.width * screenScale), maxTextureSize)
|
||||
property int textureHeight: Math.min(Math.round(modelData.height * screenScale), maxTextureSize)
|
||||
|
||||
|
||||
@@ -29,11 +29,37 @@ Singleton {
|
||||
readonly property string labwcPid: Quickshell.env("LABWC_PID")
|
||||
property bool useNiriSorting: isNiri && NiriService
|
||||
|
||||
property var randrScales: ({})
|
||||
property bool randrReady: false
|
||||
signal randrDataReady
|
||||
|
||||
property var sortedToplevels: []
|
||||
property bool _sortScheduled: false
|
||||
|
||||
signal toplevelsChanged
|
||||
|
||||
function fetchRandrData() {
|
||||
Proc.runCommand("randr", ["dms", "randr", "--json"], (output, exitCode) => {
|
||||
if (exitCode === 0 && output) {
|
||||
try {
|
||||
const data = JSON.parse(output.trim());
|
||||
if (data.outputs && Array.isArray(data.outputs)) {
|
||||
const scales = {};
|
||||
for (const out of data.outputs) {
|
||||
if (out.name && out.scale > 0)
|
||||
scales[out.name] = out.scale;
|
||||
}
|
||||
randrScales = scales;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("CompositorService: failed to parse randr data:", e);
|
||||
}
|
||||
}
|
||||
randrReady = true;
|
||||
randrDataReady();
|
||||
}, 0, 3000);
|
||||
}
|
||||
|
||||
function getScreenScale(screen) {
|
||||
if (!screen)
|
||||
return 1;
|
||||
@@ -42,6 +68,10 @@ Singleton {
|
||||
return screen.devicePixelRatio || 1;
|
||||
}
|
||||
|
||||
const randrScale = randrScales[screen.name];
|
||||
if (randrScale !== undefined && randrScale > 0)
|
||||
return Math.round(randrScale * 20) / 20;
|
||||
|
||||
if (WlrOutputService.wlrOutputAvailable && screen) {
|
||||
const wlrOutput = WlrOutputService.getOutput(screen.name);
|
||||
if (wlrOutput?.enabled && wlrOutput.scale !== undefined && wlrOutput.scale > 0) {
|
||||
@@ -137,6 +167,7 @@ Singleton {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
fetchRandrData();
|
||||
detectCompositor();
|
||||
scheduleSort();
|
||||
Qt.callLater(() => {
|
||||
|
||||
Reference in New Issue
Block a user