[Libreoffice-commits] core.git: vcl/qt5

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Mon May 13 17:45:24 UTC 2019


 vcl/qt5/Qt5Frame.cxx |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 0e3c3b842e14b9646d3697cf1266be21359e0f13
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Sat May 11 21:31:33 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Mon May 13 19:44:33 2019 +0200

    tdf#122293 qt5: Use "alien widgets" by default on Wayland
    
    As described in QWidget doc [1], calling 'QWidget::winId()',
    implicitly enforces a native window, i.e. one that has a
    native window associated with it.
    For this reason, avoid calling 'QWidget::winId()' for the Wayland
    case. Quoting QWidget doc:
    > Introduced in Qt 4.4, alien widgets are widgets unknown to the windowing
    > system. They do not have a native window handle associated with them.
    > This feature significantly speeds up widget painting, resizing, and
    > removes flicker.
    
    This in particular avoids tdf#122293/QTBUG-75766, which led to
    'mousePressEvent's not being emitted unless a mouse button was pressed,
    causing non-existent reaction to hovering over objects.
    
    As a consequence to widgets being non-native by default on Wayland,
    'Qt5Frame::windowHandle' needs to be adapted to make sure that the
    widgets handled in there are native ones, otherwise no window handle
    is associated with them.
    
    Probably more needs to be done here to make video playback via GStreamer
    work under Wayland, s.a. commit c0d4f3ad3307c ("implement wayland handle
    passing for gstreamer") for how it was done for gtk3.
    
    With and without this change, slideshows with videos are currently not
    handled properly with kde5 on Wayland (s. tdf#125219).
    
    [1] https://doc.qt.io/qt-5/qwidget.html#native-widgets-vs-alien-widgets
    
    Change-Id: Id46678e0ea594220a1765c3e59d39c41cb8bfe25
    Reviewed-on: https://gerrit.libreoffice.org/72164
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index acb43e515983..3cfb5d5d9e33 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -156,7 +156,17 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
     }
 
     m_aSystemData.nSize = sizeof(SystemEnvData);
-    m_aSystemData.aWindow = m_pQWidget->winId();
+
+    // Calling 'QWidget::winId()' implicitly enables native windows to be used
+    // rather than "alien widgets" that are unknown to the windowing system,
+    // s. https://doc.qt.io/qt-5/qwidget.html#native-widgets-vs-alien-widgets
+    // Avoid this on Wayland due to problems with missing 'mouseMoveEvent's,
+    // s. tdf#122293/QTBUG-75766
+    if (QGuiApplication::platformName() != "wayland")
+        m_aSystemData.aWindow = m_pQWidget->winId();
+    // TODO implement as needed for Wayland,
+    // s.a. commit c0d4f3ad3307c which did this for gtk3
+
     m_aSystemData.aShellWindow = reinterpret_cast<sal_IntPtr>(this);
     //m_aSystemData.pSalFrame = this;
     //m_aSystemData.pWidget = m_pQWidget;
@@ -265,10 +275,17 @@ bool Qt5Frame::isWindow() const
 
 QWindow* Qt5Frame::windowHandle() const
 {
+    // set attribute 'Qt::WA_NativeWindow' first to make sure a window handle actually exists
     if (m_pTopLevel)
+    {
+        m_pTopLevel->setAttribute(Qt::WA_NativeWindow);
         return m_pTopLevel->windowHandle();
+    }
     else
+    {
+        m_pQWidget->setAttribute(Qt::WA_NativeWindow);
         return m_pQWidget->windowHandle();
+    }
 }
 
 QScreen* Qt5Frame::screen() const


More information about the Libreoffice-commits mailing list