Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkgui
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkgui.

Source-pull-request: linuxdeepin/dtkgui#279
  • Loading branch information
deepin-ci-robot committed Nov 26, 2024
1 parent 4d3f24d commit 0e15102
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/kernel/dwindowmanagerhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

#include <functional>

#ifndef DTK_DISABLE_TREELAND
#include "plugins/platform/treeland/personalizationwaylandclientextension.h"
#endif

DGUI_BEGIN_NAMESPACE

#define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name
Expand Down Expand Up @@ -111,6 +115,34 @@ class DWindowManagerHelperPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate
mutable QList<DForeignWindow *> 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)

Expand Down Expand Up @@ -323,6 +355,11 @@ DWindowManagerHelper::~DWindowManagerHelper()
*/
DWindowManagerHelper *DWindowManagerHelper::instance()
{
#ifndef DTK_DISABLE_TREELAND
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
return treelandWMHGlobal;
}
#endif
return wmhGlobal;
}

Expand Down Expand Up @@ -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<bool, bool(*)()>(_hasBlurWindow);
}

Expand All @@ -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;

Check warning on line 579 in src/kernel/dwindowmanagerhelper.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Condition '!hasComposite' is always true

#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
Expand Down Expand Up @@ -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<bool, bool(*)()>(_hasNoTitlebar);
}

Expand Down

0 comments on commit 0e15102

Please sign in to comment.