vcl/qt5/Qt5Frame.cxx  |    2 +-
 vcl/qt5/Qt5Widget.cxx |   12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 63f92f185b78db5a575da58efac3f94a8cb5a5f6
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Mon Jul 19 22:13:21 2021 +0200
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Tue Jul 20 15:20:43 2021 +0200

    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 <glo...@fbihome.de>

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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to