summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2022-01-09 00:51:09 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2022-01-09 13:25:59 +0100
commit0c124cb6e112b340c397c7615b127e71fbfd5e8c (patch)
tree52bcfd2129c43871a4f24ed4890d78a26550f238 /vcl/qt5
parent652a7f1fce0daedee2efa1034ac6047dd49e206e (diff)
Qt minimize modal reparenting a bit
Change-Id: Ie7203e9d92e5971de6c2730ff847f351e5641c9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128178 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtFrame.cxx21
1 files changed, 13 insertions, 8 deletions
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 46f7a1a409ff..1f69ed66da0c 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -176,8 +176,8 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
{
- QWindow* pParentWindow = pParent->GetQWidget()->window()->windowHandle();
- QWindow* pChildWindow = asChild()->window()->windowHandle();
+ QWindow* pParentWindow = pParent->windowHandle();
+ QWindow* pChildWindow = windowHandle();
if (pParentWindow && pChildWindow && (pParentWindow != pChildWindow))
pChildWindow->setTransientParent(pParentWindow);
}
@@ -349,6 +349,7 @@ QWindow* QtFrame::windowHandle() const
{
// set attribute 'Qt::WA_NativeWindow' first to make sure a window handle actually exists
QWidget* pChild = asChild();
+ assert(pChild->window() == pChild);
pChild->setAttribute(Qt::WA_NativeWindow);
return pChild->windowHandle();
}
@@ -428,21 +429,25 @@ void QtFrame::modalReparent(bool bVisible)
if (!bVisible)
{
- m_pQWidget->setParent(m_pParent ? m_pParent->asChild() : nullptr,
- m_pQWidget->windowFlags());
+ QWidget* pNewParent = m_pParent ? m_pParent->asChild() : nullptr;
+ if (pNewParent != m_pQWidget->parent())
+ m_pQWidget->setParent(pNewParent, m_pQWidget->windowFlags());
return;
}
- if (!QGuiApplication::modalWindow())
+ const QWindow* pModalWin = QGuiApplication::modalWindow();
+ if (!pModalWin || m_pParent->windowHandle() == pModalWin)
return;
QtInstance* pInst = static_cast<QtInstance*>(GetSalData()->m_pInstance);
for (auto* pFrame : pInst->getFrames())
{
- QWidget* pQWidget = static_cast<QtFrame*>(pFrame)->asChild();
- if (pQWidget->windowHandle() == QGuiApplication::modalWindow())
+ QtFrame* pQtFrame = static_cast<QtFrame*>(pFrame);
+ if (pQtFrame->windowHandle() == pModalWin)
{
- m_pQWidget->setParent(pQWidget, m_pQWidget->windowFlags());
+ QWidget* pNewParent = pQtFrame->asChild();
+ if (pNewParent != m_pQWidget->parent())
+ m_pQWidget->setParent(pNewParent, m_pQWidget->windowFlags());
break;
}
}