Repository navigation
fix(display): get monitor info from display dbus on hw platforms - #950
Conversation
1. 根因:Wayland 会话下 xrandr 连接的是 Xwayland,RandR 数据由 wl_output/xdg-output 仿真合成,模式经 CVT 公式生成(受全局缩放 与合成器刷新率影响),显示 2400×1350@49.93Hz 等虚假分辨率, 且输出无 EDID 属性,无法解析屏幕尺寸与厂商信息 2. 修复:HW 平台机型(Common::isHwPlatform)显示器信息优先走 com.deepin.daemon.Display DBus 获取真实模式数据,DBus 不可用 时回退 xrandr;接口类型由 DBus 连接器名切分填充 3. 影响:HW 机型在 Wayland 下显示真实分辨率/刷新率/接口类型, X11 下除 PGUV 增加 DBus 失败回退外行为不变;非 HW 机型不受影响 PMS: https://pms.uniontech.com/bug-view-380841.html
Reviewer's GuideHardware platforms now prefer real monitor modes and connector metadata from the display DBus service, avoiding unreliable Xwayland RandR values on Wayland; monitor discovery falls back to xrandr when DBus is unavailable, while non-hardware behavior remains unchanged. Sequence diagram for hardware monitor discovery with DBus fallbacksequenceDiagram
participant ThreadExecXrandr
participant Common
participant DisplayDBus
participant Xrandr
participant DeviceMonitor
ThreadExecXrandr->>Common: isHwPlatform()
alt Hardware platform
ThreadExecXrandr->>DisplayDBus: getResolutionRateFromDBus()
alt DBus returns monitor modes
DisplayDBus-->>ThreadExecXrandr: monitor mode maps
ThreadExecXrandr->>DeviceMonitor: setInfoFromDbus(mapInfo)
DeviceMonitor->>DeviceMonitor: setAttribute(mapInfo, CurResolution)
DeviceMonitor->>DeviceMonitor: parse connector name
else DBus unavailable or empty
ThreadExecXrandr->>Xrandr: getMonitorInfoFromXrandrVerbose()
end
else Non-hardware platform
ThreadExecXrandr->>Xrandr: getMonitorInfoFromXrandrVerbose()
end
Flow diagram for DBus monitor mode normalizationflowchart TD
A[DBus monitor info received] --> B{Connector name matches display input?}
B -->|No| C[Keep existing monitor metadata]
B -->|Yes| D{Interface is empty and connector name matches?}
D -->|Yes| E[Set interface from connector prefix]
D -->|No| F[Keep existing interface]
E --> G[Set current resolution from CurResolution]
F --> G
G --> H{specialComType is kSpecialType10?}
H -->|No| I[Keep DBus resolution and refresh rate]
H -->|Yes| J[Parse resolution and fractional refresh rate]
J --> K[Store pixel dimensions and rounded refresh rate]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['建议将正则量词改为 +(一个或多个字母),确保接口名不为空:^([a-zA-Z]+)-[\s\S]*'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['为 kSpecialType10 添加注释说明该硬件类型特征及为何需要特殊分辨率解析', "修正版权年份格式为 '2022-2026'", '考虑将 QRegExp 替换为 QRegularExpression 以兼容 Qt6'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['将 QRegExp 对象声明为 static const 局部变量,避免重复编译正则表达式'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// DeviceMonitor.cpp - 优化后的 setInfoFromDbus
void DeviceMonitor::setInfoFromDbus(const QMap<QString, QString> &mapInfo)
{
if (mapInfo["Name"].toLower().contains(m_DisplayInput.toLower(), Qt::CaseInsensitive)) {
// 使用 + 量词确保接口名非空,static 避免重复编译
static const QRegExp reInput("^([a-zA-Z]+)-[\\s\\S]*");
if (m_Interface.isEmpty() && reInput.exactMatch(mapInfo["Name"])) {
m_Interface = reInput.cap(1);
}
setAttribute(mapInfo, "CurResolution", m_CurrentResolution);
// kSpecialType10: 特定硬件平台分辨率格式为 "WxH@RateHz",需解析提取
if (Common::specialComType == Common::kSpecialType10) {
static const QRegExp reResolution("^([0-9]{1,5})×([0-9]{1,5})@([0-9.]+)Hz$");
if (reResolution.exactMatch(m_CurrentResolution)) {
m_CurrentResolution = QString("%1×%2").arg(reResolution.cap(1)).arg(reResolution.cap(2));
m_RefreshRate = QString::number(ceil(reResolution.cap(3).toDouble())) + "Hz";
}
}
}
}本报告由 AI 代码审查工具自动生成 |
|
/forcemerge |
PMS: https://pms.uniontech.com/bug-view-380841.html
Summary by Sourcery
Prefer reliable display D-Bus information on hardware platforms while retaining xrandr fallback and existing behavior elsewhere.
Bug Fixes:
Enhancements: