vcl/inc/qt5/QtFrame.hxx | 6 +++++- vcl/inc/qt5/QtWidget.hxx | 1 + vcl/qt5/QtFrame.cxx | 21 ++++++++++++++------- vcl/qt5/QtWidget.cxx | 6 ++++++ 4 files changed, 26 insertions(+), 8 deletions(-)
New commits: commit 76de12a19bd90c0ed0d7a6a85502d3dccdbeba4e Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Thu Apr 7 01:07:43 2022 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Fri Apr 8 19:48:56 2022 +0200 tdf#141578 Qt handle QtFrame screen changes LO doesn't provide any way to notify screen changes / scaling factors of a window and in fact doesn't really handle scaling factors in VCL. The QWidget doesn't receive a resize event, because it's size doesn't change, just the scaling factor. So we trigger a faked resize on QWindow::screenChanged signal. Change-Id: I6928c4c62d1c0995c70fea0088cff17849bcd1d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132650 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins (cherry picked from commit 881cfbf77567194f5016a961d1c3db869734d68b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132740 Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 59ec093a2ed6..5ffaacf3ad94 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -25,6 +25,7 @@ #include <vclpluginapi.h> #include "QtTools.hxx" +#include "QtWidget.hxx" #include <headless/svpgdi.hxx> #include <vcl/svapp.hxx> @@ -70,7 +71,7 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame friend class QtWidget; - QWidget* m_pQWidget; + QtWidget* m_pQWidget; QtMainWindow* m_pTopLevel; const bool m_bUseCairo; @@ -134,6 +135,9 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame void fixICCCMwindowGroup(); +private Q_SLOTS: + void screenChanged(QScreen*); + public: QtFrame(QtFrame* pParent, SalFrameStyleFlags nSalFrameStyle, bool bUseCairo); virtual ~QtFrame() override; diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx index e2a22d3c9f18..575cef11014f 100644 --- a/vcl/inc/qt5/QtWidget.hxx +++ b/vcl/inc/qt5/QtWidget.hxx @@ -85,6 +85,7 @@ public: QtFrame& frame() const { return m_rFrame; } void endExtTextInput(); + void fakeResize(); static bool handleEvent(QtFrame&, const QWidget&, QEvent*); // key events might be propagated further down => call base on false diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index bcd95494dabd..c78417b3070a 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -30,7 +30,6 @@ #include <QtSystem.hxx> #include <QtTools.hxx> #include <QtTransferable.hxx> -#include <QtWidget.hxx> #include <QtCore/QMimeData> #include <QtCore/QPoint> @@ -178,10 +177,12 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) else m_pQWidget = new QtWidget(*this, aWinFlags); + QWindow* pChildWindow = windowHandle(); + connect(pChildWindow, &QWindow::screenChanged, this, &QtFrame::screenChanged); + if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG)) { - QWindow* pParentWindow = pParent->GetQWidget()->window()->windowHandle(); - QWindow* pChildWindow = asChild()->window()->windowHandle(); + QWindow* pParentWindow = pParent->windowHandle(); if (pParentWindow && pChildWindow && (pParentWindow != pChildWindow)) pChildWindow->setTransientParent(pParentWindow); } @@ -193,6 +194,8 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) fixICCCMwindowGroup(); } +void QtFrame::screenChanged(QScreen*) { m_pQWidget->fakeResize(); } + void QtFrame::FillSystemEnvData(SystemEnvData& rData, sal_IntPtr pWindow, QWidget* pWidget) { if (QGuiApplication::platformName() == "wayland") @@ -343,7 +346,12 @@ bool QtFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData) return true; } -QWidget* QtFrame::asChild() const { return m_pTopLevel ? m_pTopLevel : m_pQWidget; } +QWidget* QtFrame::asChild() const +{ + if (m_pTopLevel) + return m_pTopLevel; + return m_pQWidget; +} qreal QtFrame::devicePixelRatioF() const { return asChild()->devicePixelRatioF(); } @@ -864,9 +872,8 @@ void QtFrame::SetInputContext(SalInputContext* pContext) void QtFrame::EndExtTextInput(EndExtTextInputFlags /*nFlags*/) { - QtWidget* pQtWidget = static_cast<QtWidget*>(m_pQWidget); - if (pQtWidget) - pQtWidget->endExtTextInput(); + if (m_pQWidget) + m_pQWidget->endExtTextInput(); } OUString QtFrame::GetKeyName(sal_uInt16 nKeyCode) diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx index ab8bf2dc0017..1fe2ce9a7159 100644 --- a/vcl/qt5/QtWidget.cxx +++ b/vcl/qt5/QtWidget.cxx @@ -135,6 +135,12 @@ void QtWidget::resizeEvent(QResizeEvent* pEvent) m_rFrame.CallCallback(SalEvent::Resize, nullptr); } +void QtWidget::fakeResize() +{ + QResizeEvent aEvent(size(), QSize()); + resizeEvent(&aEvent); +} + void QtWidget::fillSalAbstractMouseEvent(const QtFrame& rFrame, const QInputEvent* pQEvent, const QPoint& rPos, Qt::MouseButtons eButtons, int nWidth, SalAbstractMouseEvent& aSalEvent)