diff --git a/src/widgets/dabstractdialog.cpp b/src/widgets/dabstractdialog.cpp index 4a5c5e1c5..d698d77fd 100644 --- a/src/widgets/dabstractdialog.cpp +++ b/src/widgets/dabstractdialog.cpp @@ -40,11 +40,6 @@ void DAbstractDialogPrivate::init(bool blurIfPossible) // TODO: 这里对dialog特殊处理,dialog不需要设置固定的位置,否则里面的坐标会发生偏移导致点击偏移 // 但是这不是问题的根本原因,还需要进一步分析。该属性在插件中做了特殊处理 q->QDialog::setProperty("DAbstractDialog", true); - auto noTitlebarEnabled = []{ - QFunctionPointer enableNoTitlebar = qApp->platformFunction("_d_isEnableNoTitlebar"); - bool enabled = qApp->platformName() == "dwayland" || qApp->property("_d_isDwayland").toBool(); - return enabled && enableNoTitlebar != nullptr; - }; if (qApp->isDXcbPlatform()) { handle = new DPlatformWindowHandle(q, q); @@ -66,7 +61,7 @@ void DAbstractDialogPrivate::init(bool blurIfPossible) bgBlurWidget->setBlurEnabled(blurIfPossible); q->setAttribute(Qt::WA_TranslucentBackground, blurIfPossible); - } else if (noTitlebarEnabled()) { + } else if (DWindowManagerHelper::instance()->hasNoTitlebar()) { handle = new DPlatformWindowHandle(q, q); if (!handle->enableBlurWindow()) { diff --git a/src/widgets/dfloatingmessage.cpp b/src/widgets/dfloatingmessage.cpp index fd3aaa48d..014005ed8 100644 --- a/src/widgets/dfloatingmessage.cpp +++ b/src/widgets/dfloatingmessage.cpp @@ -12,6 +12,7 @@ #include #include #include +#include class MessageLabel : public QLabel { @@ -83,7 +84,7 @@ void DFloatingMessagePrivate::init() if(ENABLE_ANIMATIONS && ENABLE_ANIMATION_MESSAGE) q->connect(closeButton, &DIconButton::clicked, q, [q]() { - q->close(); + q->windowHandle()->close(); Q_EMIT q->messageClosed(); }); else diff --git a/src/widgets/dmainwindow.cpp b/src/widgets/dmainwindow.cpp index 8682ba2a0..a739d66fc 100644 --- a/src/widgets/dmainwindow.cpp +++ b/src/widgets/dmainwindow.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -42,15 +43,8 @@ DMainWindowPrivate::DMainWindowPrivate(DMainWindow *qq) { titlebar = new DTitlebar(qq); titlebar->setAccessibleName("DMainWindowTitlebar"); - auto noTitlebarEnabled = []{ - if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) { - return true; - } - QFunctionPointer enableNoTitlebar = qApp->platformFunction("_d_isEnableNoTitlebar"); - bool enabled = qApp->platformName() == "dwayland" || qApp->property("_d_isDwayland").toBool(); - return enabled && enableNoTitlebar != nullptr; - }; - if (DApplication::isDXcbPlatform() || noTitlebarEnabled()) { + + if (DApplication::isDXcbPlatform() || DWindowManagerHelper::instance()->hasNoTitlebar()) { handle = new DPlatformWindowHandle(qq, qq); qq->setMenuWidget(titlebar); } else { diff --git a/src/widgets/dtitlebar.cpp b/src/widgets/dtitlebar.cpp index c3a23a700..86b2bce68 100644 --- a/src/widgets/dtitlebar.cpp +++ b/src/widgets/dtitlebar.cpp @@ -1533,7 +1533,7 @@ void DTitlebar::setVisible(bool visible) connect(d->maxButton, SIGNAL(clicked()), this, SLOT(_q_toggleWindowState()), Qt::UniqueConnection); connect(this, SIGNAL(doubleClicked()), this, SLOT(_q_toggleWindowState()), Qt::UniqueConnection); connect(d->minButton, SIGNAL(clicked()), this, SLOT(_q_showMinimized()), Qt::UniqueConnection); - connect(d->closeButton, &DWindowCloseButton::clicked, d->targetWindow(), &QWidget::close, Qt::UniqueConnection); + connect(d->closeButton, &DWindowCloseButton::clicked, d->targetWindow()->windowHandle(), &QWindow::close, Qt::UniqueConnection); d->updateButtonsState(d->targetWindow()->windowFlags()); } else {