1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-05 21:18:30 -04:00

portal: prevent feedback loop with the gtk4 hack to make it react to

color scheme changes
This commit is contained in:
bbedward
2026-07-04 20:42:33 -04:00
parent 30ceda97a0
commit 8a85ab06a1
6 changed files with 136 additions and 11 deletions
+31 -10
View File
@@ -87,22 +87,43 @@ Singleton {
}
}
function evaluateColorScheme() {
function canSyncColorScheme() {
if (typeof SettingsData === "undefined" || !SettingsData.syncModeWithPortal)
return;
return false;
if (!settingsPortalAvailable)
return;
return false;
if (typeof SessionData !== "undefined" && SessionData.themeModeAutoEnabled)
return;
if (typeof Theme === "undefined")
return;
// Defer mid-generation: setLightMode's regen would be dropped, and DMS's own transient color-scheme toggle would be misread. Re-run on worker completion.
if (Theme.workerRunning)
return false;
return typeof Theme !== "undefined";
}
// Only follow values stable for the settle window — the GTK4-refresh toggle reverts within ~50ms and following it would loop.
function evaluateColorScheme() {
if (!canSyncColorScheme())
return;
const shouldBeLight = systemColorScheme !== 1;
if (Theme.isLightMode === shouldBeLight)
if (Theme.isLightMode === shouldBeLight) {
colorSchemeSettleTimer.stop();
return;
Theme.setLightMode(shouldBeLight, true, false);
}
colorSchemeSettleTimer.restart();
}
Timer {
id: colorSchemeSettleTimer
interval: 750
onTriggered: {
if (!root.canSyncColorScheme())
return;
const shouldBeLight = root.systemColorScheme !== 1;
if (Theme.isLightMode === shouldBeLight)
return;
if (Theme.workerRunning) {
restart();
return;
}
Theme.setLightMode(shouldBeLight, true, false);
}
}
function setLightMode(isLightMode) {