From e25e766afc3ffe879bcbb97d549780b9334ced9a Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Wed, 27 Nov 2024 02:20:20 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkgui Synchronize source files from linuxdeepin/dtkgui. Source-pull-request: https://github.com/linuxdeepin/dtkgui/pull/279 --- src/kernel/dwindowmanagerhelper.cpp | 30 ++++++++++++++++ .../treeland/dtreelandwindowmanagerhelper.cpp | 34 +++++++++++++++++++ .../treeland/dtreelandwindowmanagerhelper.h | 25 ++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 src/plugins/platform/treeland/dtreelandwindowmanagerhelper.cpp create mode 100644 src/plugins/platform/treeland/dtreelandwindowmanagerhelper.h diff --git a/src/kernel/dwindowmanagerhelper.cpp b/src/kernel/dwindowmanagerhelper.cpp index cc64d40..ba36b38 100644 --- a/src/kernel/dwindowmanagerhelper.cpp +++ b/src/kernel/dwindowmanagerhelper.cpp @@ -24,6 +24,10 @@ #include +#ifndef DTK_DISABLE_TREELAND +#include "plugins/platform/treeland/dtreelandwindowmanagerhelper.h" +#endif + DGUI_BEGIN_NAMESPACE #define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name @@ -111,6 +115,11 @@ class DWindowManagerHelperPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate mutable QList windowList; }; +// TODO abstract an interface to adapt to various WM. +#ifndef DTK_DISABLE_TREELAND +Q_GLOBAL_STATIC(TreelandWindowManagerHelper, treelandWMHGlobal) +#endif + class DWindowManagerHelper_ : public DWindowManagerHelper {}; Q_GLOBAL_STATIC(DWindowManagerHelper_, wmhGlobal) @@ -323,6 +332,11 @@ DWindowManagerHelper::~DWindowManagerHelper() */ DWindowManagerHelper *DWindowManagerHelper::instance() { +#ifndef DTK_DISABLE_TREELAND + if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { + return treelandWMHGlobal; + } +#endif return wmhGlobal; } @@ -519,6 +533,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 +547,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 +582,11 @@ bool DWindowManagerHelper::hasComposite() const */ bool DWindowManagerHelper::hasNoTitlebar() const { +#ifndef DTK_DISABLE_TREELAND + if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { + return treelandWMHGlobal->hasNoTitlebar(); + } +#endif return callPlatformFunction(_hasNoTitlebar); } diff --git a/src/plugins/platform/treeland/dtreelandwindowmanagerhelper.cpp b/src/plugins/platform/treeland/dtreelandwindowmanagerhelper.cpp new file mode 100644 index 0000000..de73ca0 --- /dev/null +++ b/src/plugins/platform/treeland/dtreelandwindowmanagerhelper.cpp @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#include "dtreelandwindowmanagerhelper.h" +#include "personalizationwaylandclientextension.h" + +DGUI_BEGIN_NAMESPACE + +TreelandWindowManagerHelper::TreelandWindowManagerHelper(QObject *parent) + : DWindowManagerHelper(parent) +{ + connect(PersonalizationManager::instance(), &PersonalizationManager::activeChanged, this, [this](){ + Q_EMIT hasBlurWindowChanged(); + Q_EMIT hasNoTitlebarChanged(); + }); +} + +bool TreelandWindowManagerHelper::hasBlurWindow() const +{ + return PersonalizationManager::instance()->isSupported(); +} + +bool TreelandWindowManagerHelper::hasComposite() const +{ + return true; +} + +bool TreelandWindowManagerHelper::hasNoTitlebar() const +{ + return PersonalizationManager::instance()->isSupported(); +} + +DGUI_END_NAMESPACE diff --git a/src/plugins/platform/treeland/dtreelandwindowmanagerhelper.h b/src/plugins/platform/treeland/dtreelandwindowmanagerhelper.h new file mode 100644 index 0000000..4ea2c24 --- /dev/null +++ b/src/plugins/platform/treeland/dtreelandwindowmanagerhelper.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef DTREELANDWINDOWMANAGERHELPER_H +#define DTREELANDWINDOWMANAGERHELPER_H + +#include "dtkgui_global.h" +#include "dwindowmanagerhelper.h" +#include + +DGUI_BEGIN_NAMESPACE + +class TreelandWindowManagerHelper : public DWindowManagerHelper +{ +public: + explicit TreelandWindowManagerHelper(QObject *parent = 0); + bool hasBlurWindow() const; + bool hasComposite() const; + bool hasNoTitlebar() const; +}; + +DGUI_END_NAMESPACE + +#endif // DTREELANDWINDOWMANAGERHELPER_H