From 8c8a9948daf1bc40f6e8c8d67f5d61d3718d7c48 Mon Sep 17 00:00:00 2001 From: zhangkun Date: Mon, 26 Jan 2026 10:44:06 +0800 Subject: [PATCH] fix: skip scale factor retrieval on Wayland temporarily MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Modified scale factor retrieval logic to only query XSettings DBus interface when running under X11 session 2. Added session type check using XDG_SESSION_TYPE environment variable 3. Added TODO comment explaining that XSettings is not available on Wayland during early startup 4. This change prevents failed DBus calls and potential startup delays on Wayland sessions 5. The scale factor is temporarily defaulted to 1.0 on Wayland, affecting only double-click distance calculation Log: Fixed Wayland session startup issue by skipping XSettings scale factor query Influence: 1. Test application startup on both X11 and Wayland sessions 2. Verify double-click behavior works correctly with default scale factor on Wayland 3. Ensure no DBus errors appear during Wayland session initialization 4. Confirm X11 sessions still properly retrieve scale factor from XSettings 5. Test that QT_QPA_PLATFORM environment variable is correctly set based on session type fix: Wayland 下暂时跳过缩放因子获取 1. 修改缩放因子获取逻辑,仅在 X11 会话下查询 XSettings DBus 接口 2. 添加使用 XDG_SESSION_TYPE 环境变量的会话类型检查 3. 添加 TODO 注释说明 Wayland 在早期启动阶段无法使用 XSettings 4. 此更改防止 Wayland 会话上的 DBus 调用失败和潜在的启动延迟 5. Wayland 上的缩放因子暂时默认为 1.0,仅影响双击距离计算 Log: 修复 Wayland 会话启动问题,跳过 XSettings 缩放因子查询 Influence: 1. 测试在 X11 和 Wayland 会话上的应用程序启动 2. 验证 Wayland 上使用默认缩放因子的双击行为正常工作 3. 确保 Wayland 会话初始化期间不出现 DBus 错误 4. 确认 X11 会话仍能正确从 XSettings 获取缩放因子 5. 测试 QT_QPA_PLATFORM 环境变量根据会话类型正确设置 --- src/dde-session/environmentsmanager.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/dde-session/environmentsmanager.cpp b/src/dde-session/environmentsmanager.cpp index 07e62e6..61a2957 100644 --- a/src/dde-session/environmentsmanager.cpp +++ b/src/dde-session/environmentsmanager.cpp @@ -73,14 +73,21 @@ void EnvironmentsManager::init() void EnvironmentsManager::createGeneralEnvironments() { + QByteArray sessionType = qgetenv("XDG_SESSION_TYPE"); double scaleFactor = 1.0; - QDBusInterface dbusInterface("org.deepin.dde.XSettings1", "/org/deepin/dde/XSettings1", + + if (sessionType == "x11") { + QDBusInterface dbusInterface("org.deepin.dde.XSettings1", "/org/deepin/dde/XSettings1", "org.deepin.dde.XSettings1", QDBusConnection::sessionBus()); - if (dbusInterface.isValid()) { - QDBusReply scaleFactorReply = dbusInterface.call("GetScaleFactor"); - if (scaleFactorReply.isValid()) { - scaleFactor = scaleFactorReply.value(); + if (dbusInterface.isValid()) { + QDBusReply scaleFactorReply = dbusInterface.call("GetScaleFactor"); + if (scaleFactorReply.isValid()) { + scaleFactor = scaleFactorReply.value(); + } } + } else { + // TODO: wayland环境下在这里通过xsettings获取是不合理的,此时xsettings服务还没有启动,并且也无法启动(没有DISPLAY,xwayland此时没有启动) + // 且 wayland 此时也无法连接,无法通过协议获取,后续考虑其他方式获取,这里仅影响双击时两次点击坐标的冗余量的设置 } auto envs = QProcessEnvironment::systemEnvironment(); @@ -94,7 +101,6 @@ void EnvironmentsManager::createGeneralEnvironments() m_envMap.insert("XDG_CURRENT_DESKTOP", "DDE"); m_envMap.insert("QT_DBL_CLICK_DIST", QString::number(15 * scaleFactor)); - QByteArray sessionType = qgetenv("XDG_SESSION_TYPE"); if (sessionType == "x11") { m_envMap.insert("QT_QPA_PLATFORM", "dxcb;xcb"); } else if (sessionType == "wayland") {