diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-24 06:37:45 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-24 08:15:46 +0200 |
commit | bbbc820d7920a31669cb7e9aaeb5beb072eae175 (patch) | |
tree | 8d967ac1f0b11827cf1cec01a41cbca07a6f8ca5 | |
parent | f6664e1a485f459d010c344af100f9d337941a7c (diff) |
Qt5 don't assert broken height or width
At least maths element docking window has a floating height of zero.
So the original gtk comment about broken values is still true.
And the initial SalFrameGeometry is ok, so no need to initialize it.
And set default size and position on show, if not explicitly set.
Change-Id: Ibe4969a164b50b666745ce010f5100af4b3ff2f6
Reviewed-on: https://gerrit.libreoffice.org/74614
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r-- | vcl/inc/qt5/Qt5Frame.hxx | 2 | ||||
-rw-r--r-- | vcl/qt5/Qt5Frame.cxx | 48 |
2 files changed, 19 insertions, 31 deletions
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx index 5b1bc1025445..4c94b846bc93 100644 --- a/vcl/inc/qt5/Qt5Frame.hxx +++ b/vcl/inc/qt5/Qt5Frame.hxx @@ -109,7 +109,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame ScreenSaverInhibitor m_ScreenSaverInhibitor; #endif - void Center(); + void SetDefaultPos(); Size CalcDefaultSize(); void SetDefaultSize(); diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index 7559b42d0f86..0bfd51c515da 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -163,21 +163,6 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) pChildWindow->setTransientParent(pParentWindow); } - // fake an initial geometry, gets updated via configure event or SetPosSize - if (m_bDefaultPos || m_bDefaultSize) - { - maGeometry.nDisplayScreenNumber = 0; - Size aDefSize = CalcDefaultSize(); - maGeometry.nX = 0; - maGeometry.nY = 0; - maGeometry.nWidth = aDefSize.Width(); - maGeometry.nHeight = aDefSize.Height(); - maGeometry.nTopDecoration = 0; - maGeometry.nBottomDecoration = 0; - maGeometry.nLeftDecoration = 0; - maGeometry.nRightDecoration = 0; - } - m_aSystemData.nSize = sizeof(SystemEnvData); // Calling 'QWidget::winId()' implicitly enables native windows to be used @@ -370,6 +355,7 @@ void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/) assert(m_pQWidget); SetDefaultSize(); + SetDefaultPos(); auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance)); assert(pSalInst); @@ -388,15 +374,22 @@ void Qt5Frame::SetMaxClientSize(long nWidth, long nHeight) asChild()->setMaximumSize(nWidth, nHeight); } -void Qt5Frame::Center() +void Qt5Frame::SetDefaultPos() { + if (!m_bDefaultPos) + return; + + // center on parent if (m_pParent) { - QWidget* pWindow = m_pParent->GetQWidget()->window(); + QWidget* const pWindow = m_pParent->GetQWidget()->window(); QWidget* const pWidget = asChild(); - pWidget->move(pWindow->frameGeometry().topLeft() + pWindow->rect().center() - - pWidget->rect().center()); + QPoint aPos = pWindow->rect().center() - pWidget->rect().center(); + SetPosSize(aPos.x(), aPos.y(), 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y); + assert(!m_bDefaultPos); } + else + m_bDefaultPos = false; } Size Qt5Frame::CalcDefaultSize() @@ -443,31 +436,30 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt1 if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) { - m_bDefaultSize = false; if (isChild(false) || !m_pQWidget->isMaximized()) { if (!(nFlags & SAL_FRAME_POSSIZE_WIDTH)) nWidth = maGeometry.nWidth; else if (!(nFlags & SAL_FRAME_POSSIZE_HEIGHT)) nHeight = maGeometry.nHeight; - assert(nWidth > 0 && nHeight > 0); if (nWidth > 0 && nHeight > 0) { + m_bDefaultSize = false; if (m_nStyle & SalFrameStyleFlags::SIZEABLE) asChild()->resize(nWidth, nHeight); else asChild()->setFixedSize(nWidth, nHeight); + } - // assume the resize happened - // needed for calculations and will eventually be corrected by events + // assume the resize happened + // needed for calculations and will eventually be corrected by events + if (nWidth > 0) maGeometry.nWidth = nWidth; + if (nHeight > 0) maGeometry.nHeight = nHeight; - } } } - else - SetDefaultSize(); if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)) { @@ -498,10 +490,6 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt1 m_bDefaultPos = false; asChild()->move(nX, nY); } - else if (m_bDefaultPos) - Center(); - - m_bDefaultPos = false; } void Qt5Frame::GetClientSize(long& rWidth, long& rHeight) |