mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-10 15:52:58 -04:00
wallpaper: handle initial load better, add dms randr command for quick
physical scale retrieval
This commit is contained in:
@@ -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