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#291
  • Loading branch information
deepin-ci-robot authored and 18202781743 committed Dec 24, 2024
1 parent 7377a97 commit 02d4266
Show file tree
Hide file tree
Showing 8 changed files with 1,394 additions and 543 deletions.
695 changes: 185 additions & 510 deletions src/kernel/dplatformhandle.cpp

Large diffs are not rendered by default.

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

#include "private/dplatformwindowinterface_p.h"

DGUI_BEGIN_NAMESPACE

DPlatformWindowInterface::DPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle)
: m_window(window)
, m_platformHandle(platformHandle)
{
}

DPlatformWindowInterface::~DPlatformWindowInterface()
{
}

QWindow *DPlatformWindowInterface::window() const
{
return m_window;
}

void DPlatformWindowInterface::setEnabled(bool enabled)
{
Q_UNUSED(enabled)
}

bool DPlatformWindowInterface::isEnabled() const
{
return false;
}

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

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

void DPlatformWindowInterface::setDisableWindowOverrideCursor(bool disable)
{
Q_UNUSED(disable)
}

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

void DPlatformWindowInterface::setWindowRadius(int windowRadius)
{
Q_UNUSED(windowRadius)
}

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

void DPlatformWindowInterface::setBorderWidth(int borderWidth)
{
Q_UNUSED(borderWidth)
}

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

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

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

void DPlatformWindowInterface::setShadowRadius(int shadowRadius)
{
Q_UNUSED(shadowRadius)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

void DPlatformWindowInterface::setTranslucentBackground(bool translucentBackground)
{
Q_UNUSED(translucentBackground)
}

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

void DPlatformWindowInterface::setEnableSystemResize(bool enableSystemResize)
{
Q_UNUSED(enableSystemResize)
}

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

void DPlatformWindowInterface::setEnableSystemMove(bool enableSystemMove)
{
Q_UNUSED(enableSystemMove)
}

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

void DPlatformWindowInterface::setEnableBlurWindow(bool enableBlurWindow)
{
Q_UNUSED(enableBlurWindow)
}

DGUI_END_NAMESPACE

102 changes: 81 additions & 21 deletions src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@
#undef protected

#include "dtreelandplatformwindowinterface.h"
#include "dtreelandplatformwindowinterface.h"
#include "dtreelandplatforminterface.h"

#include <QWaylandClientExtension>
#include <QStyleHints>
#include <private/qwaylandintegration_p.h>
#include <private/qguiapplication_p.h>
#include <private/qwaylandwindow_p.h>
#include <private/qwaylandsurface_p.h>

#include "personalizationwaylandclientextension.h"
#include <qwaylandclientextension.h>
#include "dvtablehook.h"

#include <QtWaylandClient/QWaylandClientExtension>
#include <QtWaylandClient/private/qwaylandsurface_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QStyleHints>
#include "personalizationwaylandclientextension.h"

DCORE_USE_NAMESPACE

class MoveWindowHelper : public QObject
DGUI_BEGIN_NAMESPACE

class Q_DECL_HIDDEN MoveWindowHelper : public QObject
{
public:
explicit MoveWindowHelper(QWindow *w);
Expand Down Expand Up @@ -146,33 +145,36 @@ bool MoveWindowHelper::windowEvent(QWindow *w, QEvent *event)

class Q_DECL_HIDDEN WindowEventFilter : public QObject {
public:
WindowEventFilter(QObject *parent = nullptr, DTreeLandPlatformWindowInterface *interface = nullptr)
: QObject(parent)
, m_interface(interface)
WindowEventFilter(DTreeLandPlatformWindowInterface *interface = nullptr)
: QObject(interface)
{
}

public:
bool eventFilter(QObject *watched, QEvent *event) override {
DTreeLandPlatformWindowInterface *interface() const
{
return qobject_cast<DTreeLandPlatformWindowInterface *>(parent());
}

bool eventFilter(QObject *watched, QEvent *event) {
if (event->type() == QEvent::PlatformSurface) {
QPlatformSurfaceEvent *se = static_cast<QPlatformSurfaceEvent*>(event);
if (se->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
m_interface->initWaylandWindow();
m_interface->onSurfaceCreated();
if (auto item = interface()) {
item->initWaylandWindow();
item->onSurfaceCreated();
}
}
}
return QObject::eventFilter(watched, event);
}
private:
DTreeLandPlatformWindowInterface *m_interface;
};

DTreeLandPlatformWindowInterface::DTreeLandPlatformWindowInterface(QObject *parent, QWindow *window)
DTreeLandPlatformWindowInterface::DTreeLandPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent)
: QObject(parent)
, m_window(window)
, DPlatformWindowInterface(window, platformHandle)
{
m_manager = PersonalizationManager::instance();
m_window->installEventFilter(new WindowEventFilter(this, this));
m_window->installEventFilter(new WindowEventFilter(this));
connect(m_manager, &PersonalizationManager::activeChanged, this, [this](){
if (m_manager->isActive()) {
handlePendingTasks();
Expand Down Expand Up @@ -225,6 +227,18 @@ void DTreeLandPlatformWindowInterface::initWaylandWindow()
connect(waylandWindow, &QtWaylandClient::QWaylandWindow::wlSurfaceDestroyed, this, &DTreeLandPlatformWindowInterface::onSurfaceDestroyed, Qt::UniqueConnection);
}

void DTreeLandPlatformWindowInterface::setEnabled(bool enabled)
{
if (setEnabledNoTitlebar(enabled)) {
return;
}
}

bool DTreeLandPlatformWindowInterface::isEnabled() const
{
return isEnabledNoTitlebar();
}

PersonalizationWindowContext *DTreeLandPlatformWindowInterface::getWindowContext()
{
if (!m_manager->isSupported()) {
Expand Down Expand Up @@ -270,6 +284,11 @@ void DTreeLandPlatformWindowInterface::handlePendingTasks()
}
}

bool DTreeLandPlatformWindowInterface::isEnabledNoTitlebar() const
{
return m_isNoTitlebar;
}

bool DTreeLandPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
{
if (m_isNoTitlebar == enable) {
Expand All @@ -280,6 +299,25 @@ bool DTreeLandPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
return true;
}

int DTreeLandPlatformWindowInterface::windowRadius() const
{
return m_radius;
}

void DTreeLandPlatformWindowInterface::setWindowRadius(int windowRadius)
{
if (m_radius == windowRadius) {
return;
}
m_radius = windowRadius;
doSetWindowRadius();
}

bool DTreeLandPlatformWindowInterface::enableBlurWindow() const
{
return m_isWindowBlur;
}

void DTreeLandPlatformWindowInterface::setEnableBlurWindow(bool enable)
{
if (m_isWindowBlur == enable) {
Expand Down Expand Up @@ -307,6 +345,27 @@ void DTreeLandPlatformWindowInterface::doSetEnabledNoTitlebar()
}
}

void DTreeLandPlatformWindowInterface::doSetWindowRadius()
{
auto handleFunc = [this](){
auto windowContext = getWindowContext();
if (!windowContext) {
qWarning() << "windowContext is nullptr!";
return;
}
windowContext->set_round_corner_radius(m_radius);
if (m_platformHandle) {
Q_EMIT m_platformHandle->windowRadiusChanged();
}
return;
};
if (m_manager->isActive()) {
handleFunc();
} else {
m_pendingTasks.enqueue(handleFunc);
}
}

void DTreeLandPlatformWindowInterface::doSetEnabledBlurWindow()
{
auto handleFunc = [this](){
Expand All @@ -323,3 +382,4 @@ void DTreeLandPlatformWindowInterface::doSetEnabledBlurWindow()
m_pendingTasks.enqueue(handleFunc);
}
}
DGUI_END_NAMESPACE
Loading

0 comments on commit 02d4266

Please sign in to comment.