mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-10 05:03:28 -04:00
refactor(frame): improve connected mode surface recovery
- share modal and launcher ownership handling - recover missing background and blur layers
This commit is contained in:
@@ -220,14 +220,20 @@ Item {
|
||||
|
||||
function _publishConnectedChromeState(forceClaim, visibleOverride) {
|
||||
if (!root.frameOwnsConnectedChrome || !root.screen || !_chromeClaimId)
|
||||
return;
|
||||
return false;
|
||||
|
||||
const screenName = root.screen.name;
|
||||
const isCurrent = PopoutManager.isCurrentPopout(popoutHandle, screenName);
|
||||
if (!ConnectedModeState.hasPopoutOwner(_chromeClaimId)) {
|
||||
if (!isCurrent)
|
||||
return false;
|
||||
forceClaim = true;
|
||||
} else if (forceClaim && !isCurrent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const state = _connectedChromeState(visibleOverride);
|
||||
if (forceClaim || !ConnectedModeState.hasPopoutOwner(_chromeClaimId)) {
|
||||
ConnectedModeState.claimPopout(_chromeClaimId, state);
|
||||
} else {
|
||||
ConnectedModeState.updatePopout(_chromeClaimId, state);
|
||||
}
|
||||
return forceClaim ? ConnectedModeState.claimPopout(_chromeClaimId, state) : ConnectedModeState.updatePopout(_chromeClaimId, state);
|
||||
}
|
||||
|
||||
function _releaseConnectedChromeState() {
|
||||
@@ -252,9 +258,12 @@ Item {
|
||||
}
|
||||
if (!contentWindow.visible && !shouldBeVisible)
|
||||
return;
|
||||
if (!_chromeClaimId)
|
||||
if (!_chromeClaimId) {
|
||||
if (!PopoutManager.isCurrentPopout(popoutHandle, root.screen.name))
|
||||
return;
|
||||
_chromeClaimId = _nextChromeClaimId();
|
||||
_publishConnectedChromeState(contentWindow.visible && !ConnectedModeState.hasPopoutOwner(_chromeClaimId));
|
||||
}
|
||||
_publishConnectedChromeState(!ConnectedModeState.hasPopoutOwner(_chromeClaimId));
|
||||
}
|
||||
|
||||
function _syncPopoutAnim(axis) {
|
||||
@@ -267,6 +276,11 @@ Item {
|
||||
const syncY = axis === "y" && (barSide === "top" || barSide === "bottom");
|
||||
if (!syncX && !syncY)
|
||||
return;
|
||||
if (!ConnectedModeState.hasPopoutOwner(_chromeClaimId)) {
|
||||
if (root.screen && PopoutManager.isCurrentPopout(popoutHandle, root.screen.name))
|
||||
_queueFullSync();
|
||||
return;
|
||||
}
|
||||
ConnectedModeState.setPopoutAnim(_chromeClaimId, syncX ? _connectedChromeAnimX() : undefined, syncY ? _connectedChromeAnimY() : undefined);
|
||||
}
|
||||
|
||||
@@ -275,6 +289,11 @@ Item {
|
||||
return;
|
||||
if (!contentWindow.visible && !shouldBeVisible)
|
||||
return;
|
||||
if (!ConnectedModeState.hasPopoutOwner(_chromeClaimId)) {
|
||||
if (root.screen && PopoutManager.isCurrentPopout(popoutHandle, root.screen.name))
|
||||
_queueFullSync();
|
||||
return;
|
||||
}
|
||||
ConnectedModeState.setPopoutBody(_chromeClaimId, root.alignedX, root.renderedAlignedY, root.alignedWidth, root.renderedAlignedHeight);
|
||||
}
|
||||
|
||||
@@ -326,10 +345,13 @@ Item {
|
||||
Connections {
|
||||
target: contentWindow
|
||||
function onVisibleChanged() {
|
||||
if (contentWindow.visible)
|
||||
if (contentWindow.visible) {
|
||||
if (!root._chromeClaimId)
|
||||
root._chromeClaimId = root._nextChromeClaimId();
|
||||
root._publishConnectedChromeState(true);
|
||||
else
|
||||
} else {
|
||||
root._releaseConnectedChromeState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +359,7 @@ Item {
|
||||
target: SettingsData
|
||||
function onConnectedFrameModeActiveChanged() {
|
||||
if (root.frameOwnsConnectedChrome) {
|
||||
if (contentWindow.visible || root.shouldBeVisible) {
|
||||
if ((contentWindow.visible || root.shouldBeVisible) && root.screen && PopoutManager.isCurrentPopout(root.popoutHandle, root.screen.name)) {
|
||||
if (!root._chromeClaimId)
|
||||
root._chromeClaimId = root._nextChromeClaimId();
|
||||
root._publishConnectedChromeState(true);
|
||||
@@ -351,6 +373,22 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ConnectedModeState
|
||||
function onPopoutOwnerIdChanged() {
|
||||
if ((contentWindow.visible || root.shouldBeVisible) && root.screen && PopoutManager.isCurrentPopout(root.popoutHandle, root.screen.name) && !ConnectedModeState.hasPopoutOwner(root._chromeClaimId))
|
||||
root._queueFullSync();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PopoutManager
|
||||
function onPopoutChanged() {
|
||||
if ((contentWindow.visible || root.shouldBeVisible) && root.screen && PopoutManager.isCurrentPopout(root.popoutHandle, root.screen.name))
|
||||
root._queueFullSync();
|
||||
}
|
||||
}
|
||||
|
||||
readonly property bool frameOwnsConnectedChrome: CompositorService.usesConnectedFrameChromeForScreen(root.screen)
|
||||
readonly property bool usesConnectedSurfaceChrome: Theme.isConnectedEffect && !CompositorService.connectedFrameBlockedOnScreen(root.screen)
|
||||
readonly property bool usesLocalConnectedSurfaceChrome: usesConnectedSurfaceChrome && !frameOwnsConnectedChrome
|
||||
@@ -373,6 +411,7 @@ Item {
|
||||
contentWindow.visible = false;
|
||||
}
|
||||
_lastOpenedScreen = screen;
|
||||
PopoutManager.showPopout(popoutHandle);
|
||||
|
||||
if (contentContainer) {
|
||||
// Snap morph closed only on a fresh open; on screen-change re-open we stay at 1
|
||||
@@ -408,7 +447,6 @@ Item {
|
||||
animationsEnabled = true;
|
||||
shouldBeVisible = true;
|
||||
if (shouldBeVisible && screen) {
|
||||
PopoutManager.showPopout(popoutHandle);
|
||||
opened();
|
||||
}
|
||||
}
|
||||
@@ -440,6 +478,8 @@ Item {
|
||||
}
|
||||
if (!screenStillExists) {
|
||||
close();
|
||||
} else {
|
||||
root._queueFullSync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ Item {
|
||||
targetWindow.BackgroundEffect.blurRegion = _active ? blurRegion : null;
|
||||
}
|
||||
|
||||
function _clear() {
|
||||
if (targetWindow)
|
||||
targetWindow.BackgroundEffect.blurRegion = null;
|
||||
}
|
||||
|
||||
// Force BackgroundEffect to re-publish the blur region on the current wl_surface.
|
||||
// Clearing first bypasses Quickshell's same-Region dedup in BackgroundEffect::setBlurRegion,
|
||||
// setting pendingBlurRegion=true so the next polish actually ships the region — needed
|
||||
@@ -45,20 +50,56 @@ Item {
|
||||
targetWindow.BackgroundEffect.blurRegion = _active ? blurRegion : null;
|
||||
}
|
||||
|
||||
on_ActiveChanged: _apply()
|
||||
onTargetWindowChanged: _apply()
|
||||
function _scheduleLifecycleKick() {
|
||||
lifecycleKickAction.restart();
|
||||
}
|
||||
|
||||
function _runLifecycleKick() {
|
||||
if (!targetWindow)
|
||||
return;
|
||||
if (targetWindow.visible)
|
||||
kick();
|
||||
else
|
||||
_apply();
|
||||
}
|
||||
|
||||
on_ActiveChanged: {
|
||||
if (_active)
|
||||
_scheduleLifecycleKick();
|
||||
else
|
||||
_clear();
|
||||
}
|
||||
onTargetWindowChanged: {
|
||||
lifecycleKickAction.cancel();
|
||||
_apply();
|
||||
}
|
||||
|
||||
DeferredAction {
|
||||
id: lifecycleKickAction
|
||||
onTriggered: root._runLifecycleKick()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.targetWindow ?? null
|
||||
ignoreUnknownSignals: true
|
||||
function onVisibleChanged() {
|
||||
if (root.targetWindow && root.targetWindow.visible)
|
||||
root._apply();
|
||||
root._scheduleLifecycleKick();
|
||||
else
|
||||
root._clear();
|
||||
}
|
||||
function onResourcesLost() {
|
||||
lifecycleKickAction.cancel();
|
||||
root._clear();
|
||||
}
|
||||
function onWindowConnected() {
|
||||
root._scheduleLifecycleKick();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: _apply()
|
||||
Component.onCompleted: _scheduleLifecycleKick()
|
||||
Component.onDestruction: {
|
||||
lifecycleKickAction.cancel();
|
||||
if (targetWindow)
|
||||
targetWindow.BackgroundEffect.blurRegion = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user