summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-07-19 22:13:21 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2021-07-20 15:20:43 +0200
commit63f92f185b78db5a575da58efac3f94a8cb5a5f6 (patch)
treef4af8f94c4e6ba688b1ea1cb16f196cd782d0bd9 /vcl
parent862fdb98ca271b60a831cd5420fd16d5f9c1c747 (diff)
Qt5 fix Qt::Popup window handling
I guess to get popup windows somehow working, they were matched to Qt::ToolTip. Fixing that by removing SalFrameStyleFlags::FLOAT from the tooltip check, resulted in rather bizarre bahviour. The Qt::Popup window is modal, as documented, but wouldn't close when clicked outside, like normal popups. And I neither got any mouse button or focus events, just some leave or enter. The only way to interact with anything again, was by clicking somewhere on the popup where it can't take focus... and it has nothing to do with the transition setting either. In the end it turned out that Qt::StrongFocus prevented the mouse events to happen. Even without it the widget accepts mouse and keyboard focus, so nothing seems lost by omitting that for the Qt::Popup case; hopefully... Change-Id: Icda7bbe87268293a400fe0da551d2804675d4c2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119236 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/Qt5Frame.cxx2
-rw-r--r--vcl/qt5/Qt5Widget.cxx12
2 files changed, 11 insertions, 3 deletions
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 322f293828cd..02032d149d29 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -144,7 +144,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
else if ((nStyle & SalFrameStyleFlags::FLOAT)
&& (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION))
aWinFlags |= Qt::Tool | Qt::FramelessWindowHint;
- else if (nStyle & (SalFrameStyleFlags::FLOAT | SalFrameStyleFlags::TOOLTIP))
+ else if (nStyle & SalFrameStyleFlags::TOOLTIP)
aWinFlags |= Qt::ToolTip;
else if ((nStyle & SalFrameStyleFlags::FLOAT)
&& !(nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION))
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 2e97132f5e75..93da76ecad76 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -177,7 +177,14 @@ void Qt5Widget::handleMouseButtonEvent(const Qt5Frame& rFrame, const QMouseEvent
rFrame.CallCallback(nEventType, &aEvent);
}
-void Qt5Widget::mousePressEvent(QMouseEvent* pEvent) { handleMousePressEvent(m_rFrame, pEvent); }
+void Qt5Widget::mousePressEvent(QMouseEvent* pEvent)
+{
+ if ((windowFlags() & Qt::Popup)
+ && !geometry().translated(geometry().topLeft() * -1).contains(pEvent->pos()))
+ close();
+ else
+ handleMousePressEvent(m_rFrame, pEvent);
+}
void Qt5Widget::mouseReleaseEvent(QMouseEvent* pEvent)
{
@@ -601,7 +608,8 @@ Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f)
{
create();
setMouseTracking(true);
- setFocusPolicy(Qt::StrongFocus);
+ if (!(f & Qt::Popup))
+ setFocusPolicy(Qt::StrongFocus);
}
static ExtTextInputAttr lcl_MapUndrelineStyle(QTextCharFormat::UnderlineStyle us)