mirror of
https://github.com/videolan/vlc.git
synced 2024-11-30 13:25:56 +08:00
qt: support CSD shadows in compositor_wayland
This commit is contained in:
parent
0a47412299
commit
062d5ba178
@ -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
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user