From f290da821afe2f4e4c37066adf43004e1395675d Mon Sep 17 00:00:00 2001 From: Liu Zheng Date: Fri, 13 Dec 2024 08:34:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96treeland=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化treeland启动慢的问题 Bug: 优化treeland启动慢的问题 --- .../terminalwidget/lib/encodes/detectcode.cpp | 1 + .../terminalwidget/lib/encodes/detectcode.h | 2 +- src/main/service.cpp | 31 ++++--------------- src/main/service.h | 5 ++- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/3rdparty/terminalwidget/lib/encodes/detectcode.cpp b/3rdparty/terminalwidget/lib/encodes/detectcode.cpp index e5f5a35e8..0a9e2da03 100644 --- a/3rdparty/terminalwidget/lib/encodes/detectcode.cpp +++ b/3rdparty/terminalwidget/lib/encodes/detectcode.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include diff --git a/3rdparty/terminalwidget/lib/encodes/detectcode.h b/3rdparty/terminalwidget/lib/encodes/detectcode.h index 2a4d4cca0..1af59238b 100644 --- a/3rdparty/terminalwidget/lib/encodes/detectcode.h +++ b/3rdparty/terminalwidget/lib/encodes/detectcode.h @@ -8,7 +8,7 @@ #include #include -#include + #include #include diff --git a/src/main/service.cpp b/src/main/service.cpp index 3b4c604e8..29ae03d11 100644 --- a/src/main/service.cpp +++ b/src/main/service.cpp @@ -192,41 +192,22 @@ void Service::showHideOpacityAndBlurOptions(bool isShow) void Service::listenWindowEffectSwitcher() { - if (nullptr == m_wmSwitcher) { - m_wmSwitcher = new WMSwitcher(WMSwitcherService, WMSwitcherPath, QDBusConnection::sessionBus(), this); - m_wmSwitcher->setObjectName("WMSwitcher");//Add by ut001000 renfeixiang 2020-08-13 - connect(m_wmSwitcher, &WMSwitcher::WMChanged, this, &Service::slotWMChanged, Qt::QueuedConnection); + if (!m_mainTerminalIsInitWM) { + connect(DWindowManagerHelper::instance(),&DWindowManagerHelper::hasBlurWindowChanged,this, &Service::slotWMChanged); + m_mainTerminalIsInitWM = true; } } -void Service::slotWMChanged(const QString &wmName) +void Service::slotWMChanged() { - bool isWinEffectEnabled = false; - if (wmName == "deepin wm") - isWinEffectEnabled = true; - + bool isWinEffectEnabled = DWindowManagerHelper::instance()->hasBlurWindow(); showHideOpacityAndBlurOptions(isWinEffectEnabled); emit onWindowEffectEnabled(isWinEffectEnabled); } bool Service::isWindowEffectEnabled() { - QDBusMessage msg = QDBusMessage::createMethodCall(WMSwitcherService, WMSwitcherPath, WMSwitcherService, "CurrentWM"); - - QDBusMessage response = QDBusConnection::sessionBus().call(msg); - if (response.type() == QDBusMessage::ReplyMessage) { - QList list = response.arguments(); - QString wmName = list.first().toString(); - if (wmName == "deepin wm") { - qCInfo(mainprocess) << "The window effects is on"; - return true; - } - } else { - qCWarning(mainprocess) << "call CurrentWM Fail!" << response.errorMessage(); - } - - qCWarning(mainprocess) << "The window effects is off"; - return false; + return DWindowManagerHelper::instance()->hasBlurWindow(); } qint64 Service::getEntryTime() diff --git a/src/main/service.h b/src/main/service.h index 201db3784..fde9321f7 100644 --- a/src/main/service.h +++ b/src/main/service.h @@ -224,9 +224,8 @@ public slots: /** * @brief 处理窗口特效打开/关闭时,相关设置项目的显示/隐藏 - * @param wmName */ - void slotWMChanged(const QString &wmName); + void slotWMChanged(); /** * @brief 自定义主题对话框关闭后的处理 @@ -264,7 +263,6 @@ public slots: static Service *g_pService; DSettingsDialog *m_settingDialog = nullptr;// 设置框 全局唯一显示 CustomThemeSettingDialog *m_customThemeSettingDialog = nullptr;// 自定义主题设置对话框 全局唯一 - WMSwitcher *m_wmSwitcher = nullptr; MainWindow *m_settingOwner = nullptr;// 设置框的所有者 DDialog *m_settingShortcutConflictDialog = nullptr;// 设置框,快捷键冲突弹窗 bool m_isDialogShow = false; // 雷神用来判断是否有弹窗显示 @@ -272,6 +270,7 @@ public slots: QMap m_shellsMap; qint64 m_entryTime = 0; // 记录进入的时间,只有创建窗口时,才会来取用这个时间 bool m_mainTerminalIsStarted = false; + bool m_mainTerminalIsInitWM = false; }; #endif // SERVICE_H