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 #97

Merged
merged 1 commit into from
Dec 24, 2024
Merged
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
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"

Check warning on line 5 in src/plugins/dplatformwindowinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "private/dplatformwindowinterface_p.h" not found.

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)

Check warning on line 41 in src/plugins/dplatformwindowinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

syntax error
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>

Check warning on line 11 in src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWaylandClientExtension> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QStyleHints>

Check warning on line 12 in src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QStyleHints> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <private/qwaylandintegration_p.h>

Check warning on line 13 in src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <private/qwaylandintegration_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#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 @@

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 @@
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 @@
}
}

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

bool DTreeLandPlatformWindowInterface::setEnabledNoTitlebar(bool enable)
{
if (m_isNoTitlebar == enable) {
Expand All @@ -280,6 +299,25 @@
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::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 @@
m_pendingTasks.enqueue(handleFunc);
}
}
DGUI_END_NAMESPACE
Loading
Loading