mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-06 21:48:30 -04:00
refactor: (modals/popouts): sync functions & improve blur calculations across modals
This commit is contained in:
@@ -39,6 +39,8 @@ Item {
|
||||
property bool fullHeightSurface: false
|
||||
property bool _primeContent: false
|
||||
property bool _contentWarm: false
|
||||
// Keyboard focus grabbed one tick after emerge starts, to avoid stalling first frames.
|
||||
property bool _keyboardReady: false
|
||||
property bool _resizeActive: false
|
||||
property real _chromeAnimTravelX: 1
|
||||
property real _chromeAnimTravelY: 1
|
||||
@@ -241,7 +243,8 @@ Item {
|
||||
}
|
||||
|
||||
function _connectedChromeState(visibleOverride) {
|
||||
const visible = visibleOverride !== undefined ? !!visibleOverride : contentWindow.visible;
|
||||
// Track intent rather than the transient wl_surface state during remap.
|
||||
const visible = visibleOverride !== undefined ? !!visibleOverride : (contentWindow.visible || root.shouldBeVisible);
|
||||
const presented = contentWindow.visible || root.shouldBeVisible;
|
||||
const phase = root.isClosing ? "closing" : (!presented ? "hidden" : (!contentWindow.visible && root.shouldBeVisible ? "opening" : "open"));
|
||||
const bodyX = Theme.snap(root.pubBodyX, root.dpr);
|
||||
@@ -353,48 +356,26 @@ Item {
|
||||
_publishedBodyValid = false;
|
||||
}
|
||||
|
||||
property bool _animSyncQueued: false
|
||||
property bool _bodySyncQueued: false
|
||||
|
||||
function _queueFullSync() {
|
||||
_fullSyncQueued = true;
|
||||
if (!_syncTimer.running)
|
||||
_syncTimer.restart();
|
||||
}
|
||||
function _queueAnimSync() {
|
||||
_animSyncQueued = true;
|
||||
if (!_syncTimer.running)
|
||||
_syncTimer.restart();
|
||||
}
|
||||
function _queueBodySync() {
|
||||
_bodySyncQueued = true;
|
||||
if (!_syncTimer.running)
|
||||
_syncTimer.restart();
|
||||
}
|
||||
function _flushSync() {
|
||||
const fullDirty = _fullSyncQueued;
|
||||
const animDirty = _animSyncQueued;
|
||||
const bodyDirty = _bodySyncQueued;
|
||||
if (!_fullSyncQueued)
|
||||
return;
|
||||
_fullSyncQueued = false;
|
||||
_animSyncQueued = false;
|
||||
_bodySyncQueued = false;
|
||||
if (fullDirty)
|
||||
_syncPopoutChromeState();
|
||||
if (animDirty) {
|
||||
_syncPopoutAnim("x");
|
||||
_syncPopoutAnim("y");
|
||||
}
|
||||
if (bodyDirty)
|
||||
_syncPopoutBody();
|
||||
_syncPopoutChromeState();
|
||||
}
|
||||
|
||||
onAlignedXChanged: _queueFullSync()
|
||||
onAlignedYChanged: _queueFullSync()
|
||||
onAlignedWidthChanged: _queueFullSync()
|
||||
onContentAnimXChanged: _queueAnimSync()
|
||||
onContentAnimYChanged: _queueAnimSync()
|
||||
onRenderedAlignedYChanged: _queueBodySync()
|
||||
onRenderedAlignedHeightChanged: _queueBodySync()
|
||||
// Cheap deduped scalar writes: publish synchronously to stay in the same frame.
|
||||
onContentAnimXChanged: _syncPopoutAnim("x")
|
||||
onContentAnimYChanged: _syncPopoutAnim("y")
|
||||
onRenderedAlignedYChanged: _syncPopoutBody()
|
||||
onRenderedAlignedHeightChanged: _syncPopoutBody()
|
||||
onScreenChanged: {
|
||||
_resetPublishedBody();
|
||||
_queueFullSync();
|
||||
@@ -517,6 +498,10 @@ Item {
|
||||
|
||||
animationsEnabled = true;
|
||||
shouldBeVisible = true;
|
||||
Qt.callLater(() => {
|
||||
if (root.shouldBeVisible)
|
||||
root._keyboardReady = true;
|
||||
});
|
||||
if (shouldBeVisible && screen) {
|
||||
opened();
|
||||
}
|
||||
@@ -530,6 +515,7 @@ Item {
|
||||
_resetPublishedBody();
|
||||
isClosing = true;
|
||||
shouldBeVisible = false;
|
||||
_keyboardReady = false;
|
||||
_primeContent = false;
|
||||
PopoutManager.popoutChanged();
|
||||
closeTimer.restart();
|
||||
@@ -743,9 +729,9 @@ Item {
|
||||
readonly property real pubBodyW: morphSeedW + (alignedWidth - morphSeedW) * morphProgress
|
||||
readonly property real pubBodyH: morphSeedH + (renderedAlignedHeight - morphSeedH) * morphProgress
|
||||
|
||||
// One animation drives all four coordinates, so queue one coalesced state update
|
||||
// per progress tick instead of reacting independently to each derived property.
|
||||
onMorphProgressChanged: _queueBodySync()
|
||||
// One animation drives all four coordinates, so publish once per progress
|
||||
// tick instead of reacting independently to each derived property.
|
||||
onMorphProgressChanged: _syncPopoutBody()
|
||||
|
||||
function _beginMorphTravel() {
|
||||
morphTravelEnabled = false;
|
||||
@@ -967,7 +953,7 @@ Item {
|
||||
WlrLayershell.namespace: root.layerNamespace
|
||||
WlrLayershell.layer: root.effectivePopoutLayer
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: KeyboardFocus.keyboardFocus(shouldBeVisible, customKeyboardFocus)
|
||||
WlrLayershell.keyboardFocus: KeyboardFocus.keyboardFocus(shouldBeVisible && root._keyboardReady, customKeyboardFocus)
|
||||
|
||||
readonly property bool _fullHeight: root.fullHeightSurface
|
||||
anchors {
|
||||
|
||||
@@ -620,13 +620,13 @@ Item {
|
||||
id: popoutBlur
|
||||
targetWindow: contentWindow
|
||||
readonly property real s: Math.min(1, contentContainer.scaleValue)
|
||||
readonly property real op: Math.max(0, Math.min(1, (morph.openProgress - 0.08) * 1.6))
|
||||
readonly property bool revealClipActive: root.fluidStandaloneActive
|
||||
|
||||
blurX: revealClipActive ? contentContainer.x : contentContainer.x + contentContainer.width * (1 - s * op) * 0.5 + Theme.snap(contentContainer.animX, root.dpr)
|
||||
blurY: revealClipActive ? contentContainer.y : contentContainer.y + contentContainer.height * (1 - s * op) * 0.5 + Theme.snap(contentContainer.animY, root.dpr)
|
||||
blurWidth: root.shouldBeVisible ? (revealClipActive ? contentContainer.width : contentContainer.width * s * op) : 0
|
||||
blurHeight: root.shouldBeVisible ? (revealClipActive ? contentContainer.height : contentContainer.height * s * op) : 0
|
||||
// Blur tracks the surface's scaled rect, matching the connected backend
|
||||
blurX: revealClipActive ? contentContainer.x : contentContainer.x + contentContainer.width * (1 - s) * 0.5 + Theme.snap(contentContainer.animX, root.dpr)
|
||||
blurY: revealClipActive ? contentContainer.y : contentContainer.y + contentContainer.height * (1 - s) * 0.5 + Theme.snap(contentContainer.animY, root.dpr)
|
||||
blurWidth: root.shouldBeVisible ? (revealClipActive ? contentContainer.width : contentContainer.width * s) : 0
|
||||
blurHeight: root.shouldBeVisible ? (revealClipActive ? contentContainer.height : contentContainer.height * s) : 0
|
||||
blurRadius: Theme.cornerRadius
|
||||
clipEnabled: revealClipActive
|
||||
clipX: contentContainer.x + contentContainer.revealX
|
||||
|
||||
@@ -99,8 +99,9 @@ Item {
|
||||
root._clear();
|
||||
}
|
||||
function onResourcesLost() {
|
||||
lifecycleKickAction.cancel();
|
||||
root._clear();
|
||||
// Re-arm so blur self-heals since instances are no longer recreated per open
|
||||
root._scheduleLifecycleKick();
|
||||
}
|
||||
function onWindowConnected() {
|
||||
root._scheduleLifecycleKick();
|
||||
|
||||
Reference in New Issue
Block a user