Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: from linuxdeepin/dtkgui #64

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
{
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 DPlatformWindowInterfaceFactory::HelperCreator OutsideWindowInterfaceCreator = nullptr;

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

/*!
\brief DPlatformHandle::DPlatformHandle
将 \a window 对象传递给 enableDXcbForWindow
Expand All @@ -405,11 +415,21 @@
: 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()
{
#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