vcl/qt5/QtFrame.cxx |   53 +++++++++++++++++++++++-----------------------------
 1 file changed, 24 insertions(+), 29 deletions(-)

New commits:
commit be0d89bea01fe89f619f701cd4e5e40420c9a1e2
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Sep 27 11:06:55 2024 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Sep 28 09:34:13 2024 +0200

    qt: Query screen on demand in QtFrame
    
    Similar to how
    
        Change-Id: Ifa0eff271c7d3fa2b6db9bdc1669e62333bd3094
        Author: Michael Weghorn <[email protected]>
        Date:   Thu Sep 26 18:22:12 2024 +0200
    
            tdf#160837 qt: Rely on toolkit for frame positions, drop menubar 
hack
    
    implements it for the frame/widget position and size,
    also retrieve the current screen number by querying
    the QWidget for it's current screen instead of doing
    own bookkeeping of the current screen in SalFrame::maGeometry
    by getting/setting it using `SalFrameGeometry::{getS,s}creen.
    
    Only set it in the returend SalGeometry when
    the current SalGeometry explicitly gets requested
    by calling QtFrame::GetUnmirroredGeometry.
    
    Change-Id: Icaf712c956297dbc7a774bbd995d42eb8a63a1bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174034
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 03a04b459244..09807c941638 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -474,7 +474,7 @@ Size QtFrame::CalcDefaultSize()
     {
         if (!m_bFullScreenSpanAll)
         {
-            aSize = 
toSize(QGuiApplication::screens().at(maGeometry.screen())->size());
+            aSize = toSize(screen()->size());
         }
         else
         {
@@ -575,6 +575,8 @@ SalFrameGeometry QtFrame::GetUnmirroredGeometry() const
     aGeometry.setWidth(m_pQWidget->width() * fRatio);
     aGeometry.setHeight(m_pQWidget->height() * fRatio);
 
+    aGeometry.setScreen(std::max(sal_Int32(0), screenNumber()));
+
     return aGeometry;
 }
 
@@ -712,7 +714,7 @@ void QtFrame::ShowFullScreen(bool bFullScreen, sal_Int32 
nScreen)
     if (m_bFullScreen)
     {
         m_aRestoreGeometry = m_pTopLevel->geometry();
-        m_nRestoreScreen = maGeometry.screen();
+        m_nRestoreScreen = std::max(sal_Int32(0), screenNumber());
         SetScreenNumber(m_bFullScreenSpanAll ? m_nRestoreScreen : nScreen);
         if (!m_bFullScreenSpanAll)
             windowHandle()->showFullScreen();
@@ -1310,14 +1312,11 @@ void QtFrame::SetScreenNumber(unsigned int nScreen)
         screenGeo = pScreen->availableVirtualGeometry();
         pWindow->setScreen(pScreen);
         pWindow->setGeometry(screenGeo);
-        nScreen = screenNumber();
     }
 
     // setScreen by itself has no effect, explicitly move the widget to
     // the new screen
     asChild()->move(screenGeo.topLeft());
-
-    maGeometry.setScreen(nScreen);
 }
 
 void QtFrame::SetApplicationID(const OUString& rWMClass)
commit 95283b72cf60208fb1df0fd1eb5ec021cd43eb9e
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Sep 27 10:11:02 2024 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Sep 28 09:34:06 2024 +0200

    qt: Just ignore request to set frame to invalid screen number
    
    Instead of setting the screen to the primary screen,
    just ignore the request when QtFrame::SetScreenNumber
    gets called with an invalid screen number.
    
    The previous handling was introduced in
    
        commit f806a2832aee62efc0e0404f7c24d53aaaf814d0
        Date:   Mon Oct 22 16:35:21 2018 +0200
    
            tdf#120451: Use primary screen if requested screen doesn't exist
    
    to fix a crash, but just ignoring the request
    avoids crashing, too.
    
    (`git show --ignore-space-change` helps to see
    the "actual" change more easily.)
    
    Change-Id: I272ec64f89ef835161fa68c7fdc8cd0e407b7495
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174033
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 1c2e81938ecb..03a04b459244 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -1288,39 +1288,35 @@ void QtFrame::SetScreenNumber(unsigned int nScreen)
         return;
 
     QList<QScreen*> screens = QApplication::screens();
-    if (static_cast<int>(nScreen) < screens.size() || m_bFullScreenSpanAll)
+    if (static_cast<int>(nScreen) >= screens.size() && !m_bFullScreenSpanAll)
     {
-        QRect screenGeo;
+        SAL_WARN("vcl.qt", "Ignoring request to set invalid screen number");
+        return;
+    }
 
-        if (!m_bFullScreenSpanAll)
-        {
-            screenGeo = QGuiApplication::screens().at(nScreen)->geometry();
-            pWindow->setScreen(QApplication::screens().at(nScreen));
-        }
-        else // special case: fullscreen over all available screens
-        {
-            assert(m_bFullScreen);
-            // left-most screen
-            QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0));
-            // entire virtual desktop
-            screenGeo = pScreen->availableVirtualGeometry();
-            pWindow->setScreen(pScreen);
-            pWindow->setGeometry(screenGeo);
-            nScreen = screenNumber();
-        }
+    QRect screenGeo;
 
-        // setScreen by itself has no effect, explicitly move the widget to
-        // the new screen
-        asChild()->move(screenGeo.topLeft());
+    if (!m_bFullScreenSpanAll)
+    {
+        screenGeo = QGuiApplication::screens().at(nScreen)->geometry();
+        pWindow->setScreen(QApplication::screens().at(nScreen));
     }
-    else
+    else // special case: fullscreen over all available screens
     {
-        // index outta bounds, use primary screen
-        QScreen* primaryScreen = QApplication::primaryScreen();
-        pWindow->setScreen(primaryScreen);
-        nScreen = static_cast<sal_uInt32>(screenNumber());
+        assert(m_bFullScreen);
+        // left-most screen
+        QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0));
+        // entire virtual desktop
+        screenGeo = pScreen->availableVirtualGeometry();
+        pWindow->setScreen(pScreen);
+        pWindow->setGeometry(screenGeo);
+        nScreen = screenNumber();
     }
 
+    // setScreen by itself has no effect, explicitly move the widget to
+    // the new screen
+    asChild()->move(screenGeo.topLeft());
+
     maGeometry.setScreen(nScreen);
 }
 

Reply via email to