diff --git a/src/kernel/dwindowmanagerhelper.cpp b/src/kernel/dwindowmanagerhelper.cpp index cc64d40..66bfaf2 100644 --- a/src/kernel/dwindowmanagerhelper.cpp +++ b/src/kernel/dwindowmanagerhelper.cpp @@ -24,6 +24,10 @@ #include +#ifndef DTK_DISABLE_TREELAND +#include "plugins/platform/treeland/personalizationwaylandclientextension.h" +#endif + DGUI_BEGIN_NAMESPACE #define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name @@ -111,6 +115,34 @@ class DWindowManagerHelperPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate mutable QList windowList; }; +#ifndef DTK_DISABLE_TREELAND +class TreelandWindowManagerHelper_ : public DWindowManagerHelper +{ +public: + explicit TreelandWindowManagerHelper_(QObject *parent = 0) + : DWindowManagerHelper(parent) + { + connect(PersonalizationManager::instance(), &PersonalizationManager::activeChanged, this, [this](){ + Q_EMIT hasBlurWindowChanged(); + Q_EMIT hasNoTitlebarChanged(); + }); + } + bool hasBlurWindow() const + { + return PersonalizationManager::instance()->isSupported(); + } + bool hasComposite() const + { + return true; + } + bool hasNoTitlebar() const + { + return PersonalizationManager::instance()->isSupported(); + } +}; +Q_GLOBAL_STATIC(TreelandWindowManagerHelper_, treelandWMHGlobal) +#endif + class DWindowManagerHelper_ : public DWindowManagerHelper {}; Q_GLOBAL_STATIC(DWindowManagerHelper_, wmhGlobal) @@ -323,6 +355,11 @@ DWindowManagerHelper::~DWindowManagerHelper() */ DWindowManagerHelper *DWindowManagerHelper::instance() { +#ifndef DTK_DISABLE_TREELAND + if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { + return treelandWMHGlobal; + } +#endif return wmhGlobal; } @@ -519,6 +556,11 @@ void DWindowManagerHelper::popupSystemWindowMenu(const QWindow *window) */ bool DWindowManagerHelper::hasBlurWindow() const { +#ifndef DTK_DISABLE_TREELAND + if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { + return treelandWMHGlobal->hasBlurWindow(); + } +#endif return callPlatformFunction(_hasBlurWindow); } @@ -528,6 +570,12 @@ bool DWindowManagerHelper::hasBlurWindow() const */ bool DWindowManagerHelper::hasComposite() const { +#ifndef DTK_DISABLE_TREELAND + if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { + return treelandWMHGlobal->hasComposite(); + } +#endif + QFunctionPointer hasComposite = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) @@ -557,6 +605,11 @@ bool DWindowManagerHelper::hasComposite() const */ bool DWindowManagerHelper::hasNoTitlebar() const { +#ifndef DTK_DISABLE_TREELAND + if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { + return wmhGlobal->hasNoTitlebar(); + } +#endif return callPlatformFunction(_hasNoTitlebar); }