vcl/inc/qt5/QtInstance.hxx | 8 ++++++++ vcl/qt5/QtInstance.cxx | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
New commits: commit e49d774fd2bb5ddf35a47368f36980d5e0d32ad3 Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Sun Jan 16 10:14:47 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Jan 16 18:22:44 2022 +0100 Qt notify LO of many QScreen related events LO just has a single display event, SalEvent::DisplayChanged, Qt has a multitude. So this will generate multiple LO notifications. I don't see any reasonable way to prevent that. Doesn't seem a problem here. Change-Id: I2f11e53765869a4ca292a1d337347e4e7470e3c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128474 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> (cherry picked from commit ced4cde59eb51e4364daf69520a184b55c2c54db) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128434 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx index 009b9ae8c312..9a9853a7a2ce 100644 --- a/vcl/inc/qt5/QtInstance.hxx +++ b/vcl/inc/qt5/QtInstance.hxx @@ -75,6 +75,12 @@ private Q_SLOTS: static void deleteObjectLater(QObject* pObject); static void localeChanged(); + void orientationChanged(Qt::ScreenOrientation); + void primaryScreenChanged(QScreen*); + void screenAdded(QScreen*); + void screenRemoved(QScreen*); + void virtualGeometryChanged(const QRect&); + Q_SIGNALS: bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents); void deleteObjectLaterSignal(QObject* pObject); @@ -86,6 +92,8 @@ protected: bool useCairo() const { return m_bUseCairo; } // encodes cairo usage and Qt platform name into the ToolkitName OUString constructToolkitID(std::u16string_view sTKname); + void connectQScreenSignals(const QScreen*); + void notifyDisplayChanged(); public: explicit QtInstance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo = false); diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index 29a7d0e4ddf7..d252109e122a 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -40,6 +40,7 @@ #include <QtCore/QAbstractEventDispatcher> #include <QtCore/QThread> +#include <QtGui/QScreen> #include <QtWidgets/QApplication> #include <QtWidgets/QWidget> @@ -248,6 +249,12 @@ QtInstance::QtInstance(std::unique_ptr<QApplication>& pQApp, bool bUseCairo) connect(QGuiApplication::inputMethod(), &QInputMethod::localeChanged, this, &QtInstance::localeChanged); + for (const QScreen* pCurScreen : QApplication::screens()) + connectQScreenSignals(pCurScreen); + connect(qApp, &QGuiApplication::primaryScreenChanged, this, &QtInstance::primaryScreenChanged); + connect(qApp, &QGuiApplication::screenAdded, this, &QtInstance::screenAdded); + connect(qApp, &QGuiApplication::screenRemoved, this, &QtInstance::screenRemoved); + #ifndef EMSCRIPTEN m_bSupportsOpenGL = true; #endif @@ -602,6 +609,35 @@ void* QtInstance::CreateGStreamerSink(const SystemChildWindow* pWindow) #endif } +void QtInstance::connectQScreenSignals(const QScreen* pScreen) +{ + connect(pScreen, &QScreen::orientationChanged, this, &QtInstance::orientationChanged); + connect(pScreen, &QScreen::virtualGeometryChanged, this, &QtInstance::virtualGeometryChanged); +} + +void QtInstance::notifyDisplayChanged() +{ + SolarMutexGuard aGuard; + SalFrame* pAnyFrame = anyFrame(); + if (pAnyFrame) + pAnyFrame->CallCallback(SalEvent::DisplayChanged, nullptr); +} + +void QtInstance::orientationChanged(Qt::ScreenOrientation) { notifyDisplayChanged(); } + +void QtInstance::primaryScreenChanged(QScreen*) { notifyDisplayChanged(); } + +void QtInstance::screenAdded(QScreen* pScreen) +{ + connectQScreenSignals(pScreen); + if (QApplication::screens().size() == 1) + notifyDisplayChanged(); +} + +void QtInstance::screenRemoved(QScreen*) { notifyDisplayChanged(); } + +void QtInstance::virtualGeometryChanged(const QRect&) { notifyDisplayChanged(); } + void QtInstance::AllocFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv, std::unique_ptr<int>& rFakeArgc, std::vector<FreeableCStr>& rFakeArgvFreeable)