summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2019-05-11 21:31:33 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2019-05-13 19:44:33 +0200
commit0e3c3b842e14b9646d3697cf1266be21359e0f13 (patch)
treea88222760046aedb316ed0f040381f99dfe208f6
parentf4ba484183a1e7b9824f10580d633466c266828f (diff)
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@posteo.de>
-rw-r--r--vcl/qt5/Qt5Frame.cxx19
1 files changed, 18 insertions, 1 deletions
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