Skip to content

fix(clipboard): fix jagged image under fractional scaling - #274

Merged
mhduiy merged 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fork-from-master-0625-fix-issue-315075
Jul 6, 2026
Merged

fix(clipboard): fix jagged image under fractional scaling#274
mhduiy merged 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:fork-from-master-0625-fix-issue-315075

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
  1. Include QGuiApplication header for qGuiApp global pointer
  2. Reduce border width from 4.0 to 3.0 for cleaner appearance
  3. Use qGuiApp->devicePixelRatio() to get screen DPR instead of pixmap's potentially inaccurate devicePixelRatioF()

Log: Fix jagged edges in clipboard images at non-100% display scale ratios

fix(clipboard): 修复缩放比下剪贴板图片锯齿问题

  1. 添加 QGuiApplication 头文件以使用 qGuiApp 全局指针
  2. 将边框宽度从 4.0 调整为 3.0,改善视觉效果
  3. 使用 qGuiApp->devicePixelRatio() 获取屏幕 DPR,替代 pixmap 自身可能不准确的 devicePixelRatioF()

Log: 修复非 100% 缩放比下剪贴板图片锯齿明显的问题
PMS: BUG-315075

Summary by Sourcery

Adjust clipboard image rendering to improve visual quality under fractional display scaling.

Bug Fixes:

  • Correct device pixel ratio handling when generating rounded clipboard pixmaps to avoid jagged edges at non-100% scaling.

Enhancements:

  • Tweak rounded pixmap border thickness for a cleaner clipboard image appearance.

1. Include QGuiApplication header for qGuiApp global pointer
2. Reduce border width from 4.0 to 3.0 for cleaner appearance
3. Use qGuiApp->devicePixelRatio() to get screen DPR instead of pixmap's potentially inaccurate devicePixelRatioF()

Log: Fix jagged edges in clipboard images at non-100% display scale ratios

fix(clipboard): 修复缩放比下剪贴板图片锯齿问题

1. 添加 QGuiApplication 头文件以使用 qGuiApp 全局指针
2. 将边框宽度从 4.0 调整为 3.0,改善视觉效果
3. 使用 qGuiApp->devicePixelRatio() 获取屏幕 DPR,替代 pixmap 自身可能不准确的 devicePixelRatioF()

Log: 修复非 100% 缩放比下剪贴板图片锯齿明显的问题
PMS: BUG-315075
@deepin-ci-robot

Copy link
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR. 😃

@deepin-ci-robot

Copy link
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai

sourcery-ai Bot commented Jun 25, 2026

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

Reviewer's Guide

This PR adjusts how rounded clipboard preview pixmaps are rendered under fractional display scaling, using the global QGuiApplication DPI instead of the pixmap’s own DPR and slightly reducing the border width for visual refinement.

Sequence diagram for clipboard pixmap rounding under fractional scaling

sequenceDiagram
    participant ClipboardPreview
    participant GetRoundPixmap
    participant qGuiApp
    participant Pixmap

    ClipboardPreview->>GetRoundPixmap: GetRoundPixmap(pix, borderColor)
    alt [qGuiApp is nonnull]
        GetRoundPixmap->>qGuiApp: devicePixelRatio()
        qGuiApp-->>GetRoundPixmap: dpr
    else [qGuiApp is null]
        GetRoundPixmap->>Pixmap: devicePixelRatioF()
        Pixmap-->>GetRoundPixmap: dpr
    end
    GetRoundPixmap-->>ClipboardPreview: roundedPixmap
Loading

File-Level Changes

Change Details Files
Use screen-level device pixel ratio from QGuiApplication instead of the pixmap’s DPR when rendering rounded clipboard images to reduce jagged edges under fractional scaling.
  • Include QGuiApplication header to access the global application pointer for DPR queries.
  • Compute the DPR using the global application pointer when available, falling back to the pixmap DPR if the application pointer is null.
  • Use the computed DPR to size the target QImage used for rounded pixmap rendering.
dde-clipboard/constants.h
Tweak the visual styling of rounded clipboard pixmaps by narrowing the border width.
  • Reduce the border width constant from 4.0 to 3.0 in the rounded pixmap rendering helper function.
dde-clipboard/constants.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 left some high level feedback:

  • Consider avoiding a dependency on the global qGuiApp inside GetRoundPixmap by passing the device pixel ratio as a parameter instead, which will make the function easier to reuse and test independently of application state.
  • Now that borderWidth and radius are magic numbers used for visual tuning, you might want to centralize them as named constants (e.g., constexpr) to make future adjustments and consistency across the codebase easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider avoiding a dependency on the global qGuiApp inside GetRoundPixmap by passing the device pixel ratio as a parameter instead, which will make the function easier to reuse and test independently of application state.
- Now that borderWidth and radius are magic numbers used for visual tuning, you might want to centralize them as named constants (e.g., constexpr) to make future adjustments and consistency across the codebase easier.

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.

@mhduiy
mhduiy merged commit 04c7f1a into linuxdeepin:master Jul 6, 2026
18 checks passed
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, MyLeeJiEun

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants