Skip to content

fix: render residue on openSUSE - #383

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:render-residue
Nov 13, 2025
Merged

fix: render residue on openSUSE#383
BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:render-residue

Conversation

@BLumia

@BLumia BLumia commented Nov 13, 2025

Copy link
Copy Markdown
Member

Summary by Sourcery

Bug Fixes:

  • Clear the widget background with QPainter in PluginItem::paintEvent to fix residual rendering on openSUSE

@BLumia
BLumia requested review from mhduiy and tsic404 November 13, 2025 07:51
@sourcery-ai

sourcery-ai Bot commented Nov 13, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR addresses artifact rendering on openSUSE by introducing a paintEvent override in PluginItem: it clears the widget’s background with a transparent fill using QPainter before delegating to the base implementation and exposes this override in the class header.

Class diagram for updated PluginItem paintEvent override

classDiagram
    class PluginItem {
        +void enterEvent(QEnterEvent *event)
        +void leaveEvent(QEvent *event)
        +void moveEvent(QMoveEvent *e)
        +void paintEvent(QPaintEvent *event)  // newly added override
        +QWidget *centralWidget()
        +QMenu *pluginContextMenu()
    }
Loading

File-Level Changes

Change Details Files
Implement paintEvent override to clear rendering residue
  • Add QPainter include
  • Override paintEvent in pluginitem.cpp
  • Set composition mode to Source and fill widget rect with transparent color
  • Call QWidget::paintEvent(event) after clearing
src/loader/pluginitem.cpp
Expose paintEvent override in PluginItem header
  • Declare void paintEvent(QPaintEvent*) override in pluginitem.h
src/loader/pluginitem.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 there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来对这个代码变更进行审查:

  1. 代码逻辑分析:
    这段代码添加了一个paintEvent处理函数,目的是解决在openSUSE系统上以及未来Qt版本中可能出现的插件渲染残留问题。通过使用QPainter设置CompositionMode为Source并填充透明背景,确保了控件能够正确重绘。

  2. 代码质量评价:

  • 优点:
    • 代码注释详细,说明了添加这个函数的原因和背景
    • 实现简洁明了
    • 正确调用了父类的paintEvent
  • 改进建议:
    • 可以考虑在paintEvent中添加条件判断,只在特定平台或Qt版本下执行这个特殊的绘制逻辑
    • 可以添加性能相关的注释,说明这个操作的性能影响
  1. 性能影响分析:
  • 每次重绘都会执行额外的填充操作,会带来轻微的性能开销
  • 使用CompositionMode_Source可能会影响绘制性能
  • 对于频繁重绘的场景,这个开销可能会累积
  1. 安全性考虑:
  • 代码本身没有明显安全隐患
  • QPainter的使用是正确的,没有内存泄漏风险
  • 建议添加平台检测,避免在不需要的系统上执行这段代码

改进建议:

void PluginItem::paintEvent(QPaintEvent *event)
{
#ifdef QT_VERSION_CHECK
    // 只在特定Qt版本或平台上执行特殊绘制逻辑
    #if QT_VERSION >= QT_VERSION_CHECK(6,8,0) || defined(Q_OS_OPENSUSE)
    QPainter painter(this);
    painter.setCompositionMode(QPainter::CompositionMode_Source);
    painter.fillRect(rect(), Qt::transparent);
    #endif
#endif
    QWidget::paintEvent(event);
}

或者:

void PluginItem::paintEvent(QPaintEvent *event)
{
    // 检查是否需要特殊处理
    static bool needsSpecialPaint = []() {
        // 检查平台或Qt版本的逻辑
        return true; // 替换为实际的检查逻辑
    }();
    
    if (needsSpecialPaint) {
        QPainter painter(this);
        painter.setCompositionMode(QPainter::CompositionMode_Source);
        painter.fillRect(rect(), Qt::transparent);
    }
    
    QWidget::paintEvent(event);
}

这些改进可以:

  1. 避免在不必要的平台上执行额外的绘制操作
  2. 提高代码的可维护性
  3. 减少性能开销
  4. 使代码更加健壮和可配置

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, tsic404

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

@BLumia
BLumia merged commit 2eb2300 into linuxdeepin:master Nov 13, 2025
10 checks passed
svan71 added a commit to svan71/dde-tray-loader that referenced this pull request Jul 23, 2026
winId() forces creation of the underlying native window. Qt::WA_Translucent-
Background selects the surface format (an ARGB visual) and therefore has to be
set before that window exists; setting it afterwards leaves the already-created
surface opaque.

The result on Qt 6.11 is that every tray plugin paints its background rectangle
at all times instead of only on hover, tinted by whatever shows through from
the desktop behind the dock. Latent on Qt 6.8, which is what deepin 25 ships --
as already anticipated by the comment added in linuxdeepin#383.

Verified by A/B on Arch Linux with Qt 6.11.1, X11, swapping only this binary.
18202781743 pushed a commit to svan71/dde-tray-loader that referenced this pull request Jul 27, 2026
winId() forces creation of the underlying native window. Qt::WA_Translucent-
Background selects the surface format (an ARGB visual) and therefore has to be
set before that window exists; setting it afterwards leaves the already-created
surface opaque.

The result on Qt 6.11 is that every tray plugin paints its background rectangle
at all times instead of only on hover, tinted by whatever shows through from
the desktop behind the dock. Latent on Qt 6.8, which is what deepin 25 ships --
as already anticipated by the comment added in linuxdeepin#383.

Verified by A/B on Arch Linux with Qt 6.11.1, X11, swapping only this binary.
deepin-bot Bot pushed a commit that referenced this pull request Jul 27, 2026
winId() forces creation of the underlying native window. Qt::WA_Translucent-
Background selects the surface format (an ARGB visual) and therefore has to be
set before that window exists; setting it afterwards leaves the already-created
surface opaque.

The result on Qt 6.11 is that every tray plugin paints its background rectangle
at all times instead of only on hover, tinted by whatever shows through from
the desktop behind the dock. Latent on Qt 6.8, which is what deepin 25 ships --
as already anticipated by the comment added in #383.

Verified by A/B on Arch Linux with Qt 6.11.1, X11, swapping only this binary.
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