DtkGui
DTK Gui module
载入中...
搜索中...
未找到
dtreelandplatformwindowinterface.h
1// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DTREELANDPLATFORMWINDOWINTERFACE_H
6#define DTREELANDPLATFORMWINDOWINTERFACE_H
7
8#include "dtkgui_global.h"
9#include <QColor>
10#include <QObject>
11#include <QPainterPath>
12#include <QRegion>
13#include "private/dplatformwindowinterface_p.h"
14
15DGUI_BEGIN_NAMESPACE
18class DTreeLandPlatformWindowHelper : public QObject {
19 Q_OBJECT
20public:
21 static DTreeLandPlatformWindowHelper *get(QWindow *window);
23
24 enum Feature {
25 NoTitlebar = 1 << 0,
26 Radius = 1 << 1,
27 Border = 1 << 2,
28 Shadow = 1 << 3,
29 WindowEffect = 1 << 4,
30 BlurWindow = 1 << 5,
31 BlurRegion = 1 << 6,
32 };
33 Q_DECLARE_FLAGS(Features, Feature)
34
35 QWindow *window() const { return qobject_cast<QWindow *>(parent()); }
36 TreelandDecorationContext *decorationContext() const;
37 BackgroundEffectSurface *backgroundEffectSurface() const;
38
39 void setEnabledNoTitlebar(bool enable);
40 void setWindowRadius(int windowRadius);
41 void setBorderWidth(int borderWidth);
42 void setBorderColor(const QColor &borderColor);
43 void setShadowRadius(int shadowRadius);
44 void setShadowOffset(const QPoint &shadowOffset);
45 void setShadowColor(const QColor &shadowColor);
46 void setWindowEffect(DPlatformHandle::EffectScenes effectScene);
47 void setPlatformHandle(DPlatformHandle *handle);
48 void setEnableBlurWindow(bool enabled);
49 void setWindowBlurAreas(const QVector<DPlatformHandle::WMBlurArea> &areas);
50 void setWindowBlurPaths(const QList<QPainterPath> &paths);
51 bool enableBlurWindow() const { return m_blurWindowEnabled; }
52
53 bool isEnabledNoTitlebar() const { return m_noTitlebar; }
54 int windowRadius() const { return m_radius; }
55 int borderWidth() const { return m_borderWidth; }
56 QColor borderColor() const { return m_borderColor; }
57 int shadowRadius() const { return m_shadowRadius; }
58 QPoint shadowOffset() const { return m_shadowOffset; }
59 QColor shadowColor() const { return m_shadowColor; }
60 DPlatformHandle::EffectScenes windowEffect() const { return m_effectScene; }
61
62private slots:
63 void onActiveChanged();
64 void onSurfaceCreated();
65 void onSurfaceDestroyed();
66 void applyPending();
67private:
68 explicit DTreeLandPlatformWindowHelper(QWindow *window);
69 bool eventFilter(QObject *watched, QEvent *event) override;
70 void initWaylandWindow();
71 void scheduleApply();
72
73 template<typename T>
74 void updateFeature(T &member, const T &value, Feature flag) {
75 member = value;
76 updateFeature(flag);
77 }
78
79 void updateFeature(Feature flag) {
80 m_initialized |= flag;
81 m_dirty |= flag;
82 scheduleApply();
83 }
84
85private:
86 TreelandDecorationContext *m_decorationContext = nullptr;
87 BackgroundEffectSurface *m_backgroundEffectSurface = nullptr;
88 static QMap<QWindow *, DTreeLandPlatformWindowHelper*> windowMap;
89 DPlatformHandle *m_platformHandle = nullptr;
90
91 bool m_noTitlebar = false;
92 bool m_blurWindowEnabled = false;
93 QRegion m_blurRegion;
94 int m_radius = 0;
95 int m_borderWidth = 0;
96 QColor m_borderColor;
97 int m_shadowRadius = 0;
98 QPoint m_shadowOffset;
99 QColor m_shadowColor;
100 DPlatformHandle::EffectScenes m_effectScene = {};
101 Features m_initialized = {};
102 Features m_dirty = {};
103 bool m_applyScheduled = false;
104};
105
107{
108 Q_OBJECT
109public:
110 DTreeLandPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent = nullptr);
112
113 void setEnabled(bool enabled) override;
114 bool isEnabled() const override;
115
116 bool isEnabledNoTitlebar() const override;
117 bool setEnabledNoTitlebar(bool enable) override;
118
119 int windowRadius() const override;
120 void setWindowRadius(int windowRadius) override;
121
122 int borderWidth() const override;
123 void setBorderWidth(int borderWidth) override;
124 QColor borderColor() const override;
125 void setBorderColor(const QColor &borderColor) override;
126 int shadowRadius() const override;
127 void setShadowRadius(int shadowRadius) override;
128 QPoint shadowOffset() const override;
129 void setShadowOffset(const QPoint &shadowOffset) override;
130 QColor shadowColor() const override;
131 void setShadowColor(const QColor &shadowColor) override;
132
133 bool enableBlurWindow() const override;
134 void setEnableBlurWindow(bool enableBlurWindow) override;
135
136 DPlatformHandle::EffectScene windowEffect() override;
137 void setWindowEffect(DPlatformHandle::EffectScenes effectScene) override;
138
139 void setWindowBlurAreas(const QVector<DPlatformHandle::WMBlurArea> &areas);
140 void setWindowBlurPaths(const QList<QPainterPath> &paths);
141};
142
143DGUI_END_NAMESPACE
144
145#endif // DTREELANDPLATFORMWINDOWINTERFACE_H
Definition treelandbackgroundeffectclientextension.h:50
一个和Qt dxcb平台插件交互的工具类.
Definition dplatformhandle.h:24
Definition dplatformwindowinterface_p.h:16
Definition dtreelandplatformwindowinterface.h:18
Definition dtreelandplatformwindowinterface.h:107
Definition treelanddecorationclientextension.h:41
Definition main.cpp:22