Skip to content

feat: support displaying LVDS monitor info without EDID - #963

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/eaglefrom
GongHeng2017:squash-pr-962
Nov 3, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/eaglefrom
GongHeng2017:squash-pr-962

Conversation

@GongHeng2017

@GongHeng2017 GongHeng2017 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

LVDS displays don't provide EDID data, causing device manager to fail to recognize them. Add getMonitorWithoutEdidFromXrandr() to parse xrandr --verbose output for connected displays without EDID, and setInfoFromLvds() to populate monitor info from xrandr data.

Task: https://pms.uniontech.com/task-view-397927.html
Story: https://pms.uniontech.com/story-view-42241.html

Squashed from PR #962 (3 commits) with review fixes applied:

  • [M01] Add exitCode() check + qCWarning after waitForFinished(5000)
  • [m03] Fix SPDX copyright header spacing in DeviceMonitor.h
  • [M01] Use creator-provided commit message format (URL format for Task/Story)

Summary by Sourcery

Support identifying connected displays without EDID data so they are included in device manager monitor information.

New Features:

  • Add detection and display of connected monitors without EDID data using xrandr verbose output, including current and supported resolutions and refresh rates.

Bug Fixes:

  • Prevent duplicate monitor entries when the same connector has already been discovered through other hardware information sources.
  • Improve monitor overview formatting when screen size information is unavailable.

Enhancements:

  • Expose monitor connector names and populate monitor metadata for displays identified through xrandr.

LVDS displays don't provide EDID data, causing device manager to fail
to recognize them. Add getMonitorWithoutEdidFromXrandr() to parse
xrandr --verbose output for connected displays without EDID, and
setInfoFromLvds() to populate monitor info from xrandr data.

Task: https://pms.uniontech.com/task-view-397927.html
Story: https://pms.uniontech.com/story-view-42241.html
@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR adds xrandr-based fallback monitor discovery for connected displays without EDID, populates usable monitor metadata from parsed connector and mode information, prevents duplicates with hwinfo-discovered devices, and improves overview handling for missing screen-size data.

Sequence diagram for xrandr fallback monitor discovery

sequenceDiagram
    participant Generator as DeviceGenerator
    participant Xrandr as xrandr
    participant Manager as DeviceManager
    participant Monitor as DeviceMonitor

    Generator->>Xrandr: start(--verbose)
    Xrandr-->>Generator: output
    Generator->>Generator: exitCode()
    loop each connector
        Generator->>Generator: parse connected connector and modes
        alt connected without EDID
            Generator->>Manager: convertDeviceListAddr(DT_Monitor)
            alt connector not already present
                Generator->>Monitor: setInfoFromXrandrWithoutEdid(connectorName, interfaceType, isPrimary, currentResolution, currentRate, supportResolutions)
                Generator->>Manager: addMonitor(Monitor)
            else existing displayInput
                Generator->>Generator: skip duplicate monitor
            end
        end
    end
Loading

File-Level Changes

Change Details Files
Add a fallback path that discovers connected monitors lacking EDID by executing and parsing xrandr --verbose.
  • Run xrandr with a timeout and exit-status warning, then parse connector, connection, EDID, resolution, primary-display, and refresh-rate data.
  • Create fallback monitor entries only for connected interfaces without EDID, while deduplicating against existing monitors by connector name.
  • Invoke the fallback discovery after hwinfo-based monitor generation.
deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp
deepin-devicemanager/src/GenerateDevice/DeviceGenerator.h
Populate monitor metadata and expose the connector identifier for EDID-less displays.
  • Add a setter that initializes display, interface, vendor, primary-screen, resolution, refresh-rate, and supported-resolution fields from xrandr data.
  • Expose displayInput() so generated monitors can be matched to existing entries.
deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
deepin-devicemanager/src/DeviceManager/DeviceMonitor.h
Make monitor overview formatting safe when screen-size data is unavailable.
  • Display only the monitor name when no screen size is present instead of rendering an empty size suffix.
  • Update the DeviceMonitor SPDX copyright header.
deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
deepin-devicemanager/src/DeviceManager/DeviceMonitor.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 80 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 代码新增了从 xrandr --verbose 解析无 EDID 显示器信息的功能,整体实现合理,注释完整。 存在 waitForFinished 返回值未检查的逻辑缺陷、已废弃 API 使用及分辨率格式不一致等代码质量问题, 但无安全漏洞。

🔍 详细分析

1. 语法逻辑 ❌

评价: 存在逻辑缺陷 ❌ 不通过

潜在问题:
✅ 未发现明显问题

建议: ['检查 waitForFinished() 返回值,超时时 kill 进程并提前返回,参考 commontools.cpp 中的实现。', '将 v: 行匹配条件改为 line.trimmed().startsWith("v:") 以增强健壮性。']


2. 代码质量 ❌

评价: 结构需要优化 ❌ 不通过

潜在问题:
✅ 未发现明显问题

建议: ['将 getMonitorWithoutEdidFromXrandr() 拆分为更小的子函数,如解析连接器行、解析分辨率行、创建显示器等。', '使用 QRegularExpression 替换 QRegExp,使用 Qt::SkipEmptyParts 替换 QString::SkipEmptyParts。', '统一分辨率显示格式,与现有代码保持一致。']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['考虑在后台线程执行 xrandr 命令,或使用异步方式(QProcess::readyReadStandardOutput 信号)处理输出。']


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 修复 waitForFinished 返回值未检查的问题 (DeviceGenerator.cpp)
QProcess process;
process.start("xrandr", QStringList() << "--verbose");
if (!process.waitForFinished(5000)) {
    qCWarning(appLog) << "xrandr --verbose timed out";
    process.kill();
    process.waitForFinished();
    return;
}
if (process.exitCode() != 0) {
    qCWarning(appLog) << "xrandr --verbose failed with exit code:" << process.exitCode();
    return;
}

// 修复 v: 行解析条件
// 替换: if (line.startsWith(" ") && line.contains("v:") && line.contains("clock"))
// 为:   if (line.startsWith(" ") && line.trimmed().startsWith("v:") && line.contains("clock"))

// 修复已废弃 API
// 替换 QRegExp 为 QRegularExpression:
// QRegularExpression reEdid("^[\\t]{2}([0-9a-f]{32}).*");
// QRegularExpression reRes("^\\s+(\\d+x\\d+\\w*)");
// QRegularExpression reRate("clock\\s+(\\d+\\.\\d+)Hz");
// 替换 QString::SkipEmptyParts 为 Qt::SkipEmptyParts

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, max-lvs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@GongHeng2017

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit e305580 into linuxdeepin:develop/eagle Nov 3, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants