Skip to content

Commit

Permalink
chore: add window platform interface
Browse files Browse the repository at this point in the history
add window platform interface

Log: as title.
  • Loading branch information
wangfei committed Nov 28, 2024
1 parent fed4aae commit 967a5a4
Show file tree
Hide file tree
Showing 11 changed files with 1,357 additions and 55 deletions.
38 changes: 28 additions & 10 deletions src/kernel/dplatformhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include "dplatformtheme.h"
#include "dwindowmanagerhelper.h"

#include "private/dplatformwindowinterface_p.h"
#include <qsharedpointer.h>
#ifndef DTK_DISABLE_XCB
#include "plugins/platform/xcb/dxcbplatformwindowinterface.h"
#endif
#ifndef DTK_DISABLE_TREELAND
#include "plugins/platform/treeland/dtreelandplatformwindowinterface.h"
#endif
Expand Down Expand Up @@ -104,19 +109,17 @@ static void setWindowProperty(QWindow *window, const char *name, const QVariant
reinterpret_cast<void(*)(QWindow *, const char *, const QVariant &)>(setWindowProperty)(window, name, value);
}

#ifndef DTK_DISABLE_TREELAND
static QHash<DPlatformHandle *, DTreeLandPlatformWindowInterface *> g_platformThemeMap;
static QHash<DPlatformHandle*, DPlatformWindowInterface*> g_platformThemeMap;

static DTreeLandPlatformWindowInterface *dPlatformWindowInterfaceByWindow(QWindow * window)
static DPlatformWindowInterface *dPlatformWindowInterfaceByWindow(QWindow *window)

Check warning on line 114 in src/kernel/dplatformhandle.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'window' can be declared with const

Check warning on line 114 in src/kernel/dplatformhandle.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Parameter 'window' can be declared with const

Check warning on line 114 in src/kernel/dplatformhandle.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'window' can be declared with const

