mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-08 06:28:27 -04:00
refactor(Xray): Update Xray & standalone to frame transitions
- Fix dbar autohide with Xray options that could have blocked bar area content - Fixes #2729
This commit is contained in:
@@ -25,6 +25,22 @@ Singleton {
|
||||
property bool luaConfigStatusReady: false
|
||||
property bool luaConfigStatusLoading: false
|
||||
property string luaConfigFormat: ""
|
||||
property bool layoutGenerationPending: false
|
||||
property bool layoutGenerationRunning: false
|
||||
property int _layoutRequestRevision: 0
|
||||
property int _layoutAppliedRevision: 0
|
||||
property int _frameTransitionRevision: 0
|
||||
readonly property bool frameLayoutReady: _layoutAppliedRevision >= _frameTransitionRevision
|
||||
|
||||
DeferredAction {
|
||||
id: layoutGenerationAction
|
||||
onTriggered: root.doGenerateLayoutConfig()
|
||||
}
|
||||
|
||||
onLuaConfigStatusLoadingChanged: {
|
||||
if (!luaConfigStatusLoading && layoutGenerationPending)
|
||||
layoutGenerationAction.schedule();
|
||||
}
|
||||
|
||||
onLuaConfigActiveChanged: {
|
||||
if (luaConfigActive)
|
||||
@@ -237,18 +253,39 @@ Singleton {
|
||||
});
|
||||
}
|
||||
|
||||
function reloadConfig() {
|
||||
function reloadConfig(callback) {
|
||||
Proc.runCommand("hyprctl-reload", ["hyprctl", "reload"], (output, exitCode) => {
|
||||
if (exitCode !== 0)
|
||||
log.warn("hyprctl reload failed:", output);
|
||||
if (callback)
|
||||
callback(exitCode === 0);
|
||||
});
|
||||
}
|
||||
|
||||
function generateLayoutConfig() {
|
||||
function generateLayoutConfig(frameTransition) {
|
||||
if (!CompositorService.isHyprland)
|
||||
return;
|
||||
if (!canWriteLuaConfig("layout"))
|
||||
_layoutRequestRevision++;
|
||||
if (frameTransition === true)
|
||||
_frameTransitionRevision = _layoutRequestRevision;
|
||||
layoutGenerationPending = true;
|
||||
layoutGenerationAction.schedule();
|
||||
}
|
||||
|
||||
function doGenerateLayoutConfig() {
|
||||
if (layoutGenerationRunning)
|
||||
return;
|
||||
layoutGenerationPending = false;
|
||||
const requestRevision = _layoutRequestRevision;
|
||||
if (!canWriteLuaConfig("layout")) {
|
||||
if (luaConfigStatusLoading || !luaConfigStatusReady) {
|
||||
layoutGenerationPending = true;
|
||||
return;
|
||||
}
|
||||
_layoutAppliedRevision = Math.max(_layoutAppliedRevision, requestRevision);
|
||||
return;
|
||||
}
|
||||
layoutGenerationRunning = true;
|
||||
|
||||
const defaultRadius = typeof SettingsData !== "undefined" ? SettingsData.cornerRadius : 12;
|
||||
const defaultGaps = typeof SettingsData !== "undefined" ? Math.max(4, (SettingsData.barConfigs[0]?.spacing ?? 4)) : 4;
|
||||
@@ -262,10 +299,9 @@ Singleton {
|
||||
const barFrameXrayEnabled = typeof SettingsData === "undefined" || SettingsData.hyprlandLayoutBarXrayEnabled;
|
||||
const frameEnabled = typeof SettingsData !== "undefined" && SettingsData.frameEnabled;
|
||||
const frameConnectedMode = frameEnabled && SettingsData.frameMode === "connected";
|
||||
|
||||
// Hyprland's `xray = false` is still in early development, so unlike niri we never emit it (unset already
|
||||
// samples real content) - we only force xray=true
|
||||
const barFrameTargetNamespace = !frameEnabled ? "dms:bar" : (frameConnectedMode ? null : "dms:frame");
|
||||
// Hyprland `xray = false` is still early-development; unset already samples real content, so only force xray=true
|
||||
// Standalone Bar Xray is safe only while every active bar reserves its strip
|
||||
const barFrameTargetNamespace = !frameEnabled ? (SettingsData.standaloneBarXrayAvailable ? "dms:bar" : null) : (frameConnectedMode ? null : "dms:frame");
|
||||
|
||||
let content = `-- Auto-generated by DMS — do not edit manually
|
||||
|
||||
@@ -302,10 +338,21 @@ hl.layer_rule({
|
||||
Proc.runCommand("hypr-write-layout", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && cat > "${layoutPath}" << 'EOF'\n${content}EOF`], (output, exitCode) => {
|
||||
if (exitCode !== 0) {
|
||||
log.warn("Failed to write layout config:", output);
|
||||
// Best-effort ack so a failed write can't wedge frame transitions
|
||||
_layoutAppliedRevision = Math.max(_layoutAppliedRevision, requestRevision);
|
||||
layoutGenerationRunning = false;
|
||||
if (layoutGenerationPending)
|
||||
layoutGenerationAction.schedule();
|
||||
return;
|
||||
}
|
||||
log.info("Generated layout config at", layoutPath);
|
||||
reloadConfig();
|
||||
reloadConfig(success => {
|
||||
// Advance even on failure — proceed degraded rather than wedge the transition
|
||||
_layoutAppliedRevision = Math.max(_layoutAppliedRevision, requestRevision);
|
||||
layoutGenerationRunning = false;
|
||||
if (layoutGenerationPending)
|
||||
layoutGenerationAction.schedule();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user