[Libreoffice-commits] core.git: Branch 'libreoffice-7-3-3' - vcl/inc vcl/qt5
vcl/inc/qt5/QtInstance.hxx |6 ++ vcl/inc/qt5/QtWidget.hxx |1 + vcl/qt5/QtInstance.cxx |7 +++ vcl/qt5/QtWidget.cxx | 20 4 files changed, 30 insertions(+), 4 deletions(-) New commits: commit 6603bd259d6e8abbb6af68fae0eba3f4d876b4f8 Author: Jan-Marek Glogowski AuthorDate: Thu Apr 21 10:56:42 2022 +0200 Commit: Christian Lohmaier CommitDate: Wed Apr 27 12:49:39 2022 +0200 tdf#148699 Qt track the active / shown popup I have no idea, if there can be multiple active popups in LO in some way. There can be multiple FloatingWindow and gtk does count them in m_nFloats... There is a whole lot going on in gtk3 related to isFloatGrabWindow(), with "funny" comments like: // FIXME: find out who the hell steals the focus from our frame So this goes with some "optimistic" approach: there is just one active popup, so we can track it in QtInstance. It WFM... Change-Id: I9778587696e1ad9e641dba4f102e2e921266eee6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133249 Tested-by: Jenkins Reviewed-by: Michael Weghorn (cherry picked from commit 347622a98f512dae709f938a85498dcdcf9f225a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133260 Reviewed-by: Jan-Marek Glogowski (cherry picked from commit 06c51d61e4a16057f945effe85b1ff9457f8cffb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133276 Reviewed-by: Christian Lohmaier Tested-by: Christian Lohmaier diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx index 9a9853a7a2ce..fd111bb22abe 100644 --- a/vcl/inc/qt5/QtInstance.hxx +++ b/vcl/inc/qt5/QtInstance.hxx @@ -35,6 +35,7 @@ #include "QtFilePicker.hxx" +class QtFrame; class QtTimer; class QApplication; @@ -67,6 +68,8 @@ class VCLPLUG_QT_PUBLIC QtInstance : public QObject, Timer m_aUpdateStyleTimer; bool m_bUpdateFonts; +QtFrame* m_pActivePopup; + DECL_DLLPRIVATE_LINK(updateStyleHdl, Timer*, void); void AfterAppInit() override; @@ -172,6 +175,9 @@ public: void UpdateStyle(bool bFontsChanged); void* CreateGStreamerSink(const SystemChildWindow*) override; + +QtFrame* activePopup() const { return m_pActivePopup; } +void setActivePopup(QtFrame*); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx index 878c8b1229ce..9482d8c7b205 100644 --- a/vcl/inc/qt5/QtWidget.hxx +++ b/vcl/inc/qt5/QtWidget.hxx @@ -72,6 +72,7 @@ class QtWidget : public QWidget virtual void paintEvent(QPaintEvent*) override; virtual void resizeEvent(QResizeEvent*) override; virtual void showEvent(QShowEvent*) override; +virtual void hideEvent(QHideEvent*) override; virtual void wheelEvent(QWheelEvent*) override; virtual void closeEvent(QCloseEvent*) override; virtual void changeEvent(QEvent*) override; diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index d252109e122a..247001443020 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -223,6 +223,7 @@ QtInstance::QtInstance(std::unique_ptr& pQApp, bool bUseCairo) , m_pQApplication(std::move(pQApp)) , m_aUpdateStyleTimer("vcl::qt5 m_aUpdateStyleTimer") , m_bUpdateFonts(false) +, m_pActivePopup(nullptr) { ImplSVData* pSVData = ImplGetSVData(); const OUString sToolkit = "qt" + OUString::number(QT_VERSION_MAJOR); @@ -722,6 +723,12 @@ std::unique_ptr QtInstance::CreateQApplication(int& nArgc, char** return pQApp; } +void QtInstance::setActivePopup(QtFrame* pFrame) +{ +assert(!pFrame || pFrame->isPopup()); +m_pActivePopup = pFrame; +} + extern "C" { VCLPLUG_QT_PUBLIC SalInstance* create_SalInstance() { diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx index 017249b05434..663e9b531dbc 100644 --- a/vcl/qt5/QtWidget.cxx +++ b/vcl/qt5/QtWidget.cxx @@ -282,9 +282,21 @@ void QtWidget::showEvent(QShowEvent*) // sequence from QtFrame::SetModal, if the frame was already set visible, // resulting in a hidden / unmapped window SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height()); +if (m_rFrame.isPopup()) +{ +auto* pQtInst(static_cast(GetSalData()->m_pInstance)); +pQtInst->setActivePopup(_rFrame); +} m_rFrame.CallCallback(SalEvent::Paint, ); } +void QtWidget::hideEvent(QHideEvent*) +{ +auto* pQtInst(static_cast(GetSalData()->m_pInstance)); +if (m_rFrame.isPopup() && pQtInst->activePopup() == _rFrame) +pQtInst->setActivePopup(nullptr); +} + void QtWidget::closeEvent(QCloseEvent* /*pEvent*/) { m_rFrame.CallCallback(SalEvent::Close, nullptr); @@ -592,11 +604,11 @@ bool QtWidget::handleEvent(QtFrame& rFrame, QWidget& rWidget, QEvent* pEvent) } else if (pEvent->type() == QEvent::ToolTip) { -// Qt's POV on focus is wrong for our fake popup windows, so check LO's state. +// Qt's POV
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3-3' - vcl/inc vcl/qt5
vcl/inc/qt5/QtFrame.hxx |3 +++ vcl/inc/qt5/QtWidget.hxx |2 +- vcl/qt5/QtFrame.cxx |8 +++- vcl/qt5/QtWidget.cxx | 19 ++- 4 files changed, 29 insertions(+), 3 deletions(-) New commits: commit 421abb60875e88432f5d0c6ad4d6dbd8e483647f Author: Jan-Marek Glogowski AuthorDate: Tue Apr 12 00:29:56 2022 +0200 Commit: Michael Weghorn CommitDate: Tue Apr 19 12:58:53 2022 +0200 tdf#148115 Qt handle tooltips via event loop Instead of calling QToolTip::showText directly from LO, this defers showing the tooltip to the QEvent processing, which takes the tooltip timeouts into account. So tooltips are shown with a slight delay, therefore they happen less fast on mouse move, reducing / avoiding artifacts of fast changing windows. This unfortunately comes with yet an other hack in the area of our fake popup windows... New handling is based on the code of the Qt Tool Tips example. Change-Id: I42634ad36dd12171c30f52f07a02a88d3c48a718 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132841 Reviewed-by: Michael Weghorn Tested-by: Jenkins (cherry picked from commit af6dd54d53eee0d0de1164bff0a77c6b433b3935) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132864 Reviewed-by: Jan-Marek Glogowski (cherry picked from commit 7fc871299080427587307932c505d3ae93d6a357) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133040 Reviewed-by: Adolfo Jayme Barrientos Reviewed-by: Michael Stahl Tested-by: Michael Stahl diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 5ffaacf3ad94..23a4fd9887f1 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -111,6 +111,9 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame LanguageType m_nInputLanguage; +OUString m_aTooltipText; +QRect m_aTooltipArea; + void SetDefaultPos(); Size CalcDefaultSize(); void SetDefaultSize(); diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx index 575cef11014f..878c8b1229ce 100644 --- a/vcl/inc/qt5/QtWidget.hxx +++ b/vcl/inc/qt5/QtWidget.hxx @@ -87,7 +87,7 @@ public: void endExtTextInput(); void fakeResize(); -static bool handleEvent(QtFrame&, const QWidget&, QEvent*); +static bool handleEvent(QtFrame&, QWidget&, QEvent*); // key events might be propagated further down => call base on false static inline bool handleKeyReleaseEvent(QtFrame&, const QWidget&, QKeyEvent*); // mouse events are always accepted diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index c78417b3070a..f6f4b6c2611d 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -175,7 +175,12 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) m_pTopLevel->setFocusProxy(m_pQWidget); } else +{ m_pQWidget = new QtWidget(*this, aWinFlags); +// from Qt's POV the popup window doesn't have the input focus, so we must force tooltips... +if (isPopup()) +m_pQWidget->setAttribute(Qt::WA_AlwaysShowToolTips); +} QWindow* pChildWindow = windowHandle(); connect(pChildWindow, ::screenChanged, this, ::screenChanged); @@ -855,7 +860,8 @@ bool QtFrame::ShowTooltip(const OUString& rText, const tools::Rectangle& rHelpAr QRect aHelpArea(toQRect(rHelpArea)); if (QGuiApplication::isRightToLeft()) aHelpArea.moveLeft(maGeometry.nWidth - aHelpArea.width() - aHelpArea.left() - 1); -QToolTip::showText(QCursor::pos(), toQString(rText), m_pQWidget, aHelpArea); +m_aTooltipText = rText; +m_aTooltipArea = aHelpArea; return true; } diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx index 1fe2ce9a7159..017249b05434 100644 --- a/vcl/qt5/QtWidget.cxx +++ b/vcl/qt5/QtWidget.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -562,7 +563,7 @@ bool QtWidget::handleKeyEvent(QtFrame& rFrame, const QWidget& rWidget, QKeyEvent return bStopProcessingKey; } -bool QtWidget::handleEvent(QtFrame& rFrame, const QWidget& rWidget, QEvent* pEvent) +bool QtWidget::handleEvent(QtFrame& rFrame, QWidget& rWidget, QEvent* pEvent) { if (pEvent->type() == QEvent::ShortcutOverride) { @@ -589,6 +590,22 @@ bool QtWidget::handleEvent(QtFrame& rFrame, const QWidget& rWidget, QEvent* pEve ButtonKeyState::Pressed)) return true; } +else if (pEvent->type() == QEvent::ToolTip) +{ +// Qt's POV on focus is wrong for our fake popup windows, so check LO's state. +// Otherwise Qt will continue handling ToolTip events from the "parent" window. +const vcl::Window* pFocusWin = Application::GetFocusWindow(); +if (!rFrame.m_aTooltipText.isEmpty() && pFocusWin +&& pFocusWin->GetFrameWindow() == rFrame.GetWindow()) +