| 1 |
// SPDX-FileCopyrightText: 2022-2024 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#include "dplatformhandle.h" |
| 6 |
#include "dplatformwindowinterface_p.h" |
| 7 |
#include "dguiapplicationhelper.h" |
| 8 |
#ifndef DTK_DISABLE_XCB |
| 9 |
#include "plugins/platform/xcb/dxcbplatformwindowinterface.h" |
| 10 |
#endif |
| 11 |
#ifndef DTK_DISABLE_TREELAND |
| 12 |
#include "plugins/platform/treeland/dtreelandplatformwindowinterface.h" |
| 13 |
#endif |
| 14 |
|
| 15 |
DGUI_BEGIN_NAMESPACE |
| 16 |
|
| 17 |
static QHash<const DPlatformHandle*, DPlatformWindowInterface*> g_platformWindowImpls; |
| 18 |
|
| 19 |
static DPlatformWindowInterface *platformWindowImpl(const DPlatformHandle *platformHandle) |
| 20 |
{ |
| 21 |
return g_platformWindowImpls.value(platformHandle); |
| 22 |
} |
| 23 |
|
| 24 |
/*! |
| 25 |
\class Dtk::Gui::DPlatformHandle |
| 26 |
\inmodule dtkgui |
| 27 |
\brief 一个和Qt dxcb平台插件交互的工具类. |
| 28 |
|
| 29 |
实质性的功能皆在dxcb插件中实现,此插件目前只 |
| 30 |
支持X11平台,在其它平台上使用这个类不会有任何效果。关于dxcb:它介于Qt应用和Qt xcb平台 |
| 31 |
插件之间,通过覆写xcb插件中某些对象的虚函数来改变它的一些行为,本质上来讲是Qt xcb插件的 |
| 32 |
扩展,在X11平台上为DTK应用提供了一些改变窗口效果的功能(比如自定义窗口的边框)、其它和平 |
| 33 |
台密切相关的实现(比如修复Qt应用在X11平台的一些bug),不能脱离Qt xcb插件独立运行。dxcb |
| 34 |
通过重载 QPlatformNativeInterface 提供接口,DPlatformHandle 中使用 |
| 35 |
QGuiApplication::platformFunction 调用这些接口。Application、dxcb、qt xcb 之间 |
| 36 |
的关系: |
| 37 |
\raw HTML |
| 38 |
<pre style="font-family: FreeMono, Consolas, Menlo, 'Noto Mono', 'Courier New', Courier, monospace;line-height: 100%;"> |
| 39 |
┏━━━━━━━━━━━━━━━━┓ |
| 40 |
┃ Application ┃ |
| 41 |
┗━━━━━━━━━━━━━━━━┛ |
| 42 |
⇅ |
| 43 |
┏━━━━━━━━━━━━━━━━━━━━┓ |
| 44 |
┃ dxcb plugin ┃ |
| 45 |
┗━━━━━━━━━━━━━━━━━━━━┛ |
| 46 |
⇅ |
| 47 |
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ |
| 48 |
┃ qt xcb platform ┃ |
| 49 |
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ |
| 50 |
</pre> |
| 51 |
\endraw |
| 52 |
|
| 53 |
\ref {http://doc.qt.io/qt-5/qpa.html}{QPA} |
| 54 |
\ref {https://github.com/linuxdeepin/qt5dxcb-plugin/}{dxcb插件} |
| 55 |
\sa Dtk::Gui::DPlatformHandle::isDXcbPlatform |
| 56 |
\sa QGuiApplication::platformNativeInterface |
| 57 |
\sa Dtk::Widget::DMainWindow |
| 58 |
\sa DWindowManagerHelper |
| 59 |
\warning 使用此工具前要确保应用加载了dxcb插件 |
| 60 |
\warning 因为 QGuiApplication::platformFunction 是在 Qt 5.4.0 版本引入的新接口, |
| 61 |
所以 DPlatformHandle 不支持 Qt 5.4.0 以下版本。 |
| 62 |
*/ |
| 63 |
|
| 64 |
/*! |
| 65 |
\property DPlatformHandle::windowRadius |
| 66 |
\brief 窗口的圆角半径。默认情况下,窗口管理器支持混成时,圆角半径为4,否则为0,并且 |
| 67 |
会随着窗口管理器开启/关闭混成效果而变化 |
| 68 |
\note 可读可写 |
| 69 |
\note 窗口为半屏、全屏或最大化状态时此值不生效 |
| 70 |
\warning 手动设置值后将无法再随着窗口管理器是否支持混成而自动更新边框宽度 |
| 71 |
\sa DWindowManagerHelper::hasComposite |
| 72 |
*/ |
| 73 |
|
| 74 |
/*! |
| 75 |
\property DPlatformHandle::borderWidth |
| 76 |
\brief 窗口的外边框宽度。默认情况下,窗口管理器支持混成时,边框宽度为1,否则对于可以 |
| 77 |
改变大小的窗口其值为2,否则为1,并且会随着窗口管理器开启/关闭混成效果而变化 |
| 78 |
\note 可读可写 |
| 79 |
\warning 手动设置值后将无法再随着窗口管理器是否支持混成而自动更新边框宽度 |
| 80 |
\sa DWindowManagerHelper::hasComposite |
| 81 |
*/ |
| 82 |
|
| 83 |
/*! |
| 84 |
\property DPlatformHandle::borderColor |
| 85 |
\brief 窗口外边框的颜色。默认情况下,窗口管理器支持混成时,颜色为 QColor(0, 0, 0, 255 * 0.15), |
| 86 |
否则为边框颜色和 #e0e0e0 的混合,并且会随着窗口管理器开启/关闭混成效果而变化 |
| 87 |
\note 可读可写 |
| 88 |
\sa DWindowManagerHelper::hasComposite |
| 89 |
*/ |
| 90 |
|
| 91 |
/*! |
| 92 |
\property DPlatformHandle::shadowRadius |
| 93 |
\brief 窗口的阴影半径。默认为 60 |
| 94 |
\note 可读可写 |
| 95 |
\note 窗口管理器不支持混成时此值无效 |
| 96 |
\sa DWindowManagerHelper::hasComposite |
| 97 |
*/ |
| 98 |
|
| 99 |
/*! |
| 100 |
\property DPlatformHandle::shadowOffset |
| 101 |
\brief 窗口阴影的偏移量。默认为 QPoint(0,16) |
| 102 |
\note 可读可写 |
| 103 |
\note 窗口管理器不支持混成时此值无效 |
| 104 |
\sa DWindowManagerHelper::hasComposite |
| 105 |
*/ |
| 106 |
|
| 107 |
/*! |
| 108 |
\property DPlatformHandle::shadowColor |
| 109 |
\brief 窗口阴影的颜色。默认为 QColor(0, 0, 0, 255 * 0.6) |
| 110 |
\note 可读可写 |
| 111 |
\note 窗口管理器不支持混成时此值无效 |
| 112 |
\sa DWindowManagerHelper::hasComposite |
| 113 |
*/ |
| 114 |
|
| 115 |
/*! |
| 116 |
\property DPlatformHandle::clipPath |
| 117 |
\brief 窗口的裁剪区域。处于路径内部的区域为窗口有效区域,非有效区域内的窗口内容 |
| 118 |
将无法显示,并且无法收到鼠标和触摸事件。示例: |
| 119 |
\code |
| 120 |
QWidget w; |
| 121 |
QPainterPath path; |
| 122 |
QFont font; |
| 123 |
|
| 124 |
font.setPixelSize(100); |
| 125 |
path.addText(0, 150, font, "deepin"); |
| 126 |
|
| 127 |
DPlatformHandle handle(&w); |
| 128 |
|
| 129 |
handle.setClipPath(path); |
| 130 |
w.resize(400, 200); |
| 131 |
w.show(); |
| 132 |
\endcode |
| 133 |
\image clip_window_demo.gif |
| 134 |
\note 可读可写 |
| 135 |
\note 窗口的阴影和外边框绘制和其有效区域密切相关 |
| 136 |
\warning 设置此属性后将导致 DPlatformHandle::windowRadius 失效 |
| 137 |
*/ |
| 138 |
|
| 139 |
/*! |
| 140 |
\property DPlatformHandle::frameMask |
| 141 |
\brief 设置 Frame Window 的遮罩,和 \a clipPath 不同的是,它的裁剪包括阴影 |
| 142 |
部分。示例: |
| 143 |
\code |
| 144 |
QWidget w; |
| 145 |
DPlatformHandle handle(&w); |
| 146 |
|
| 147 |
// 为何更好的观察效果,此处将阴影改为蓝色 |
| 148 |
handle.setShadowColor(Qt::blue); |
| 149 |
w.resize(400, 200); |
| 150 |
w.show(); |
| 151 |
QRect frame_rect = w.rect() + handle.frameMargins(); |
| 152 |
frame_rect.moveTopLeft(QPoint(0, 0)); |
| 153 |
handle.setFrameMask(QRegion(frame_rect, QRegion::Ellipse)); |
| 154 |
\endcode |
| 155 |
\image frame_mask_demo.png |
| 156 |
\note 可读可写 |
| 157 |
\note 由于实现机制限制,使用此属性裁剪 Frame Window 时,无法去除边缘产生的锯齿 |
| 158 |
*/ |
| 159 |
|
| 160 |
/*! |
| 161 |
\property DPlatformHandle::frameMargins |
| 162 |
\brief Sub Window 相对于 Frame Window 的边距 |
| 163 |
\image frame_margins.png |
| 164 |
\note 只读 |
| 165 |
\warning 在窗口隐藏时不保证此值的正确性 |
| 166 |
*/ |
| 167 |
|
| 168 |
/*! |
| 169 |
\property DPlatformHandle::translucentBackground |
| 170 |
\brief 如果此属性值为 true,则在更新窗口绘制内容之前会先清空要更新区域内的图像, |
| 171 |
否则不清空,默认为 false |
| 172 |
\note 可读可写 |
| 173 |
*/ |
| 174 |
|
| 175 |
/*! |
| 176 |
\property DPlatformHandle::enableSystemResize |
| 177 |
\brief 如果此属性值为 true,则允许外界改变窗口的大小(如使用鼠标拖拽窗口边框), |
| 178 |
否则不允许。默认为 true |
| 179 |
\note 无论属性值是多少,Qt::Popup 和 Qt::BypassWindowManagerHint 类型的 |
| 180 |
窗口都不允许改变大小 |
| 181 |
\note 可读可写 |
| 182 |
\note 此属性仅仅控制 dxcb 中的行为,不会影响窗口管理器的行为 |
| 183 |
\sa QWidget::setFixedSize |
| 184 |
\sa QWindow::setMinimumSize |
| 185 |
\sa QWindow::setMaximumSize |
| 186 |
\sa DWindowManagerHelper::FUNC_RESIZE |
| 187 |
*/ |
| 188 |
|
| 189 |
/*! |
| 190 |
\property DPlatformHandle::enableSystemMove |
| 191 |
\brief 如果此属性值为 ture,则允许外界移动窗口的位置(如使用鼠标拖拽移动窗口), |
| 192 |
否则不允许。默认为 true |
| 193 |
\note 无论属性值是多少,Qt::Popup 和 Qt::BypassWindowManagerHint 类型的 |
| 194 |
窗口都不允许改变大小 |
| 195 |
\note 可读可写 |
| 196 |
\note 此属性仅仅控制 dxcb 中的行为,不会影响窗口管理器的行为 |
| 197 |
\sa DWindowManagerHelper::FUNC_MOVE |
| 198 |
*/ |
| 199 |
|
| 200 |
/*! |
| 201 |
\property DPlatformHandle::enableBlurWindow |
| 202 |
\brief 如果此属性为 true,则窗口有效区域内的背景将呈现出模糊效果,否则无特效。 |
| 203 |
默认为 false |
| 204 |
\note 可读可写 |
| 205 |
\sa DPlatformHandle::setWindowBlurAreaByWM |
| 206 |
*/ |
| 207 |
|
| 208 |
/*! |
| 209 |
\property DPlatformHandle::autoInputMaskByClipPath |
| 210 |
\brief 如果此属性值为 true,则窗口可输入区域跟随其 \a clipPath 属性,否则不 |
| 211 |
跟随。默认为 true |
| 212 |
\note 可输入区域指可接收鼠标或触摸事件的区域 |
| 213 |
\note 可读可写 |
| 214 |
*/ |
| 215 |
|
| 216 |
/*! |
| 217 |
\property DPlatformHandle::realWindowId |
| 218 |
\brief Sub Window 的窗口 id,直接使用 QWindow::winId 或 QWidget::winId |
| 219 |
获取到的是 Frame Window 的窗口 id |
| 220 |
\note 只读 |
| 221 |
*/ |
| 222 |
|
| 223 |
/*! |
| 224 |
\fn void DPlatformHandle::frameMarginsChanged() |
| 225 |
\brief 信号会在 frameMargins 属性的值改变时被发送. |
| 226 |
*/ |
| 227 |
/*! |
| 228 |
\fn void DPlatformHandle::windowRadiusChanged() |
| 229 |
\brief 信号会在 windowRadius 属性的值改变时被发送 |
| 230 |
*/ |
| 231 |
/*! |
| 232 |
\fn void DPlatformHandle::borderWidthChanged() |
| 233 |
\brief 信号会在 borderWidth 属性的值改变时被发送 |
| 234 |
*/ |
| 235 |
/*! |
| 236 |
\fn void DPlatformHandle::borderColorChanged() |
| 237 |
\brief 信号会在 borderColor 属性的值改变时被发送 |
| 238 |
*/ |
| 239 |
/*! |
| 240 |
\fn void DPlatformHandle::shadowRadiusChanged() |
| 241 |
\brief 信号会在 shadowRadius 属性的值改变时被发送 |
| 242 |
*/ |
| 243 |
/*! |
| 244 |
\fn void DPlatformHandle::shadowOffsetChanged() |
| 245 |
\brief 信号会在 shadowOffset 属性的值改变时被发送 |
| 246 |
*/ |
| 247 |
/*! |
| 248 |
\fn void DPlatformHandle::shadowColorChanged() |
| 249 |
\brief 信号会在 shadowColor 属性的值改变时被发送 |
| 250 |
*/ |
| 251 |
/*! |
| 252 |
\fn void DPlatformHandle::clipPathChanged() |
| 253 |
\brief 信号会在 clipPath 属性的值改变时被发送 |
| 254 |
*/ |
| 255 |
/*! |
| 256 |
\fn void DPlatformHandle::frameMaskChanged() |
| 257 |
\brief 信号会在 frameMask 属性的值改变时被发送 |
| 258 |
*/ |
| 259 |
/*! |
| 260 |
\fn void DPlatformHandle::translucentBackgroundChanged() |
| 261 |
\brief 信号会在 translucentBackground 属性的值改变时被发送 |
| 262 |
*/ |
| 263 |
/*! |
| 264 |
\fn void DPlatformHandle::enableSystemResizeChanged() |
| 265 |
\brief 信号会在 enableSystemResize 属性的值改变时被发送 |
| 266 |
*/ |
| 267 |
/*! |
| 268 |
\fn void DPlatformHandle::enableSystemMoveChanged() |
| 269 |
\brief 信号会在 enableSystemMove 属性的值改变时被发送 |
| 270 |
*/ |
| 271 |
/*! |
| 272 |
\fn void DPlatformHandle::enableBlurWindowChanged() |
| 273 |
\brief 信号会在 enableBlurWindow 属性的值改变时被发送 |
| 274 |
*/ |
| 275 |
/*! |
| 276 |
\fn void DPlatformHandle::autoInputMaskByClipPathChanged() |
| 277 |
\brief 信号会在 autoInputMaskByClipPath 属性的值改变时被发送 |
| 278 |
*/ |
| 279 |
|
| 280 |
/*! |
| 281 |
\class Dtk::Gui::DPlatformHandle::WMBlurArea |
| 282 |
\inmodule dtkgui |
| 283 |
|
| 284 |
\brief 描述窗口背景模糊区域的数据结构,包含位置、大小、圆角半径等信息. |
| 285 |
|
| 286 |
\var x |
| 287 |
水平方向的坐标 |
| 288 |
\var y |
| 289 |
竖直方向的坐标 |
| 290 |
\var width |
| 291 |
区域的宽度 |
| 292 |
\var height |
| 293 |
区域的高度 |
| 294 |
\var xRadius |
| 295 |
水平方向的圆角半径 |
| 296 |
\var yRaduis |
| 297 |
竖直方向的圆角半径 |
| 298 |
*/ |
| 299 |
|
| 300 |
static DPlatformWindowInterfaceFactory::Creator OutsideWindowInterfaceCreator = nullptr; |
| 301 |
|
| 302 |
void DPlatformWindowInterfaceFactory::registerInterface(Creator creator) |
| 303 |
{ |
| 304 |
OutsideWindowInterfaceCreator = creator; |
| 305 |
} |
| 306 |
|
| 307 |
static DPlatformWindowInterface *createWindowInterface(QWindow *window, DPlatformHandle *platformHandle) |
| 308 |
{ |
| 309 |
DPlatformWindowInterface *impl = nullptr; |
| 310 |
if (OutsideWindowInterfaceCreator) { |
| 311 |
impl = OutsideWindowInterfaceCreator(window, platformHandle); |
| 312 |
} |
| 313 |
if (!impl) { |
| 314 |
#ifndef DTK_DISABLE_XCB |
| 315 |
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsXWindowPlatform)) { |
| 316 |
impl = new DXCBPlatformWindowInterface(window, platformHandle); |
| 317 |
} |
| 318 |
#endif |
| 319 |
|
| 320 |
#ifndef DTK_DISABLE_TREELAND |
| 321 |
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { |
| 322 |
impl = new DTreeLandPlatformWindowInterface(window, platformHandle); |
| 323 |
} |
| 324 |
#endif |
| 325 |
} |
| 326 |
|
| 327 |
return impl; |
| 328 |
} |
| 329 |
|
| 330 |
/*! |
| 331 |
\brief DPlatformHandle::DPlatformHandle |
| 332 |
将 \a window 对象传递给 enableDXcbForWindow |
| 333 |
\a window 要开启DTK风格的主窗口 |
| 334 |
\a parent DPlatformHandle 对象的父对象 |
| 335 |
\sa DPlatformHandle::enableDXcbForWindow(QWindow *) |
| 336 |
*/ |
| 337 |
DPlatformHandle::DPlatformHandle(QWindow *window, QObject *parent) |
| 338 |
: QObject(parent) |
| 339 |
, m_window(window) |
| 340 |
{ |
| 341 |
auto impl = createWindowInterface(window, this); |
| 342 |
if (!impl) { |
| 343 |
qDebug() << "Use default DPlatformWindowInterface for the window" << window->winId(); |
| 344 |
impl = new DPlatformWindowInterface(window, this); |
| 345 |
} |
| 346 |
g_platformWindowImpls.insert(this, impl); |
| 347 |
|
| 348 |
impl->setEnabled(true); |
| 349 |
} |
| 350 |
|
| 351 |
DPlatformHandle::~DPlatformHandle() |
| 352 |
{ |
| 353 |
if (auto item = g_platformWindowImpls.take(this)) { |
| 354 |
delete item; |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 358 |
/*! |
| 359 |
\brief DPlatformHandle::pluginVersion |
| 360 |
\return 返回dxcb插件的版本 |
| 361 |
\note 在旧版dxcb插件中未实现获取版本的接口,将会返回一个空的 QString 对象 |
| 362 |
*/ |
| 363 |
QString DPlatformHandle::pluginVersion() |
| 364 |
{ |
| 365 |
#ifndef DTK_DISABLE_XCB |
| 366 |
return DXCBPlatformWindowInterface::pluginVersion(); |
| 367 |
#else |
| 368 |
return {}; |
| 369 |
#endif |
| 370 |
} |
| 371 |
|
| 372 |
/*! |
| 373 |
\brief DPlatformHandle::isDXcbPlatform 检查当前程序是否使用了dxcb平台插件。 |
| 374 |
\return 正在使用返回 true,否则返回 false。 |
| 375 |
*/ |
| 376 |
bool DPlatformHandle::isDXcbPlatform() |
| 377 |
{ |
| 378 |
#ifndef DTK_DISABLE_XCB |
| 379 |
return DXCBPlatformWindowInterface::isDXcbPlatform(); |
| 380 |
#else |
| 381 |
return false; |
| 382 |
#endif |
| 383 |
} |
| 384 |
|
| 385 |
/*! |
| 386 |
\brief DPlatformHandle::enableDXcbForWindow |
| 387 |
将 QWindow 的窗口装饰设置为 DTK 风格,这将使用 Qt::FramelessWindowHint 去除本地窗口管理器 |
| 388 |
给窗口附加的边框修饰以及窗口阴影效果,并且,会创建一个对应的本地窗口(在X11平台就是指X Window) |
| 389 |
作为此窗口的父窗口,父窗口(Frame Window)中将根据子窗口(Sub Window)的有效区域绘制阴影和边 |
| 390 |
框等效果,默认情况下,子窗口的有效区域为一个圆角矩形,结构如下: |
| 391 |
\raw HTML |
| 392 |
<pre style="font-family: FreeMono, Consolas, Menlo, 'Noto Mono', 'Courier New', Courier, monospace;line-height: 100%;"> |
| 393 |
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ |
| 394 |
┃ Frame Window ┃ |
| 395 |
┃ ┃ |
| 396 |
┃ ┃ |
| 397 |
┃ ╭┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅╮ ┃ |
| 398 |
┃ ┋ Sub Window ┋ ┃ |
| 399 |
┃ ┋ ┋ ┃ |
| 400 |
┃ ┋ ┋ ┃ |
| 401 |
┃ ┋ ┋ ┃ |
| 402 |
┃ ┋ ┋ ┃ |
| 403 |
┃ ┋ ┋ ┃ |
| 404 |
┃ ┋ ┋ ┃ |
| 405 |
┃ ┋ ┋ ┃ |
| 406 |
┃ ┋ ┋ ┃ |
| 407 |
┃ ╰┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅╯ ┃ |
| 408 |
┃ ┃ |
| 409 |
┃ ┃ |
| 410 |
┃ ┃ |
| 411 |
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ |
| 412 |
</pre> |
| 413 |
\endraw |
| 414 |
|
| 415 |
但是,如果窗口管理器自身支持隐藏窗口标题栏,则此方法将优先调用 enableNoTitlebarForWindow 实现同样的效果。 |
| 416 |
|
| 417 |
例子: |
| 418 |
\code |
| 419 |
QWidget w1; |
| 420 |
|
| 421 |
w1.setWindowTitle("使用系统边框的窗口"); |
| 422 |
w1.show(); |
| 423 |
|
| 424 |
DMainWindow w2; |
| 425 |
QWidget w3; |
| 426 |
|
| 427 |
w2.titlebar()->setTitle("使用DTK风格边框带标题栏的窗口"); |
| 428 |
w3.setWindowTitle("使用DTK风格边框没有标题栏的窗口"); |
| 429 |
w2.show(); |
| 430 |
|
| 431 |
DPlatformHandle::enableDXcbForWindow(&w3); |
| 432 |
w3.show(); // 因为这个窗口没有标题栏,所以不会显示窗口标题 |
| 433 |
|
| 434 |
\endcode |
| 435 |
\image dtk_and_system_window.jpeg |
| 436 |
开启了dxcb的窗口,在窗口外边缘10像素的范围按下鼠标左键可以触发改变窗口大小的行为, |
| 437 |
而且会自动将鼠标吸附到对应的窗口边缘,增强了拖拽改变窗口大小的体验。效果: |
| 438 |
\image dtk_window_cursor_effect.gif |
| 439 |
另外,所有到达主窗口的鼠标移动事件如果没有调用 QEvent::accepted ,则会触发主窗 |
| 440 |
口的移动效果,默认情况下,一个没有子控件的DTK窗口,如果没有重写 QWidget::mouseMoveEvent , |
| 441 |
则使用鼠标左键在窗口的任意地方按住并移动都会触发移动窗口的动作。如: |
| 442 |
\code |
| 443 |
class Window : public QWidget |
| 444 |
{ |
| 445 |
public: |
| 446 |
explicit Window() { |
| 447 |
|
| 448 |
} |
| 449 |
|
| 450 |
protected: |
| 451 |
void mouseMoveEvent(QMouseEvent *event) override { |
| 452 |
event->accept(); |
| 453 |
} |
| 454 |
}; |
| 455 |
\endcode |
| 456 |
\code |
| 457 |
Window w; |
| 458 |
DPlatformHandle::enableDXcbForWindow(&w); |
| 459 |
w.show(); |
| 460 |
\endcode |
| 461 |
将无法使用鼠标移动窗口w |
| 462 |
|
| 463 |
窗口管理器(如X11平台上的Window Manager)是否支持混成会影响dxcb插件对窗口添加的默认装饰。 |
| 464 |
\note 在 Deepin 桌面环境中,打开窗口特效则支持混成,关闭窗口特效则不支持混成 |
| 465 |
|
| 466 |
支持混成: |
| 467 |
\image enable_composite.png |
| 468 |
不支持混成: |
| 469 |
\image disable_composite.png |
| 470 |
并且,在不支持混成的窗口管理器中,上述“窗口边缘的鼠标吸附”效果也会被禁用。可以使用 |
| 471 |
DWindowManagerHelper::hasComposite 或 QX11Info::isCompositingManagerRunning |
| 472 |
判断当前运行的窗口管理器是否支持混成。 |
| 473 |
\a window |
| 474 |
\sa Dtk::Gui::DPlatformHandle::setEnabledNoTitlebarForWindow() |
| 475 |
*/ |
| 476 |
void DPlatformHandle::enableDXcbForWindow(QWindow *window) |
| 477 |
{ |
| 478 |
DPlatformHandle handle(window); |
| 479 |
auto impl = platformWindowImpl(&handle); |
| 480 |
impl->setEnabled(true); |
| 481 |
} |
| 482 |
|
| 483 |
/*! |
| 484 |
\brief DPlatformHandle::enableDXcbForWindow |
| 485 |
功能上和 DPlatformHandle::enableDXcbForWindow(QWindow *) 一致. |
| 486 |
|
| 487 |
\a window |
| 488 |
\a redirectContent 如果值为 true,Sub Window 将不可见,且它的绘制内容会 |
| 489 |
被合成到外层的 Frame Window(它的父窗口),否则 Sub Window 和 Frame Window |
| 490 |
会分开绘制和显示。默认情况下只需要使用 DPlatformHandle::enableDXcbForWindow(QWindow *), |
| 491 |
dxcb插件中会自动根据窗口渲染类型选择使用更合适的实现方式,使用 OpenGL 渲染的窗口将开启 |
| 492 |
redirectContent 模式。 |
| 493 |
\note 如果窗口内嵌入了其它的本地窗口(如X11平台的X Window),默认情况下,这个窗口 |
| 494 |
绘制的内容不受dxcb插件的控制,它的绘制内容可能会超过 Sub Window 的有效区域,这种 |
| 495 |
情况下,应该使用此接口,并将 redirectContent 指定为 true。 |
| 496 |
|
| 497 |
\ref {https://www.x.org/releases/X11R7.5/doc/damageproto/damageproto.txt}{X11 Damage} |
| 498 |
*/ |
| 499 |
void DPlatformHandle::enableDXcbForWindow(QWindow *window, bool redirectContent) |
| 500 |
{ |
| 501 |
DPlatformHandle handle(window); |
| 502 |
#ifndef DTK_DISABLE_XCB |
| 503 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(&handle))) { |
| 504 |
impl->enableDXcb(redirectContent); |
| 505 |
} |
| 506 |
#endif |
| 507 |
} |
| 508 |
|
| 509 |
/*! |
| 510 |
\brief DPlatformHandle::isEnabledDXcb. |
| 511 |
|
| 512 |
\return 如果窗口 \a window 开启了DTK风格的窗口修饰则返回 true,否则返回 false |
| 513 |
\sa DPlatformHandle::isEnabledNoTitlebar() |
| 514 |
*/ |
| 515 |
bool DPlatformHandle::isEnabledDXcb(const QWindow *window) |
| 516 |
{ |
| 517 |
DPlatformHandle handle(const_cast<QWindow *>(window)); |
| 518 |
auto impl = platformWindowImpl(&handle); |
| 519 |
return impl->isEnabled(); |
| 520 |
} |
| 521 |
|
| 522 |
/*! |
| 523 |
\brief DPlatformHandle::setEnabledNoTitlebarForWindow. |
| 524 |
|
| 525 |
使用窗口管理器提供的方式隐藏窗口的标题栏,目前已适配 DDE KWin 窗管,在窗口管理器支持的前提下, |
| 526 |
此方法将通过设置窗口属性 _DEEPIN_SCISSOR_WINDOW 的值为 1 来开启无标题栏效果。 |
| 527 |
\a window 被设置的 QWindow 实例. |
| 528 |
\a enable 是否开启无标题属性. |
| 529 |
\return 设置成功返回 true,否则返回false. |
| 530 |
|
| 531 |
\sa DPlatformHandle::enableDXcbForWindow() |
| 532 |
\sa DWindowManagerHelper::hasNoTitlebar() |
| 533 |
*/ |
| 534 |
bool DPlatformHandle::setEnabledNoTitlebarForWindow(QWindow *window, bool enable) |
| 535 |
{ |
| 536 |
DPlatformHandle handle(window); |
| 537 |
auto impl = platformWindowImpl(&handle); |
| 538 |
return impl->setEnabledNoTitlebar(enable); |
| 539 |
} |
| 540 |
|
| 541 |
/*! |
| 542 |
\brief DPlatformHandle::isEnableNoTitlebar |
| 543 |
\a window |
| 544 |
\return 如果窗口使用窗管提供的方式隐藏了标题栏则返回 true,否则返回 false |
| 545 |
\sa DPlatformHandle::isEnabledDXcb |
| 546 |
*/ |
| 547 |
bool DPlatformHandle::isEnabledNoTitlebar(const QWindow *window) |
| 548 |
{ |
| 549 |
DPlatformHandle handle(const_cast<QWindow *>(window)); |
| 550 |
auto impl = platformWindowImpl(&handle); |
| 551 |
return impl->isEnabledNoTitlebar(); |
| 552 |
} |
| 553 |
|
| 554 |
/*! |
| 555 |
\brief DPlatformHandle::setWindowBlurAreaByWM |
| 556 |
设置窗口背景的模糊区域,示例: |
| 557 |
\code |
| 558 |
QWindow w; |
| 559 |
QVector<DPlatformHandle::WMBlurArea> area_list; |
| 560 |
DPlatformHandle::WMBlurArea area; |
| 561 |
|
| 562 |
area.x = 50; |
| 563 |
area.y = 50; |
| 564 |
area.width = 200; |
| 565 |
area.height = 200; |
| 566 |
area.xRadius = 10; |
| 567 |
area.yRaduis = 10; |
| 568 |
area_list.append(area); |
| 569 |
|
| 570 |
DPlatformHandle::setWindowBlurAreaByWM(&w, area_list); |
| 571 |
|
| 572 |
QSurfaceFormat format = w.format(); |
| 573 |
format.setAlphaBufferSize(8); |
| 574 |
|
| 575 |
w.setFormat(format); |
| 576 |
w.resize(300, 300); |
| 577 |
w.show(); |
| 578 |
|
| 579 |
\endcode |
| 580 |
\image blur_window_demo1.png |
| 581 |
\a window 目标窗口对象 |
| 582 |
\a area 模糊区域,此区域范围内的窗口背景将填充为窗口后面内容模糊之后的图像 |
| 583 |
\return 如果设置成功则返回 true,否则返回 false |
| 584 |
\note 对于需要显示模糊背景的窗口,需要将其 QSurfaceFormat 的 alpha 通道设置为8 |
| 585 |
\note 调用此接口设置窗口背景模糊区域后将覆盖之前所设置的区域,包括调用 |
| 586 |
setWindowBlurAreaByWM(QWindow *, const QList<QPainterPath> &) |
| 587 |
所设置的区域 |
| 588 |
\note 建议使用 DBlurEffectWidget 实现窗口背景模糊效果 |
| 589 |
\note 此功能依赖于窗口管理器的实现,目前仅支持 deepin-wm 和 kwin 这两个窗口管理器 |
| 590 |
\sa Dtk::Widget::DBlurEffectWidget |
| 591 |
\sa QSurfaceFormat::setAlphaBufferSize |
| 592 |
\sa QWindow::setFormat |
| 593 |
\sa DWindowManagerHelper::hasBlurWindow |
| 594 |
\sa DPlatformHandle::setWindowBlurAreaByWM(QWindow *, const QList<QPainterPath> &) |
| 595 |
*/ |
| 596 |
bool DPlatformHandle::setWindowBlurAreaByWM(QWindow *window, const QVector<DPlatformHandle::WMBlurArea> &area) |
| 597 |
{ |
| 598 |
DPlatformHandle handle(const_cast<QWindow *>(window)); |
| 599 |
#ifndef DTK_DISABLE_XCB |
| 600 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(&handle))) { |
| 601 |
return impl->setWindowBlurArea(area); |
| 602 |
} |
| 603 |
#endif |
| 604 |
handle.setEnableBlurWindow(true); |
| 605 |
return true; |
| 606 |
} |
| 607 |
|
| 608 |
/*! |
| 609 |
\brief DPlatformHandle::setWindowBlurAreaByWM |
| 610 |
设置窗口背景的模糊区域,使用 QPainterPath 描述模糊区域,使用起来更加的灵活,可以 |
| 611 |
实现任何形状,但是性能要低于使用 QVector<DPlatformHandle::WMBlurArea> |
| 612 |
描述模糊区域。示例: |
| 613 |
\code |
| 614 |
QWindow w; |
| 615 |
QList<QPainterPath> path_list; |
| 616 |
QPainterPath path; |
| 617 |
QFont font; |
| 618 |
|
| 619 |
font.setPixelSize(100); |
| 620 |
font.setBold(true); |
| 621 |
path.addText(0, 150, font, "deepin"); |
| 622 |
path_list.append(path); |
| 623 |
|
| 624 |
DPlatformHandle::setWindowBlurAreaByWM(&w, path_list); |
| 625 |
|
| 626 |
QSurfaceFormat format = w.format(); |
| 627 |
format.setAlphaBufferSize(8); |
| 628 |
|
| 629 |
w.setFormat(format); |
| 630 |
w.resize(300, 300); |
| 631 |
w.show(); |
| 632 |
|
| 633 |
\endcode |
| 634 |
\image blur_window_demo2.png |
| 635 |
\a window 目标窗口对象 |
| 636 |
\a paths 模糊区域,此区域范围内的窗口背景将填充为窗口后面内容模糊之后的图像 |
| 637 |
\return 如果设置成功则返回 true,否则返回 false |
| 638 |
\note 调用此接口设置窗口背景模糊区域后将覆盖之前所设置的区域,包括调用 |
| 639 |
setWindowBlurAreaByWM(QWindow *, QVector<DPlatformHandle::WMBlurArea> &) |
| 640 |
设置的窗口背景模糊路径 |
| 641 |
\note 对于需要显示模糊背景的窗口,需要将其 QSurfaceFormat 的 alpha 通道设置为8 |
| 642 |
\note 建议使用 DBlurEffectWidget 实现窗口背景模糊效果 |
| 643 |
\note 此功能依赖于窗口管理器的实现,目前仅支持 deepin-wm 和 kwin 这两个窗口管理器 |
| 644 |
\warning setWindowBlurAreaByWM(QWindow *, QVector<DPlatformHandle::WMBlurArea> &) |
| 645 |
能满足需求请不要使用此接口 |
| 646 |
\sa Dtk::Widget::DBlurEffectWidget |
| 647 |
\sa QSurfaceFormat::setAlphaBufferSize |
| 648 |
\sa QWindow::setFormat |
| 649 |
\sa DWindowManagerHelper::hasBlurWindow |
| 650 |
\sa DPlatformHandle::setWindowBlurAreaByWM() |
| 651 |
*/ |
| 652 |
bool DPlatformHandle::setWindowBlurAreaByWM(QWindow *window, const QList<QPainterPath> &paths) |
| 653 |
{ |
| 654 |
DPlatformHandle handle(const_cast<QWindow *>(window)); |
| 655 |
#ifndef DTK_DISABLE_XCB |
| 656 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(&handle))) { |
| 657 |
return impl->setWindowBlurArea(paths); |
| 658 |
} |
| 659 |
#endif |
| 660 |
handle.setEnableBlurWindow(true); |
| 661 |
return true; |
| 662 |
} |
| 663 |
|
| 664 |
/*! |
| 665 |
\brief DPlatformHandle::setWindowWallpaperParaByWM |
| 666 |
设置窗口背景壁纸,示例: |
| 667 |
\code |
| 668 |
QWindow w; |
| 669 |
QRect area; |
| 670 |
WallpaperScaleMode sMode |
| 671 |
WallpaperFillMode fMode |
| 672 |
|
| 673 |
area.setRect(50, 50, 200, 200); |
| 674 |
bMode = WallpaperScaleFlag::FollowWindow | WallpaperFillFlag::PreserveAspectCrop; |
| 675 |
|
| 676 |
DPlatformHandle::setWindowWallpaperParaByWM(&w, area, bMode); |
| 677 |
|
| 678 |
QSurfaceFormat format = w.format(); |
| 679 |
format.setAlphaBufferSize(8); |
| 680 |
|
| 681 |
w.setFormat(format); |
| 682 |
w.resize(300, 300); |
| 683 |
w.show(); |
| 684 |
|
| 685 |
\endcode |
| 686 |
\a window 目标窗口对象 |
| 687 |
\a area 壁纸区域,此区域范围内的窗口背景将填充为用户设置的当前工作区窗口壁纸 |
| 688 |
\~Chinese \a sMode 控制壁纸缩放是随屏幕还是随窗口 |
| 689 |
\~Chinese \a fMode 控制壁纸是缩放还是裁剪 |
| 690 |
\return 如果设置成功则返回 true,否则返回 false |
| 691 |
\note 对于需要显示opengl壁纸特效的窗口,需要将其 QSurfaceFormat 的 alpha 通道设置为8 |
| 692 |
\note 需要在window handle有效之后调用否则3d下失效 |
| 693 |
\note 调用此接口设置窗口背景壁纸区域后将覆盖之前所设置的区域 |
| 694 |
\note 此功能依赖于窗口管理器的实现,目前仅支持 kwin 窗口管理器 |
| 695 |
\sa Dtk::Widget::DBlurEffectWidget |
| 696 |
\sa QSurfaceFormat::setAlphaBufferSize |
| 697 |
\sa QWindow::setFormat |
| 698 |
\sa DWindowManagerHelper::hasBlurWindow |
| 699 |
\sa DPlatformHandle::setWindowBlurAreaByWM(QWindow *, const QList<QPainterPath> &) |
| 700 |
*/ |
| 701 |
bool DPlatformHandle::setWindowWallpaperParaByWM(QWindow *window, const QRect &area, WallpaperScaleMode sMode, WallpaperFillMode fMode) |
| 702 |
{ |
| 703 |
DPlatformHandle handle(window); |
| 704 |
#ifndef DTK_DISABLE_XCB |
| 705 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(&handle))) { |
| 706 |
return impl->setWindowWallpaperPara(area, sMode, fMode); |
| 707 |
} |
| 708 |
#endif |
| 709 |
return false; |
| 710 |
} |
| 711 |
|
| 712 |
/*! |
| 713 |
\brief DPlatformHandle::connectWindowManagerChangedSignal |
| 714 |
将窗口管理器变化的信号链接到 \a object 对象的 \a slot 槽,建议使用 DWindowManager::windowManagerChanged |
| 715 |
\a object |
| 716 |
\a slot |
| 717 |
\return 如果链接成功则返回 true,否则返回 false |
| 718 |
\sa DWindowManagerHelper::windowManagerChanged() |
| 719 |
*/ |
| 720 |
bool DPlatformHandle::connectWindowManagerChangedSignal(QObject *object, std::function<void ()> slot) |
| 721 |
{ |
| 722 |
#ifndef DTK_DISABLE_XCB |
| 723 |
return DXCBPlatformWindowInterface::connectWindowManagerChangedSignal(object, slot); |
| 724 |
#endif |
| 725 |
return false; |
| 726 |
} |
| 727 |
|
| 728 |
/*! |
| 729 |
\brief DPlatformHandle::connectHasBlurWindowChanged |
| 730 |
将窗口管理器是否支持背景模糊的信号链接到 object 对象的 slot 槽,建议使用 |
| 731 |
DWindowManager::hasBlurWindowChanged |
| 732 |
\a object |
| 733 |
\a slot |
| 734 |
\return 如果链接成功则返回 true,否则返回 false |
| 735 |
\sa DWindowManagerHelper::hasBlurWindowChanged |
| 736 |
*/ |
| 737 |
bool DPlatformHandle::connectHasBlurWindowChanged(QObject *object, std::function<void ()> slot) |
| 738 |
{ |
| 739 |
#ifndef DTK_DISABLE_XCB |
| 740 |
return DXCBPlatformWindowInterface::connectHasBlurWindowChanged(object, slot); |
| 741 |
#endif |
| 742 |
return false; |
| 743 |
} |
| 744 |
|
| 745 |
/*! |
| 746 |
\brief DPlatformHandle::setWindowBlurAreaByWM |
| 747 |
这只是一个重载的函数,将调用 setWindowBlurAreaByWM(const QList<QPainterPath> &paths) |
| 748 |
并将构造对象时传递的主窗口当做第一个参数 |
| 749 |
\a area |
| 750 |
\return |
| 751 |
\sa DPlatformHandle::setWindowBlurAreaByWM(const QList<QPainterPath> &paths) |
| 752 |
*/ |
| 753 |
bool DPlatformHandle::setWindowBlurAreaByWM(const QVector<DPlatformHandle::WMBlurArea> &area) |
| 754 |
{ |
| 755 |
return setWindowBlurAreaByWM(m_window, area); |
| 756 |
} |
| 757 |
|
| 758 |
/*! |
| 759 |
\brief DPlatformHandle::setWindowBlurAreaByWM |
| 760 |
这只是一个重载的函数,将调用 setWindowBlurAreaByWM(const QVector<DPlatformHandle::WMBlurArea> &area) |
| 761 |
并将构造对象时传递的主窗口当做第一个参数 |
| 762 |
\a paths |
| 763 |
\return |
| 764 |
\sa DPlatformHandle::setWindowBlurAreaByWM() |
| 765 |
*/ |
| 766 |
bool DPlatformHandle::setWindowBlurAreaByWM(const QList<QPainterPath> &paths) |
| 767 |
{ |
| 768 |
return setWindowBlurAreaByWM(m_window, paths); |
| 769 |
} |
| 770 |
|
| 771 |
/*! |
| 772 |
\brief DPlatformHandle::setDisableWindowOverrideCursor |
| 773 |
如果 \a disable 为 true,则禁止窗口 \a window 改变光标样式,否则允许改变光标样式。 |
| 774 |
窗口被禁止改变光标样式后,使用 QWindow::setCursor 将不会产生任何效果。 |
| 775 |
\a window |
| 776 |
\a disable |
| 777 |
*/ |
| 778 |
void DPlatformHandle::setDisableWindowOverrideCursor(QWindow *window, bool disable) |
| 779 |
{ |
| 780 |
DPlatformHandle handler(window); |
| 781 |
#ifndef DTK_DISABLE_XCB |
| 782 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(&handler))) { |
| 783 |
impl->setDisableWindowOverrideCursor(disable); |
| 784 |
} |
| 785 |
#endif |
| 786 |
} |
| 787 |
|
| 788 |
int DPlatformHandle::windowRadius() const |
| 789 |
{ |
| 790 |
auto impl = platformWindowImpl(this); |
| 791 |
return impl->windowRadius(); |
| 792 |
} |
| 793 |
|
| 794 |
int DPlatformHandle::borderWidth() const |
| 795 |
{ |
| 796 |
auto impl = platformWindowImpl(this); |
| 797 |
return impl->borderWidth(); |
| 798 |
} |
| 799 |
|
| 800 |
QColor DPlatformHandle::borderColor() const |
| 801 |
{ |
| 802 |
auto impl = platformWindowImpl(this); |
| 803 |
return impl->borderColor(); |
| 804 |
} |
| 805 |
|
| 806 |
int DPlatformHandle::shadowRadius() const |
| 807 |
{ |
| 808 |
auto impl = platformWindowImpl(this); |
| 809 |
return impl->shadowRadius(); |
| 810 |
} |
| 811 |
|
| 812 |
QPoint DPlatformHandle::shadowOffset() const |
| 813 |
{ |
| 814 |
auto impl = platformWindowImpl(this); |
| 815 |
return impl->shadowOffset(); |
| 816 |
} |
| 817 |
|
| 818 |
QColor DPlatformHandle::shadowColor() const |
| 819 |
{ |
| 820 |
auto impl = platformWindowImpl(this); |
| 821 |
return impl->shadowColor(); |
| 822 |
} |
| 823 |
|
| 824 |
DPlatformHandle::EffectScene DPlatformHandle::windowEffect() |
| 825 |
{ |
| 826 |
auto impl = platformWindowImpl(this); |
| 827 |
return impl->windowEffect(); |
| 828 |
} |
| 829 |
|
| 830 |
DPlatformHandle::EffectType DPlatformHandle::windowStartUpEffect() |
| 831 |
{ |
| 832 |
auto impl = platformWindowImpl(this); |
| 833 |
return impl->windowStartUpEffect(); |
| 834 |
} |
| 835 |
|
| 836 |
QPainterPath DPlatformHandle::clipPath() const |
| 837 |
{ |
| 838 |
auto impl = platformWindowImpl(this); |
| 839 |
return impl->clipPath(); |
| 840 |
} |
| 841 |
|
| 842 |
QRegion DPlatformHandle::frameMask() const |
| 843 |
{ |
| 844 |
auto impl = platformWindowImpl(this); |
| 845 |
return impl->frameMask(); |
| 846 |
} |
| 847 |
|
| 848 |
QMargins DPlatformHandle::frameMargins() const |
| 849 |
{ |
| 850 |
auto impl = platformWindowImpl(this); |
| 851 |
return impl->frameMargins(); |
| 852 |
} |
| 853 |
|
| 854 |
bool DPlatformHandle::translucentBackground() const |
| 855 |
{ |
| 856 |
auto impl = platformWindowImpl(this); |
| 857 |
return impl->translucentBackground(); |
| 858 |
} |
| 859 |
|
| 860 |
bool DPlatformHandle::enableSystemResize() const |
| 861 |
{ |
| 862 |
auto impl = platformWindowImpl(this); |
| 863 |
return impl->enableSystemResize(); |
| 864 |
} |
| 865 |
|
| 866 |
bool DPlatformHandle::enableSystemMove() const |
| 867 |
{ |
| 868 |
auto impl = platformWindowImpl(this); |
| 869 |
return impl->enableSystemMove(); |
| 870 |
} |
| 871 |
|
| 872 |
bool DPlatformHandle::enableBlurWindow() const |
| 873 |
{ |
| 874 |
auto impl = platformWindowImpl(this); |
| 875 |
return impl->enableBlurWindow(); |
| 876 |
} |
| 877 |
|
| 878 |
bool DPlatformHandle::autoInputMaskByClipPath() const |
| 879 |
{ |
| 880 |
#ifndef DTK_DISABLE_XCB |
| 881 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(this))) { |
| 882 |
return impl->autoInputMaskByClipPath(); |
| 883 |
} |
| 884 |
#endif |
| 885 |
return false; |
| 886 |
} |
| 887 |
|
| 888 |
WId DPlatformHandle::realWindowId() const |
| 889 |
{ |
| 890 |
#ifndef DTK_DISABLE_XCB |
| 891 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(this))) { |
| 892 |
return impl->realWindowId(); |
| 893 |
} |
| 894 |
#endif |
| 895 |
return 0; |
| 896 |
} |
| 897 |
|
| 898 |
WId DPlatformHandle::windowLeader() |
| 899 |
{ |
| 900 |
#ifndef DTK_DISABLE_XCB |
| 901 |
return DXCBPlatformWindowInterface::windowLeader(); |
| 902 |
#endif |
| 903 |
return 0; |
| 904 |
} |
| 905 |
|
| 906 |
void DPlatformHandle::setWindowRadius(int windowRadius) |
| 907 |
{ |
| 908 |
auto impl = platformWindowImpl(this); |
| 909 |
impl->setWindowRadius(windowRadius); |
| 910 |
} |
| 911 |
|
| 912 |
void DPlatformHandle::setBorderWidth(int borderWidth) |
| 913 |
{ |
| 914 |
auto impl = platformWindowImpl(this); |
| 915 |
impl->setBorderWidth(borderWidth); |
| 916 |
} |
| 917 |
|
| 918 |
void DPlatformHandle::setBorderColor(const QColor &borderColor) |
| 919 |
{ |
| 920 |
auto impl = platformWindowImpl(this); |
| 921 |
impl->setBorderColor(borderColor); |
| 922 |
} |
| 923 |
|
| 924 |
void DPlatformHandle::setWindowEffect(DPlatformHandle::EffectScenes effectScene) |
| 925 |
{ |
| 926 |
auto impl = platformWindowImpl(this); |
| 927 |
impl->setWindowEffect(effectScene); |
| 928 |
} |
| 929 |
|
| 930 |
void DPlatformHandle::setWindowStartUpEffect(DPlatformHandle::EffectTypes effectType) |
| 931 |
{ |
| 932 |
auto impl = platformWindowImpl(this); |
| 933 |
impl->setWindowStartUpEffect(effectType); |
| 934 |
} |
| 935 |
|
| 936 |
void DPlatformHandle::setShadowRadius(int shadowRadius) |
| 937 |
{ |
| 938 |
auto impl = platformWindowImpl(this); |
| 939 |
impl->setShadowRadius(shadowRadius); |
| 940 |
} |
| 941 |
|
| 942 |
void DPlatformHandle::setShadowOffset(const QPoint &shadowOffset) |
| 943 |
{ |
| 944 |
auto impl = platformWindowImpl(this); |
| 945 |
impl->setShadowOffset(shadowOffset); |
| 946 |
} |
| 947 |
|
| 948 |
void DPlatformHandle::setShadowColor(const QColor &shadowColor) |
| 949 |
{ |
| 950 |
auto impl = platformWindowImpl(this); |
| 951 |
impl->setShadowColor(shadowColor); |
| 952 |
} |
| 953 |
|
| 954 |
void DPlatformHandle::setClipPath(const QPainterPath &clipPath) |
| 955 |
{ |
| 956 |
auto impl = platformWindowImpl(this); |
| 957 |
impl->setClipPath(clipPath); |
| 958 |
} |
| 959 |
|
| 960 |
void DPlatformHandle::setFrameMask(const QRegion &frameMask) |
| 961 |
{ |
| 962 |
auto impl = platformWindowImpl(this); |
| 963 |
impl->setFrameMask(frameMask); |
| 964 |
} |
| 965 |
|
| 966 |
void DPlatformHandle::setTranslucentBackground(bool translucentBackground) |
| 967 |
{ |
| 968 |
auto impl = platformWindowImpl(this); |
| 969 |
impl->setTranslucentBackground(translucentBackground); |
| 970 |
} |
| 971 |
|
| 972 |
void DPlatformHandle::setEnableSystemResize(bool enableSystemResize) |
| 973 |
{ |
| 974 |
auto impl = platformWindowImpl(this); |
| 975 |
impl->setEnableSystemResize(enableSystemResize); |
| 976 |
} |
| 977 |
|
| 978 |
void DPlatformHandle::setEnableSystemMove(bool enableSystemMove) |
| 979 |
{ |
| 980 |
auto impl = platformWindowImpl(this); |
| 981 |
impl->setEnableSystemMove(enableSystemMove); |
| 982 |
} |
| 983 |
|
| 984 |
void DPlatformHandle::setEnableBlurWindow(bool enableBlurWindow) |
| 985 |
{ |
| 986 |
auto impl = platformWindowImpl(this); |
| 987 |
impl->setEnableBlurWindow(enableBlurWindow); |
| 988 |
} |
| 989 |
|
| 990 |
void DPlatformHandle::setAutoInputMaskByClipPath(bool autoInputMaskByClipPath) |
| 991 |
{ |
| 992 |
#ifndef DTK_DISABLE_XCB |
| 993 |
if (auto impl = dynamic_cast<DXCBPlatformWindowInterface *>(platformWindowImpl(this))) { |
| 994 |
impl->setAutoInputMaskByClipPath(autoInputMaskByClipPath); |
| 995 |
} |
| 996 |
#endif |
| 997 |
} |
| 998 |
|
| 999 |
bool DPlatformHandle::eventFilter(QObject *obj, QEvent *event) |
| 1000 |
{ |
| 1001 |
return QObject::eventFilter(obj, event); |
| 1002 |
} |
| 1003 |
|
| 1004 |
DGUI_END_NAMESPACE |
| 1005 |
|
| 1006 |
QT_BEGIN_NAMESPACE |
| 1007 |
QDebug operator<<(QDebug deg, const DPlatformHandle::WMBlurArea &area) |
| 1008 |
{ |
| 1009 |
QDebugStateSaver saver(deg); |
| 1010 |
Q_UNUSED(saver) |
| 1011 |
|
| 1012 |
deg.setAutoInsertSpaces(true); |
| 1013 |
deg << "x:" << area.x |
| 1014 |
<< "y:" << area.y |
| 1015 |
<< "width:" << area.width |
| 1016 |
<< "height:" << area.height |
| 1017 |
<< "xRadius:" << area.xRadius |
| 1018 |
<< "yRadius:" << area.yRaduis; |
| 1019 |
|
| 1020 |
return deg; |
| 1021 |
} |
| 1022 |
QT_END_NAMESPACE |