commit 538ae8ab2401111df543878878137f179ab7bc07 parent 8a143c8de6aad8e5a4765fe9d5a08123087ce658 Author: falkTX <falktx@falktx.com> Date: Sun, 16 May 2021 17:01:08 +0100 Allow modals to prevent themselves from closing Signed-off-by: falkTX <falktx@falktx.com> Diffstat:
M | dgl/src/WindowPrivateData.cpp | | | 21 | ++++++++++++++------- |
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp @@ -472,18 +472,25 @@ void Window::PrivateData::onPuglClose() { DGL_DBG("PUGL: onClose\n"); - if (! self->onClose()) - return; + // if we have a parent or running as standalone we can prevent closing in certain conditions + if (modal.parent != nullptr || appData->isStandalone) + { + // parent gives focus to us as modal, prevent closing + if (modal.child != nullptr) + return modal.child->focus(); + + // ask window if we should close + if (! self->onClose()) + return; + } if (modal.enabled) stopModal(); - if (modal.child != nullptr) + if (PrivateData* const child = modal.child) { - if (modal.child->modal.enabled) - modal.child->stopModal(); - - modal.child->close(); + modal.child = nullptr; + child->close(); } close();