[Libreoffice-commits] core.git: vcl/inc vcl/qt5

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 4 08:06:12 UTC 2018


 vcl/inc/qt5/Qt5Frame.hxx |    2 +
 vcl/qt5/Qt5Frame.cxx     |   63 ++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 54 insertions(+), 11 deletions(-)

New commits:
commit c134154de1d96f458c4502372c7d7e4d12a58fb3
Author:     Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Wed Aug 29 14:04:56 2018 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Sep 4 10:05:50 2018 +0200

    kde5: fix initial [re]size of LibO main window
    
    Consider also blank user profile (empty-ish WindowState) and show
    maximized window in that case
    
    Change-Id: Idddcef357cec5f6e6923884ee0c5b454451e8caa
    Reviewed-on: https://gerrit.libreoffice.org/59764
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 3bec15f1ecf4..e81add10ad1e 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -82,6 +82,8 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public SalFrame
     bool isWindow();
     QWindow* windowHandle();
     QScreen* screen();
+    bool isMinimized();
+    bool isMaximized();
 
     void TriggerPaintEvent();
     void TriggerPaintEvent(QRect aRect);
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index f609f3cbaa5b..b6ce6dc5736a 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -35,6 +35,7 @@
 #include <QtWidgets/QStyle>
 #include <QtWidgets/QToolTip>
 #include <QtWidgets/QApplication>
+#include <QtWidgets/QDesktopWidget>
 #include <QtWidgets/QMenuBar>
 #include <QtWidgets/QMainWindow>
 
@@ -118,7 +119,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
     // fake an initial geometry, gets updated via configure event or SetPosSize
     if (m_bDefaultPos || m_bDefaultSize)
     {
-        Size aDefSize = Size(0, 0); // CalcDefaultSize();
+        Size aDefSize = CalcDefaultSize();
         maGeometry.nX = -1;
         maGeometry.nY = -1;
         maGeometry.nWidth = aDefSize.Width();
@@ -161,8 +162,8 @@ void Qt5Frame::TriggerPaintEvent(QRect aRect)
 
 void Qt5Frame::InitSvpSalGraphics(SvpSalGraphics* pSvpSalGraphics)
 {
-    int width = 100;
-    int height = 100;
+    int width = 640;
+    int height = 480;
     m_pSvpGraphics = pSvpSalGraphics;
     m_pSurface.reset(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height));
     m_pSvpGraphics->setSurface(m_pSurface.get(), basegfx::B2IVector(width, height));
@@ -235,10 +236,33 @@ QWindow* Qt5Frame::windowHandle()
 
 QScreen* Qt5Frame::screen()
 {
+    QWindow* winHandle = nullptr;
+
+    if (m_pTopLevel)
+        winHandle = m_pTopLevel->windowHandle();
+    else
+        winHandle = m_pQWidget->windowHandle();
+
+    if (winHandle)
+        return winHandle->screen();
+
+    return nullptr;
+}
+
+bool Qt5Frame::isMinimized()
+{
     if (m_pTopLevel)
-        return m_pTopLevel->windowHandle()->screen();
+        return m_pTopLevel->isMinimized();
     else
-        return m_pQWidget->windowHandle()->screen();
+        return m_pQWidget->isMinimized();
+}
+
+bool Qt5Frame::isMaximized()
+{
+    if (m_pTopLevel)
+        return m_pTopLevel->isMaximized();
+    else
+        return m_pQWidget->isMaximized();
 }
 
 void Qt5Frame::SetTitle(const OUString& rTitle)
@@ -285,6 +309,10 @@ void Qt5Frame::SetExtendedFrameStyle(SalExtStyle /*nExtStyle*/) {}
 void Qt5Frame::Show(bool bVisible, bool /*bNoActivate*/)
 {
     assert(m_pQWidget);
+
+    if (m_bDefaultSize)
+        SetDefaultSize();
+
     if (m_pTopLevel)
         m_pTopLevel->setVisible(bVisible);
     else
@@ -316,10 +344,14 @@ void Qt5Frame::Center()
 Size Qt5Frame::CalcDefaultSize()
 {
     assert(isWindow());
+    QSize qSize(0, 0);
     QScreen* pScreen = screen();
-    if (!pScreen)
-        return Size();
-    return bestmaxFrameSizeForScreenSize(toSize(pScreen->size()));
+    if (pScreen)
+        qSize = pScreen->size();
+    else
+        qSize = QApplication::desktop()->screenGeometry(0).size();
+
+    return bestmaxFrameSizeForScreenSize(toSize(qSize));
 }
 
 void Qt5Frame::SetDefaultSize()
@@ -341,7 +373,10 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt1
         m_bDefaultSize = false;
         if (isChild(false) || !m_pQWidget->isMaximized())
         {
-            m_pQWidget->resize(nWidth, nHeight);
+            if (m_pTopLevel)
+                m_pTopLevel->resize(nWidth, nHeight);
+            else
+                m_pQWidget->resize(nWidth, nHeight);
         }
     }
     else if (m_bDefaultSize)
@@ -420,7 +455,7 @@ void Qt5Frame::SetWindowState(const SalFrameState* pState)
           | WindowStateMask::MaximizedWidth | WindowStateMask::MaximizedHeight;
 
     if ((pState->mnMask & WindowStateMask::State) && (pState->mnState & WindowStateState::Maximized)
-        && (pState->mnMask & nMaxGeometryMask) == nMaxGeometryMask)
+        && !isMaximized() && (pState->mnMask & nMaxGeometryMask) == nMaxGeometryMask)
         m_pQWidget->showMaximized();
     else if (pState->mnMask
              & (WindowStateMask::X | WindowStateMask::Y | WindowStateMask::Width
@@ -449,6 +484,12 @@ void Qt5Frame::SetWindowState(const SalFrameState* pState)
     }
     else if (pState->mnMask & WindowStateMask::State && !isChild())
     {
+        if (pState->mnState & WindowStateState::Maximized && m_pTopLevel)
+        {
+            m_pTopLevel->showMaximized();
+            return;
+        }
+
         if ((pState->mnState & WindowStateState::Minimized) && isWindow())
             m_pQWidget->showMinimized();
         else
@@ -460,7 +501,7 @@ bool Qt5Frame::GetWindowState(SalFrameState* pState)
 {
     pState->mnState = WindowStateState::Normal;
     pState->mnMask = WindowStateMask::State;
-    if (m_pQWidget->isMinimized() || !m_pQWidget->windowHandle())
+    if (isMinimized() /*|| !windowHandle()*/)
         pState->mnState |= WindowStateState::Minimized;
     else if (m_pQWidget->isMaximized())
     {


More information about the Libreoffice-commits mailing list