Skip to content

Commit

Permalink
feat: support treeland platform for wmHelper
Browse files Browse the repository at this point in the history
WindowManager's some interface may be deprecated, like MotifFunctions
and allWindowIdList.
and there is currently no abstraction of platform common
interfaces.

pms: Bug-287901
  • Loading branch information
18202781743 committed Nov 26, 2024
1 parent 16d4999 commit 85fe7ea
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

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

View workflow job for this annotation

GitHub Actions / static-check / static-check

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 85fe7ea

Please sign in to comment.