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

Katarina Behrens (via logerrit) logerrit at kemper.freedesktop.org
Fri May 31 11:22:52 UTC 2019


 vcl/inc/qt5/Qt5Frame.hxx |    2 +
 vcl/qt5/Qt5Frame.cxx     |   75 +++++++++++++++++++++++++++++++++++++----------
 2 files changed, 62 insertions(+), 15 deletions(-)

New commits:
commit 6f613f973dcb86dbebc212bc466fbaa2b002655b
Author:     Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Wed May 29 19:01:28 2019 +0200
Commit:     Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Fri May 31 13:22:10 2019 +0200

    tdf#124484: resize slideshow window so it spans all displays
    
    Change-Id: I55b4ab8ec5059110525c5194e1133c65bbd07fec
    Reviewed-on: https://gerrit.libreoffice.org/73183
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index a42a95aac3bd..16743edc0fc6 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -83,6 +83,8 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame
     bool m_bDefaultSize;
     bool m_bDefaultPos;
     bool m_bFullScreen;
+    bool m_bFullScreenSpanAll;
+    sal_uInt32 m_nRestoreScreen;
     QRect m_aRestoreGeometry;
 
     void Center();
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 386fa08052c7..6d19d825fa1c 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -60,6 +60,28 @@ static void SvpDamageHandler(void* handle, sal_Int32 nExtentsX, sal_Int32 nExten
     pThis->Damage(nExtentsX, nExtentsY, nExtentsWidth, nExtentsHeight);
 }
 
+namespace
+{
+sal_Int32 screenNumber(const QScreen* pScreen)
+{
+    const QList<QScreen*> screens = QApplication::screens();
+
+    sal_Int32 nScreen = 0;
+    bool bFound = false;
+    for (const QScreen* pCurScreen : screens)
+    {
+        if (pScreen == pCurScreen)
+        {
+            bFound = true;
+            break;
+        }
+        nScreen++;
+    }
+
+    return bFound ? nScreen : -1;
+}
+}
+
 Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
     : m_pTopLevel(nullptr)
     , m_bUseCairo(bUseCairo)
@@ -74,6 +96,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
     , m_bDefaultSize(true)
     , m_bDefaultPos(true)
     , m_bFullScreen(false)
+    , m_bFullScreenSpanAll(false)
 {
     Qt5Instance* pInst = static_cast<Qt5Instance*>(GetSalData()->m_pInstance);
     pInst->insertFrame(this);
@@ -145,6 +168,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)
     {
+        maGeometry.nDisplayScreenNumber = 0;
         Size aDefSize = CalcDefaultSize();
         maGeometry.nX = -1;
         maGeometry.nY = -1;
@@ -431,16 +455,25 @@ void Qt5Frame::Center()
 Size Qt5Frame::CalcDefaultSize()
 {
     assert(isWindow());
-    QSize qSize(0, 0);
-    QScreen* pScreen = screen();
-    if (pScreen)
-        qSize = pScreen->size();
-    else
-        qSize = QApplication::desktop()->screenGeometry(0).size();
 
-    Size aSize = toSize(qSize);
+    Size aSize;
     if (!m_bFullScreen)
-        aSize = bestmaxFrameSizeForScreenSize(aSize);
+    {
+        const QScreen* pScreen = screen();
+        aSize = bestmaxFrameSizeForScreenSize(
+            toSize(pScreen ? pScreen->size() : QApplication::desktop()->screenGeometry(0).size()));
+    }
+    else
+    {
+        if (!m_bFullScreenSpanAll)
+            aSize = toSize(
+                QApplication::desktop()->screenGeometry(maGeometry.nDisplayScreenNumber).size());
+        else
+        {
+            int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0));
+            aSize = toSize(QApplication::screens()[nLeftScreen]->availableVirtualGeometry().size());
+        }
+    }
 
     return aSize;
 }
@@ -644,7 +677,11 @@ void Qt5Frame::ShowFullScreen(bool bFullScreen, sal_Int32 nScreen)
     // only top-level windows can go fullscreen
     assert(m_pTopLevel);
 
+    if (m_bFullScreen == bFullScreen)
+        return;
+
     m_bFullScreen = bFullScreen;
+    m_bFullScreenSpanAll = m_bFullScreen && (nScreen < 0);
 
     // show it if it isn't shown yet
     if (!isWindow())
@@ -653,15 +690,18 @@ void Qt5Frame::ShowFullScreen(bool bFullScreen, sal_Int32 nScreen)
     if (m_bFullScreen)
     {
         m_aRestoreGeometry = m_pTopLevel->geometry();
-        // do that before going fullscreen
-        SetScreenNumber(nScreen);
-        windowHandle()->showFullScreen();
+        m_nRestoreScreen = maGeometry.nDisplayScreenNumber;
+        SetScreenNumber(m_bFullScreenSpanAll ? m_nRestoreScreen : nScreen);
+        if (!m_bFullScreenSpanAll)
+            windowHandle()->showFullScreen();
+        else
+            windowHandle()->showNormal();
     }
     else
     {
+        SetScreenNumber(m_nRestoreScreen);
         windowHandle()->showNormal();
         m_pTopLevel->setGeometry(m_aRestoreGeometry);
-        m_aRestoreGeometry = QRect();
     }
 }
 
@@ -1101,23 +1141,25 @@ void Qt5Frame::SetScreenNumber(unsigned int nScreen)
         if (pWindow)
         {
             QList<QScreen*> screens = QApplication::screens();
-            if (static_cast<int>(nScreen) < screens.size())
+            if (static_cast<int>(nScreen) < screens.size() || m_bFullScreenSpanAll)
             {
-                bool bSpanAllScreens = (nScreen == static_cast<unsigned int>(-1));
                 QRect screenGeo;
 
-                if (!bSpanAllScreens)
+                if (!m_bFullScreenSpanAll)
                 {
                     screenGeo = QApplication::desktop()->screenGeometry(nScreen);
                     pWindow->setScreen(QApplication::screens()[nScreen]);
                 }
                 else // special case: fullscreen over all available screens
                 {
+                    assert(m_bFullScreen);
                     // left-most screen
                     int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0));
                     // entire virtual desktop
                     screenGeo = QApplication::screens()[nLeftScreen]->availableVirtualGeometry();
                     pWindow->setScreen(QApplication::screens()[nLeftScreen]);
+                    pWindow->setGeometry(screenGeo);
+                    nScreen = nLeftScreen;
                 }
 
                 // setScreen by itself has no effect, explicitly move the widget to
@@ -1130,7 +1172,10 @@ void Qt5Frame::SetScreenNumber(unsigned int nScreen)
                 // index outta bounds, use primary screen
                 QScreen* primaryScreen = QApplication::primaryScreen();
                 pWindow->setScreen(primaryScreen);
+                nScreen = static_cast<sal_uInt32>(screenNumber(primaryScreen));
             }
+
+            maGeometry.nDisplayScreenNumber = nScreen;
         }
     }
 }


More information about the Libreoffice-commits mailing list