summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2019-05-29 19:01:28 +0200
committerKatarina Behrens <Katarina.Behrens@cib.de>2019-05-31 13:22:10 +0200
commit6f613f973dcb86dbebc212bc466fbaa2b002655b (patch)
tree32c03ec6fd63cf4b353cc8d711a91882c6158d15 /vcl/qt5
parent6f74de514e6a384b549ce2136037e03a60b1c54f (diff)
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@cib.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/Qt5Frame.cxx75
1 files changed, 60 insertions, 15 deletions
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;
}
}
}