mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
Revert "dankmodal: fix persistent modal handling"
This reverts commit e7cb0d397e.
This commit is contained in:
@@ -15,97 +15,30 @@ Singleton {
|
|||||||
property bool windowsVisible: false
|
property bool windowsVisible: false
|
||||||
property var targetScreen: null
|
property var targetScreen: null
|
||||||
property var persistentModal: null
|
property var persistentModal: null
|
||||||
property Item currentDirectContent: null
|
|
||||||
|
|
||||||
readonly property bool hasActiveModal: activeModal !== null
|
readonly property bool hasActiveModal: activeModal !== null
|
||||||
readonly property bool hasPersistentModal: persistentModal !== null
|
readonly property bool hasPersistentModal: persistentModal !== null
|
||||||
readonly property bool isPersistentModalActive: hasActiveModal && activeModal === persistentModal
|
readonly property bool isPersistentModalActive: hasActiveModal && activeModal === persistentModal
|
||||||
readonly property bool shouldShowModal: hasActiveModal
|
readonly property bool shouldShowModal: hasActiveModal
|
||||||
readonly property bool shouldKeepWindowsAlive: hasPersistentModal && targetScreen !== null
|
readonly property bool shouldKeepWindowsAlive: hasPersistentModal
|
||||||
|
|
||||||
onPersistentModalChanged: {
|
onPersistentModalChanged: {
|
||||||
if (!persistentModal) {
|
if (!persistentModal)
|
||||||
if (!hasActiveModal)
|
|
||||||
targetScreen = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (!targetScreen)
|
|
||||||
targetScreen = CompositorService.focusedScreen;
|
|
||||||
cachedModal = persistentModal;
|
cachedModal = persistentModal;
|
||||||
updateCachedModalProperties(persistentModal);
|
cachedModalWidth = Theme.px(persistentModal.modalWidth, dpr);
|
||||||
}
|
cachedModalHeight = Theme.px(persistentModal.modalHeight, dpr);
|
||||||
|
cachedModalX = calculateX(persistentModal);
|
||||||
onActiveModalChanged: updateDirectContent()
|
cachedModalY = calculateY(persistentModal);
|
||||||
|
cachedAnimationDuration = persistentModal.animationDuration ?? Theme.shortDuration;
|
||||||
function updateCachedModalProperties(modal) {
|
cachedEnterCurve = persistentModal.animationEnterCurve ?? Theme.expressiveCurves.expressiveFastSpatial;
|
||||||
if (!modal)
|
cachedExitCurve = persistentModal.animationExitCurve ?? Theme.expressiveCurves.expressiveFastSpatial;
|
||||||
return;
|
cachedScaleCollapsed = persistentModal.animationScaleCollapsed ?? 0.96;
|
||||||
cachedModalWidth = Theme.px(modal.modalWidth, dpr);
|
if (persistentModal.directContent) {
|
||||||
cachedModalHeight = Theme.px(modal.modalHeight, dpr);
|
persistentModal.directContent.parent = directContentWrapper;
|
||||||
cachedModalX = calculateX(modal);
|
persistentModal.directContent.anchors.fill = directContentWrapper;
|
||||||
cachedModalY = calculateY(modal);
|
|
||||||
cachedAnimationDuration = modal.animationDuration ?? Theme.shortDuration;
|
|
||||||
cachedEnterCurve = modal.animationEnterCurve ?? Theme.expressiveCurves.expressiveFastSpatial;
|
|
||||||
cachedExitCurve = modal.animationExitCurve ?? Theme.expressiveCurves.expressiveFastSpatial;
|
|
||||||
cachedScaleCollapsed = modal.animationScaleCollapsed ?? 0.96;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateDirectContent() {
|
|
||||||
if (currentDirectContent) {
|
|
||||||
currentDirectContent.visible = false;
|
|
||||||
currentDirectContent.parent = null;
|
|
||||||
currentDirectContent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!activeModal?.directContent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
currentDirectContent = activeModal.directContent;
|
|
||||||
currentDirectContent.parent = directContentWrapper;
|
|
||||||
currentDirectContent.anchors.fill = directContentWrapper;
|
|
||||||
currentDirectContent.visible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isScreenValid(screen) {
|
|
||||||
if (!screen)
|
|
||||||
return false;
|
|
||||||
for (const s of Quickshell.screens) {
|
|
||||||
if (s === screen || s.name === screen.name)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleScreensChanged() {
|
|
||||||
if (!targetScreen)
|
|
||||||
return;
|
|
||||||
if (isScreenValid(targetScreen))
|
|
||||||
return;
|
|
||||||
|
|
||||||
const newScreen = CompositorService.focusedScreen;
|
|
||||||
if (hasActiveModal) {
|
|
||||||
targetScreen = newScreen;
|
|
||||||
if (cachedModal)
|
|
||||||
updateCachedModalProperties(cachedModal);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasPersistentModal) {
|
|
||||||
targetScreen = newScreen;
|
|
||||||
updateCachedModalProperties(persistentModal);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
targetScreen = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: Quickshell
|
|
||||||
function onScreensChanged() {
|
|
||||||
root.handleScreensChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var screen: backgroundWindow.screen
|
readonly property var screen: backgroundWindow.screen
|
||||||
readonly property real dpr: screen ? CompositorService.getScreenScale(screen) : 1
|
readonly property real dpr: screen ? CompositorService.getScreenScale(screen) : 1
|
||||||
readonly property real shadowBuffer: 5
|
readonly property real shadowBuffer: 5
|
||||||
@@ -155,10 +88,18 @@ Singleton {
|
|||||||
function showModal(modal) {
|
function showModal(modal) {
|
||||||
wantsToHide = false;
|
wantsToHide = false;
|
||||||
targetScreen = CompositorService.focusedScreen;
|
targetScreen = CompositorService.focusedScreen;
|
||||||
|
|
||||||
activeModal = modal;
|
activeModal = modal;
|
||||||
cachedModal = modal;
|
cachedModal = modal;
|
||||||
windowsVisible = true;
|
windowsVisible = true;
|
||||||
updateCachedModalProperties(modal);
|
cachedModalWidth = Theme.px(modal.modalWidth, dpr);
|
||||||
|
cachedModalHeight = Theme.px(modal.modalHeight, dpr);
|
||||||
|
cachedModalX = calculateX(modal);
|
||||||
|
cachedModalY = calculateY(modal);
|
||||||
|
cachedAnimationDuration = modal.animationDuration ?? Theme.shortDuration;
|
||||||
|
cachedEnterCurve = modal.animationEnterCurve ?? Theme.expressiveCurves.expressiveFastSpatial;
|
||||||
|
cachedExitCurve = modal.animationExitCurve ?? Theme.expressiveCurves.expressiveFastSpatial;
|
||||||
|
cachedScaleCollapsed = modal.animationScaleCollapsed ?? 0.96;
|
||||||
|
|
||||||
if (modal.directContent)
|
if (modal.directContent)
|
||||||
Qt.callLater(focusDirectContent);
|
Qt.callLater(focusDirectContent);
|
||||||
@@ -186,39 +127,18 @@ Singleton {
|
|||||||
|
|
||||||
function hideModalInstant() {
|
function hideModalInstant() {
|
||||||
wantsToHide = false;
|
wantsToHide = false;
|
||||||
const closingModal = activeModal;
|
|
||||||
activeModal = null;
|
activeModal = null;
|
||||||
|
windowsVisible = false;
|
||||||
if (shouldKeepWindowsAlive) {
|
|
||||||
cachedModal = persistentModal;
|
|
||||||
updateCachedModalProperties(persistentModal);
|
|
||||||
} else {
|
|
||||||
windowsVisible = false;
|
|
||||||
targetScreen = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanupInputMethod();
|
cleanupInputMethod();
|
||||||
if (closingModal && typeof closingModal.onFullyClosed === "function")
|
|
||||||
closingModal.onFullyClosed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCloseAnimationFinished() {
|
function onCloseAnimationFinished() {
|
||||||
if (hasActiveModal)
|
if (hasActiveModal)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cachedModal && typeof cachedModal.onFullyClosed === "function")
|
if (cachedModal && typeof cachedModal.onFullyClosed === "function")
|
||||||
cachedModal.onFullyClosed();
|
cachedModal.onFullyClosed();
|
||||||
|
|
||||||
cleanupInputMethod();
|
cleanupInputMethod();
|
||||||
|
|
||||||
if (shouldKeepWindowsAlive) {
|
|
||||||
cachedModal = persistentModal;
|
|
||||||
updateCachedModalProperties(persistentModal);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
windowsVisible = false;
|
windowsVisible = false;
|
||||||
targetScreen = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupInputMethod() {
|
function cleanupInputMethod() {
|
||||||
@@ -380,11 +300,21 @@ Singleton {
|
|||||||
width: root.modalWidth
|
width: root.modalWidth
|
||||||
height: root.modalHeight
|
height: root.modalHeight
|
||||||
|
|
||||||
readonly property bool hasDirectContent: root.currentDirectContent !== null
|
readonly property bool hasDirectContent: root.cachedModal ? (root.cachedModal.directContent !== null && root.cachedModal.directContent !== undefined) : false
|
||||||
|
|
||||||
opacity: root.shouldShowModal ? 1 : 0
|
opacity: root.shouldShowModal ? 1 : 0
|
||||||
scale: root.shouldShowModal ? 1 : root.cachedScaleCollapsed
|
scale: root.shouldShowModal ? 1 : root.cachedScaleCollapsed
|
||||||
|
|
||||||
|
onHasDirectContentChanged: {
|
||||||
|
if (!hasDirectContent)
|
||||||
|
return;
|
||||||
|
const dc = root.cachedModal.directContent;
|
||||||
|
if (dc.parent === directContentWrapper)
|
||||||
|
return;
|
||||||
|
dc.parent = directContentWrapper;
|
||||||
|
dc.anchors.fill = directContentWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
id: opacityAnimation
|
id: opacityAnimation
|
||||||
|
|||||||
Reference in New Issue
Block a user