diff --git a/src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp b/src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp index 423ea14..d82f022 100644 --- a/src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp +++ b/src/plugins/platform/treeland/dtreelandplatformwindowinterface.cpp @@ -219,7 +219,12 @@ void DTreeLandPlatformWindowHelper::onActiveChanged() void DTreeLandPlatformWindowHelper::onSurfaceCreated() { - Q_EMIT surfaceCreated(); + if (m_isNoTitlebar) { + doSetEnabledNoTitlebar(); + } + if (m_isWindowBlur) { + doSetEnabledBlurWindow(); + } } void DTreeLandPlatformWindowHelper::onSurfaceDestroyed() @@ -258,6 +263,43 @@ PersonalizationWindowContext *DTreeLandPlatformWindowHelper::windowContext() con return m_windowContext; } +void DTreeLandPlatformWindowHelper::setEnabledNoTitlebar(bool enable) +{ + m_isNoTitlebar = enable; + doSetEnabledNoTitlebar(); +} +void DTreeLandPlatformWindowHelper::setWindowRadius(int windowRadius) +{ + m_radius = windowRadius; + doSetWindowRadius(); +} +void DTreeLandPlatformWindowHelper::setEnableBlurWindow(bool enableBlurWindow) +{ + m_isWindowBlur = enableBlurWindow; + doSetEnabledBlurWindow(); +} + +void DTreeLandPlatformWindowHelper::doSetEnabledNoTitlebar() +{ + if (auto context = windowContext()) { + context->set_titlebar(m_isNoTitlebar ? PersonalizationWindowContext::enable_mode_disable : PersonalizationWindowContext::enable_mode_enable); + } +} + +void DTreeLandPlatformWindowHelper::doSetWindowRadius() +{ + if (auto context = windowContext()) { + context->set_round_corner_radius(m_radius); + } +} + +void DTreeLandPlatformWindowHelper::doSetEnabledBlurWindow() +{ + if (auto context = windowContext()) { + context->set_blend_mode(m_isWindowBlur ? PersonalizationWindowContext::blend_mode_blur : PersonalizationWindowContext::blend_mode_transparent); + } +} + DTreeLandPlatformWindowInterface::DTreeLandPlatformWindowInterface(QWindow *window, DPlatformHandle *platformHandle, QObject *parent) : QObject(parent) , DPlatformWindowInterface(window, platformHandle) @@ -265,26 +307,12 @@ DTreeLandPlatformWindowInterface::DTreeLandPlatformWindowInterface(QWindow *wind if (!MoveWindowHelper::mapped.value(window)) { Q_UNUSED(new MoveWindowHelper(window)) } - - if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) { - connect(helper, &DTreeLandPlatformWindowHelper::surfaceCreated, this, &DTreeLandPlatformWindowInterface::onSurfaceCreated); - } } DTreeLandPlatformWindowInterface::~DTreeLandPlatformWindowInterface() { } -void DTreeLandPlatformWindowInterface::onSurfaceCreated() -{ - if (m_isNoTitlebar) { - doSetEnabledNoTitlebar(); - } - if (m_isWindowBlur) { - doSetEnabledBlurWindow(); - } -} - void DTreeLandPlatformWindowInterface::setEnabled(bool enabled) { if (setEnabledNoTitlebar(enabled)) { @@ -308,7 +336,9 @@ bool DTreeLandPlatformWindowInterface::setEnabledNoTitlebar(bool enable) return true; } m_isNoTitlebar = enable; - doSetEnabledNoTitlebar(); + if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) { + helper->setEnabledNoTitlebar(enable); + } return true; } @@ -323,7 +353,12 @@ void DTreeLandPlatformWindowInterface::setWindowRadius(int windowRadius) return; } m_radius = windowRadius; - doSetWindowRadius(); + if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) { + helper->setWindowRadius(m_radius); + } + if (m_platformHandle) { + Q_EMIT m_platformHandle->windowRadiusChanged(); + } } bool DTreeLandPlatformWindowInterface::enableBlurWindow() const @@ -337,45 +372,11 @@ void DTreeLandPlatformWindowInterface::setEnableBlurWindow(bool enable) return; } m_isWindowBlur = enable; - doSetEnabledBlurWindow(); -} - -void DTreeLandPlatformWindowInterface::doSetEnabledNoTitlebar() -{ if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) { - auto context = helper->windowContext(); - if (!context) { - return; - } - context->set_titlebar(m_isNoTitlebar ? PersonalizationWindowContext::enable_mode_disable : PersonalizationWindowContext::enable_mode_enable); - } -} - -void DTreeLandPlatformWindowInterface::doSetWindowRadius() -{ - if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) { - auto context = helper->windowContext(); - if (!context) { - return; - } - context->set_round_corner_radius(m_radius); - if (m_platformHandle) { - Q_EMIT m_platformHandle->windowRadiusChanged(); - } + helper->setEnableBlurWindow(enable); } -} - -void DTreeLandPlatformWindowInterface::doSetEnabledBlurWindow() -{ - if (auto helper = DTreeLandPlatformWindowHelper::get(m_window)) { - auto context = helper->windowContext(); - if (!context) { - return; - } - context->set_blend_mode(m_isWindowBlur ? PersonalizationWindowContext::blend_mode_blur : PersonalizationWindowContext::blend_mode_transparent); - if (m_platformHandle) { - Q_EMIT m_platformHandle->enableBlurWindowChanged(); - } + if (m_platformHandle) { + Q_EMIT m_platformHandle->enableBlurWindowChanged(); } } DGUI_END_NAMESPACE diff --git a/src/plugins/platform/treeland/dtreelandplatformwindowinterface.h b/src/plugins/platform/treeland/dtreelandplatformwindowinterface.h index 4c04133..8cbd12b 100644 --- a/src/plugins/platform/treeland/dtreelandplatformwindowinterface.h +++ b/src/plugins/platform/treeland/dtreelandplatformwindowinterface.h @@ -22,8 +22,10 @@ class DTreeLandPlatformWindowHelper : public QObject { QWindow *window() const { return qobject_cast(parent()); } PersonalizationWindowContext *windowContext() const; -Q_SIGNALS: - void surfaceCreated(); + void setEnabledNoTitlebar(bool enable); + void setWindowRadius(int windowRadius); + void setEnableBlurWindow(bool enableBlurWindow); + private slots: void onActiveChanged(); void onSurfaceCreated(); @@ -32,9 +34,17 @@ private slots: explicit DTreeLandPlatformWindowHelper(QWindow *window); bool eventFilter(QObject *watched, QEvent *event) override; void initWaylandWindow(); + + void doSetEnabledNoTitlebar(); + void doSetWindowRadius(); + void doSetEnabledBlurWindow(); private: PersonalizationWindowContext *m_windowContext = nullptr; static QMap windowMap; + + bool m_isNoTitlebar = false; + bool m_isWindowBlur = false; + int m_radius = 0; }; class DTreeLandPlatformWindowInterface : public QObject, public DPlatformWindowInterface @@ -56,14 +66,7 @@ class DTreeLandPlatformWindowInterface : public QObject, public DPlatformWindowI bool enableBlurWindow() const override; void setEnableBlurWindow(bool enableBlurWindow) override; -public slots: - void onSurfaceCreated(); - private: - void doSetEnabledNoTitlebar(); - void doSetWindowRadius(); - void doSetEnabledBlurWindow(); - bool m_isNoTitlebar = false; bool m_isWindowBlur = false; int m_radius = 0;