diff --git a/src/main.cpp b/src/main.cpp
index ca2a5b4..172291c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -140,67 +140,55 @@ int main(int argc, char *argv[])
// Set display backend
Utils::setQPAPlatform();
- // 龙芯机器配置,使得 DApplication 能正确加载 QTWEBENGINE
+ // 龙芯机器配置,使得 DApplication 能正确加载 QtWebEngine
qputenv("DTK_FORCE_RASTER_WIDGETS", "FALSE");
- // qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls");
- // qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-web-security");
-
// 浏览器开启 GPU 支持
+ // qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls");
+ // qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-web-security");
#ifdef __sw_64__
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
#elif __aarch64__
- if (!Utils::isWayland()) {
- QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
- env = env.trimmed();
- /**
- * NOTE: 参考帮助手册代码,对于部分ARM CPU 设备,
- * --disable-gpu 保证 X11 环境下网页正常显示
- * --single-process 避免 X11 环境下 QtWebEngine 崩溃(可选)
- */
- env += " --disable-gpu";
- qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
- QSurfaceFormat format;
- format.setRenderableType(QSurfaceFormat::OpenGLES);
- QSurfaceFormat::setDefaultFormat(format);
+ QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
+ env = env.trimmed();
+ /**
+ * NOTE: 参考帮助手册代码,对于部分 ARM CPU 设备,
+ * --disable-gpu 保证网页正常显示
+ * --single-process 避免 QtWebEngine 崩溃(可选)
+ */
+ env += " --disable-gpu";
+ if (Utils::isPhytium()) {
+ env += " --single-process";
+ }
+ qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
+ if (Utils::isWayland()) {
/**
- * NOTE: https://zhuanlan.zhihu.com/p/550285855
- * 避免 X11 环境下从 QtWebEngine 后退回到 QWidget 时黑屏闪烁
+ * WARNING: DDM TreeLand 混合器下,设置
+ * QT_WAYLAND_SHELL_INTEGRATION 环境变量
+ * 会导致崩溃 By justforlxz
*/
+ if (!Utils::isTreeLand()) {
+ /**
+ * NOTE: 参考帮助手册代码,对于麒麟 CPU 设备,
+ * 避免 wayland 环境下 QtWebEngine 崩溃
+ */
+ qputenv("QT_WAYLAND_SHELL_INTEGRATION", "kwayland-shell");
+ }
+
+ }
+ QSurfaceFormat format;
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
+ QSurfaceFormat::setDefaultFormat(format);
+
+ /**
+ * NOTE: https://zhuanlan.zhihu.com/p/550285855
+ * 避免 X11 环境下从 QtWebEngine 后退回到 QWidget 时黑屏闪烁
+ */
+ if (!Utils::isWayland()) {
qputenv("QMLSCENE_DEVICE", "softwarecontext");
DApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
}
- /**
- * FIXME: 对于麒麟 CPU 设备,调用 QtWebEngine 会导致客户端崩溃;
- * 暂时不对 CPU 进行判断,对 wayland 环境下统一处理
- */
- else {
- QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
- env = env.trimmed();
- /**
- * NOTE: 参考帮助手册代码,对于麒麟 CPU 设备,
- * --disable-gpu 保证 wayland 环境下网页正常显示
- * --single-process 避免 wayland 环境下 QtWebEngine 崩溃(可选)
- */
- env += " --disable-gpu";
- qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
-
- /**
- * NOTE: 参考帮助手册代码,对于麒麟 CPU 设备,
- * 避免 wayland 环境下 QtWebEngine 崩溃
- */
- qputenv("QT_WAYLAND_SHELL_INTEGRATION", "kwayland-shell");
- QSurfaceFormat format;
- format.setRenderableType(QSurfaceFormat::OpenGLES);
- QSurfaceFormat::setDefaultFormat(format);
- }
- if (Utils::isPhytium()){
- QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
- env = env.trimmed();
- env += " --single-process";
- qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
- }
#endif
/**
@@ -215,12 +203,10 @@ int main(int argc, char *argv[])
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
- {
- // 开启 Hidpi 支持
- qDebug() << "Enable HiDPI Support.";
- DApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
- DApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
- }
+ // 开启 Hidpi 支持
+ qDebug() << "Enable HiDPI Support.";
+ DApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ DApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
// 强制使用 DTK 平台插件
diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp
index 0d37237..9a1440b 100644
--- a/src/utils/utils.cpp
+++ b/src/utils/utils.cpp
@@ -73,6 +73,21 @@ bool Utils::isWayland()
return isWayland;
}
+/**
+ * @brief 判断是否使用 TreeLand 混合器
+ * @return bool true: 使用 TreeLand 混合器 false: 非 TreeLand 混合器
+ */
+bool Utils::isTreeLand()
+{
+ bool isTreeLand = false;
+ if (qgetenv("DDE_CURRENT_COMPOSITER").toLower() == "treeland"
+ || qgetenv("DESKTOP_SESSION").toLower() == "treeland") {
+ isTreeLand = true;
+ }
+
+ return isTreeLand;
+}
+
bool Utils::isPhytium()
{
bool isPhytium = false;
diff --git a/src/utils/utils.h b/src/utils/utils.h
index 776fd90..a85d64a 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -10,6 +10,7 @@ public:
static void sendNotification(const QString &icon, const QString &title, const QString &body);
static bool isDDE();
static bool isWayland();
+ static bool isTreeLand();
static void initConfig();
static bool isUOS();
static bool isPhytium();