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 <m.weghorn@posteo.de>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -177,6 +180,9 @@ public:
|
||||
|
||||
bool DoExecute(int& nExitCode) override;
|
||||
void DoQuit() override;
|
||||
|
||||
QtFrame* activePopup() const { return m_pActivePopup; }
|
||||
void setActivePopup(QtFrame*);
|
||||
};
|
||||
|
||||
inline QtInstance* GetQtInstance() { return static_cast<QtInstance*>(GetSalInstance()); }
|
||||
|
@@ -73,6 +73,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;
|
||||
|
@@ -225,6 +225,7 @@ QtInstance::QtInstance(std::unique_ptr<QApplication>& 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);
|
||||
@@ -740,6 +741,12 @@ void QtInstance::DoQuit()
|
||||
QApplication::quit();
|
||||
}
|
||||
|
||||
void QtInstance::setActivePopup(QtFrame* pFrame)
|
||||
{
|
||||
assert(!pFrame || pFrame->isPopup());
|
||||
m_pActivePopup = pFrame;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
VCLPLUG_QT_PUBLIC SalInstance* create_SalInstance()
|
||||
{
|
||||
|
@@ -316,9 +316,17 @@ 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())
|
||||
GetQtInstance()->setActivePopup(&m_rFrame);
|
||||
m_rFrame.CallCallback(SalEvent::Paint, &aPaintEvt);
|
||||
}
|
||||
|
||||
void QtWidget::hideEvent(QHideEvent*)
|
||||
{
|
||||
if (m_rFrame.isPopup() && GetQtInstance()->activePopup() == &m_rFrame)
|
||||
GetQtInstance()->setActivePopup(nullptr);
|
||||
}
|
||||
|
||||
void QtWidget::closeEvent(QCloseEvent* /*pEvent*/)
|
||||
{
|
||||
m_rFrame.CallCallback(SalEvent::Close, nullptr);
|
||||
@@ -627,11 +635,10 @@ 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 on the active popup is wrong due to our fake popup, 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())
|
||||
const QtFrame* pPopupFrame = GetQtInstance()->activePopup();
|
||||
if (!rFrame.m_aTooltipText.isEmpty() && (!pPopupFrame || pPopupFrame == &rFrame))
|
||||
QToolTip::showText(QCursor::pos(), toQString(rFrame.m_aTooltipText), &rWidget,
|
||||
rFrame.m_aTooltipArea);
|
||||
else
|
||||
|
Reference in New Issue
Block a user