[vlc-commits] [Git][videolan/vlc][master] qt: support CSD shadows in compositor_wayland

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Jun 23 15:44:46 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
062d5ba1 by Fatih Uzunoglu at 2024-06-23T15:31:45+00:00
qt: support CSD shadows in compositor_wayland

- - - - -


2 changed files:

- modules/gui/qt/maininterface/compositor_wayland.cpp
- modules/gui/qt/maininterface/compositor_wayland.hpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor_wayland.cpp
=====================================
@@ -27,6 +27,10 @@
 #include <QtGui/qpa/qplatformnativeinterface.h>
 #include <QtGui/qpa/qplatformwindow.h>
 
+#ifdef QT_WAYLAND_HAS_CUSTOM_MARGIN_SUPPORT
+#include <QtGui/qpa/qplatformwindow_p.h>
+#endif
+
 #include <vlc_window.h>
 #include <vlc_modules.h>
 
@@ -113,8 +117,25 @@ bool CompositorWayland::makeMainInterface(MainCtx* mainCtx)
 
     m_waylandImpl->setupInterface(m_waylandImpl, interfaceSurface, dprForWindow(m_qmlView.get()));
 
-    const bool ret = commonGUICreate(m_qmlView.get(), m_qmlView.get(),
-                                     CompositorVideo::CAN_SHOW_PIP | CompositorVideo::HAS_ACRYLIC);
+    CompositorVideo::Flags flags = CompositorVideo::CAN_SHOW_PIP | CompositorVideo::HAS_ACRYLIC;
+
+#ifdef QT_WAYLAND_HAS_CUSTOM_MARGIN_SUPPORT
+    connect(m_intf->p_mi, &MainCtx::windowExtendedMarginChanged, this, [this](const unsigned margin) {
+        const auto quickViewPtr = m_qmlView.get();
+        assert(quickViewPtr);
+        connect(quickViewPtr, &QWindow::widthChanged, this, &CompositorWayland::adjustQuickWindowMask, Qt::UniqueConnection);
+        connect(quickViewPtr, &QWindow::heightChanged, this, &CompositorWayland::adjustQuickWindowMask, Qt::UniqueConnection);
+
+        const auto waylandWindow = dynamic_cast<QNativeInterface::Private::QWaylandWindow *>(quickViewPtr->handle());
+        assert(waylandWindow);
+        const QMargins margins(margin, margin, margin, margin);
+        waylandWindow->setCustomMargins(margins);
+    });
+
+    flags |= CompositorVideo::HAS_EXTENDED_FRAME;
+#endif
+
+    const bool ret = commonGUICreate(m_qmlView.get(), m_qmlView.get(), flags);
 
     if (ret)
         m_qmlView->show();
@@ -206,4 +227,17 @@ void CompositorWayland::onSurfaceSizeChanged(const QSizeF& size)
                         size.height() / nativeDpr);
 }
 
+#ifdef QT_WAYLAND_HAS_CUSTOM_MARGIN_SUPPORT
+void CompositorWayland::adjustQuickWindowMask()
+{
+    assert(m_intf);
+    assert(m_intf->p_mi);
+    unsigned maskMargin = 0;
+    if (Q_LIKELY(static_cast<unsigned>(m_intf->p_mi->CSDBorderSize()) < m_intf->p_mi->windowExtendedMargin()))
+        maskMargin = m_intf->p_mi->windowExtendedMargin() - m_intf->p_mi->CSDBorderSize();
+    const QMargins maskMargins(maskMargin, maskMargin, maskMargin, maskMargin);
+    m_qmlView->setMask(m_qmlView->geometry().marginsRemoved(maskMargins));
+}
+#endif
+
 }


=====================================
modules/gui/qt/maininterface/compositor_wayland.hpp
=====================================
@@ -25,6 +25,10 @@
 #include <memory>
 #include "compositor.hpp"
 
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)) && defined(QT_GUI_PRIVATE)
+#define QT_WAYLAND_HAS_CUSTOM_MARGIN_SUPPORT
+#endif
+
 class MainCtx;
 class QQuickView;
 class InterfaceWindowHandler;
@@ -77,7 +81,9 @@ public:
 protected slots:
     void onSurfacePositionChanged(const QPointF&) override;
     void onSurfaceSizeChanged(const QSizeF&) override;
-
+#ifdef QT_WAYLAND_HAS_CUSTOM_MARGIN_SUPPORT
+    void adjustQuickWindowMask();
+#endif
 
 protected:
     std::unique_ptr<QQuickView> m_qmlView;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/062d5ba178179372d2a350c2fba5afa0fa081baf

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/062d5ba178179372d2a350c2fba5afa0fa081baf
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list