Check warning on line 114 in src/kernel/dplatformhandle.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Parameter 'window' can be declared with const
{
for (auto it = g_platformThemeMap.cbegin(); it != g_platformThemeMap.cend(); ++it) {
if (it.value()->getWindow() == window) {
if (it.value()->window() == window) {
return it.value();
}
}
return nullptr;
}
#endif

/*!
\class Dtk::Gui::DPlatformHandle
Expand Down Expand Up @@ -394,6 +397,13 @@ static DTreeLandPlatformWindowInterface *dPlatformWindowInterfaceByWindow(QWindo
竖直方向的圆角半径
*/

static DPlatformWindowInterfaceFactory::HelperCreator OutsideWindowInterfaceCreator = nullptr;

void DPlatformWindowInterfaceFactory::registerInterface(HelperCreator creator)
{
OutsideWindowInterfaceCreator = creator;
}

/*!
\brief DPlatformHandle::DPlatformHandle
将 \a window 对象传递给 enableDXcbForWindow
Expand All @@ -405,11 +415,21 @@ DPlatformHandle::DPlatformHandle(QWindow *window, QObject *parent)
: QObject(parent)
, m_window(window)
{
if (OutsideWindowInterfaceCreator) {
g_platformThemeMap.insert(this, OutsideWindowInterfaceCreator(window, this));
} else {
#ifndef DTK_DISABLE_XCB
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsXWindowPlatform)) {
g_platformThemeMap.insert(this, new DXCBPlatformWindowInterface(window, this, parent));
}
#endif

#ifndef DTK_DISABLE_TREELAND
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
g_platformThemeMap.insert(this, new DTreeLandPlatformWindowInterface(nullptr, window));
}
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
g_platformThemeMap.insert(this, new DTreeLandPlatformWindowInterface(window, this, parent));
}
#endif
}

enableDXcbForWindow(window);

Expand All @@ -418,11 +438,9 @@ DPlatformHandle::DPlatformHandle(QWindow *window, QObject *parent)

DPlatformHandle::~DPlatformHandle()
{
#ifndef DTK_DISABLE_TREELAND
if (auto item = g_platformThemeMap.take(this)) {
item->deleteLater();
}
#endif
}

/*!
Expand Down
214 changes: 214 additions & 0 deletions src/plugins/dplatformwindowinterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "dplatformhandle.h"
#include "private/dplatformwindowinterface_p.h"
#include "private/dplatformwindowinterface_p_p.h"
#include "dtkgui_global.h"
#include <dobject.h>
#include <qobject.h>

DGUI_BEGIN_NAMESPACE

DPlatformWindowInterfacePrivate::DPlatformWindowInterfacePrivate(DPlatformWindowInterface *qq)
: DObjectPrivate(qq)
{
}

DPlatformWindowInterface::DPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent)
:DPlatformWindowInterface(*new DPlatformWindowInterfacePrivate(this), window, platformHandle, parent)
{
}

DPlatformWindowInterface::~DPlatformWindowInterface()
{
}

QWindow *DPlatformWindowInterface::window() const
{
D_DC(DPlatformWindowInterface);

return d->m_window;
}

bool DPlatformWindowInterface::isEnabledNoTitlebar() const
{
return {};
}

bool DPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
{
return {};
}

bool DPlatformWindowInterface::setWindowBlurAreaByWM(const QVector<DPlatformHandle::WMBlurArea> &area)
{
return {};
}

bool DPlatformWindowInterface::setWindowBlurAreaByWM(const QList<QPainterPath> &paths)
{
return {};
}

int DPlatformWindowInterface::windowRadius() const
{
return {};
}

void DPlatformWindowInterface::setWindowRadius(int windowRadius)
{
}

int DPlatformWindowInterface::borderWidth() const
{
return {};
}

void DPlatformWindowInterface::setBorderWidth(int borderWidth)
{
}

QColor DPlatformWindowInterface::borderColor() const
{
return {};
}

void DPlatformWindowInterface::setBorderColor(const QColor &borderColor)
{
}

int DPlatformWindowInterface::shadowRadius() const
{
return {};
}

void DPlatformWindowInterface::setShadowRadius(int shadowRadius)
{
}

QPoint DPlatformWindowInterface::shadowOffset() const
{
return {};
}

void DPlatformWindowInterface::setShadowOffset(const QPoint &shadowOffset)
{
}

QColor DPlatformWindowInterface::shadowColor() const
{
return {};
}

void DPlatformWindowInterface::setShadowColor(const QColor &shadowColor)
{
}

DPlatformHandle::EffectScene DPlatformWindowInterface::windowEffect()
{
return {};
}

void DPlatformWindowInterface::setWindowEffect(DPlatformHandle::EffectScenes effectScene)
{
}

DPlatformHandle::EffectType DPlatformWindowInterface::windowStartUpEffect()
{
return {};
}

void DPlatformWindowInterface::setWindowStartUpEffect(DPlatformHandle::EffectTypes effectType)
{
}

QPainterPath DPlatformWindowInterface::clipPath() const
{
return {};
}

void DPlatformWindowInterface::setClipPath(const QPainterPath &clipPath)
{
}

QRegion DPlatformWindowInterface::frameMask() const
{
return {};
}

void DPlatformWindowInterface::setFrameMask(const QRegion &frameMask)
{
}

QMargins DPlatformWindowInterface::frameMargins() const
{
return {};
}

bool DPlatformWindowInterface::translucentBackground() const
{
return {};
}

void DPlatformWindowInterface::setTranslucentBackground(bool translucentBackground)
{
}

bool DPlatformWindowInterface::enableSystemResize() const
{
return {};
}

void DPlatformWindowInterface::setEnableSystemResize(bool enableSystemResize)
{
}

bool DPlatformWindowInterface::enableSystemMove() const
{
return {};
}

void DPlatformWindowInterface::setEnableSystemMove(bool enableSystemMove)
{
}

bool DPlatformWindowInterface::enableBlurWindow() const
{
return {};
}

void DPlatformWindowInterface::setEnableBlurWindow(bool enableBlurWindow)
{
}

bool DPlatformWindowInterface::autoInputMaskByClipPath() const
{
return {};
}

void DPlatformWindowInterface::setAutoInputMaskByClipPath(bool autoInputMaskByClipPath)
{
}

WId DPlatformWindowInterface::realWindowId() const
{
return {};
}

WId DPlatformWindowInterface::windowLeader()
{
return {};
}

DPlatformWindowInterface::DPlatformWindowInterface(DPlatformWindowInterfacePrivate &dd, QWindow *window, DPlatformHandle *platformHandle, QObject *parent)
: QObject(parent)
, DObject(dd)
{
d_func()->m_window = window;
d_func()->m_platformHandle = platformHandle;
}

DGUI_END_NAMESPACE

Loading

0 comments on commit 967a5a4

Please sign in to comment.