vcl/inc/qt5/QtObject.hxx | 7 ++++++- vcl/qt5/QtObject.cxx | 31 +++++++++++++++++++++---------- vcl/qt5/QtOpenGLContext.cxx | 9 +++++++++ 3 files changed, 36 insertions(+), 11 deletions(-)
New commits: commit b296b33cfbde5113f27ddef71a48380cb6ce5e06 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jun 21 19:53:50 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jun 21 23:19:02 2024 +0200 tdf#149461 qt6: Provide a QWindow for OpenGL rendering As described at [1], "QWindow supports rendering using OpenGL [...]". Using a QWindow for OpenGL rendering had been introduced in commit 56b19f9a814ae5a39ed760ee542d715493cd0bf3 Date: Fri Dec 14 12:44:20 2018 +0300 tdf#121247, tdf#121266 KDE5: Add basic support for OpenGL , but then commit 4366e0605214260e55a937173b0c2e02225dc843 Date: Tue May 24 11:34:59 2022 +0200 tdf#148864 Qt switch QtObjectWindow to QWidget had switched from QWindow to QWidget, and OpenGL slide transitions like the "Tiles" one stopped working. At least for qt6, which now uses QtMultimedia for video playback (see the tdf#145735 commits), issues like tdf#148864 ("Kubuntu 22.04 LTS LibreOffice Impress 7.3.3 Fails to Play Embedded Videos") and tdf#125517 ("LO Impress: Can't stop presentation with video and go to the next slide") related to video playback appear to be no problem, so switch back to using QWindow there. Explicitly set the window background to transparent in `QtOpenGLContext::ImplInit`, as not doing so caused slide content in presentation mode to not be updated properly when testing with the attachment 183972 from tdf#149461 on Wayland. (This was not an issue when running on XWayland, i.e. with QT_QPA_PLATFORM=xcb). With this in place, OpenGL transitions work with qt6. With QT_QPA_PLATFORM=xcb, it looks all fine in my tests on Debian testing. With QT_QPA_PLATFORM=wayland, the slide text from attachment 183972 sometimes incorrectly showed up for a fraction of a second after the slide transition finished, then disappeared again until it was triggered to show as it should (e.g. by pressing the right arrow key), s. screencast attachment 194899 in tdf#149461. A multitude of warnings like the following are shown on stderr in that case, which don't show up for xcb: warn:vcl.opengl:47352:47352:vcl/source/opengl/OpenGLHelper.cxx:709: GL Error 0506 (invalid framebuffer operation) in file /home/michi/development/git/libreoffice/slideshow/source/engine/opengl/TransitionImpl.cxx at line 398 That looks like a separate issue to me, however which would need further analysis. Keep using the QtObjectWindow approach for qt5 to not regress on video playback. [1] https://doc.qt.io/qt-5/qtgui-index.html#opengl-and-opengl-es-integration Change-Id: I6e1eb989254e2cbbfada6f719ee0518571df4c42 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169347 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtObject.hxx b/vcl/inc/qt5/QtObject.hxx index bc5a8e584b8f..e5f9944d6b86 100644 --- a/vcl/inc/qt5/QtObject.hxx +++ b/vcl/inc/qt5/QtObject.hxx @@ -24,6 +24,7 @@ #include <QtCore/QObject> #include <QtGui/QRegion> +#include <QtGui/QWindow> #include <QtWidgets/QWidget> class QtFrame; @@ -36,7 +37,11 @@ class QtObject final : public QObject, public SalObject SystemEnvData m_aSystemData; QtFrame* m_pParent; - QtObjectWidget* m_pQWidget; + + // window, required for OpenGL rendering + QWindow* m_pQWindow; + QWidget* m_pQWidget; + QRegion m_pRegion; bool m_bForwardKey; diff --git a/vcl/qt5/QtObject.cxx b/vcl/qt5/QtObject.cxx index 229916bcd1ff..b9f1b804f95c 100644 --- a/vcl/qt5/QtObject.cxx +++ b/vcl/qt5/QtObject.cxx @@ -23,6 +23,7 @@ #include <QtFrame.hxx> #include <QtWidget.hxx> +#include <QtCore/QLibraryInfo> #include <QtGui/QGuiApplication> #include <QtGui/QKeyEvent> #include <QtGui/QMouseEvent> @@ -36,7 +37,19 @@ QtObject::QtObject(QtFrame* pParent, bool bShow) if (!m_pParent || !pParent->GetQWidget()) return; - m_pQWidget = new QtObjectWidget(*this); + if (QLibraryInfo::version().majorVersion() > 5) + { + m_pQWindow = new QWindow; + m_pQWidget = QWidget::createWindowContainer(m_pQWindow, pParent->GetQWidget()); + } + else + { + // with the qt5 VCL plugin, the above would cause issues with video playback (s. tdf#148864, tdf#125517), + // which is not a problem with the QtMultimedia approach that the qt6 VCL plugin uses; + // stay with the QtObjectWidget introduced in commit 4366e0605214260e55a937173b0c2e02225dc843 + m_pQWidget = new QtObjectWidget(*this); + m_pQWindow = m_pQWidget->windowHandle(); + } // set layout, used for video playback, see QtPlayer::createPlayerWindow QVBoxLayout* layout = new QVBoxLayout; @@ -58,10 +71,7 @@ QtObject::~QtObject() } } -QWindow* QtObject::windowHandle() const -{ - return m_pQWidget ? m_pQWidget->windowHandle() : nullptr; -} +QWindow* QtObject::windowHandle() const { return m_pQWindow; } void QtObject::ResetClipRegion() { diff --git a/vcl/qt5/QtOpenGLContext.cxx b/vcl/qt5/QtOpenGLContext.cxx index f0cf9b5f4c65..49322c8864ae 100644 --- a/vcl/qt5/QtOpenGLContext.cxx +++ b/vcl/qt5/QtOpenGLContext.cxx @@ -80,6 +80,15 @@ bool QtOpenGLContext::ImplInit() } m_pWindow->setSurfaceType(QSurface::OpenGLSurface); + + // give window a transparent background, see + // https://doc.qt.io/qt-6/qwindow.html#setFormat + // Otherwise, slide content in a presentation using OpenGL transitions + // doesn't get updated with qt6 on Wayland + QSurfaceFormat format; + format.setAlphaBufferSize(8); + m_pWindow->setFormat(format); + m_pWindow->create(); m_pContext = new QOpenGLContext(m_pWindow); commit 22270a54a2d73f96109ca851b1e1627910213645 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jun 21 19:38:13 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jun 21 23:18:52 2024 +0200 tdf#149461 qt: Move setting layout to QtObject ctor Move setting the layout for the QtObjectWidget from the QtObjectWidget ctor to the QtObject ctor, in preparation to also use that for QWidgets other than the QtObjectWidget. Change-Id: Ifbb0d853659bc8099bed40db2bbe8a8778077aa2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169346 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtObject.cxx b/vcl/qt5/QtObject.cxx index bde8b570ac2e..229916bcd1ff 100644 --- a/vcl/qt5/QtObject.cxx +++ b/vcl/qt5/QtObject.cxx @@ -37,6 +37,12 @@ QtObject::QtObject(QtFrame* pParent, bool bShow) return; m_pQWidget = new QtObjectWidget(*this); + + // set layout, used for video playback, see QtPlayer::createPlayerWindow + QVBoxLayout* layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + m_pQWidget->setLayout(layout); + if (bShow) m_pQWidget->show(); @@ -112,11 +118,6 @@ QtObjectWidget::QtObjectWidget(QtObject& rParent) assert(m_rParent.frame() && m_rParent.frame()->GetQWidget()); setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_OpaquePaintEvent); - - // set layout, used for video playback, see QtPlayer::createPlayerWindow - QVBoxLayout* layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - setLayout(layout); } void QtObjectWidget::focusInEvent(QFocusEvent*)