Skip to content

fix(core): defer output rearrangement to fix VT switch issues#1014

Merged
zccrs merged 1 commit into
linuxdeepin:masterfrom
glyvut:winmove
Jun 23, 2026
Merged

fix(core): defer output rearrangement to fix VT switch issues#1014
zccrs merged 1 commit into
linuxdeepin:masterfrom
glyvut:winmove

Conversation

@glyvut

@glyvut glyvut commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Add a single-shot timer in RootSurfaceContainer to batch surface output updates. This fixes the issue where windows could not be dragged after VT switch by ensuring proper output recovery sequence.

在RootSurfaceContainer中添加单次定时器合并表面输出更新,
修复VT切换后窗口无法拖动等问题。

Log: 修复VT切换后窗口无法拖动的bug
PMS: BUG-366537
Influence: 切换VT后窗口可正常拖动,多显示器恢复更平滑

Summary by Sourcery

Defer surface-output rearrangement in the root surface container to batch output updates and improve output recovery after VT switches.

Bug Fixes:

  • Fix window drag failures and related focus issues after VT switches by ensuring outputs and surface ownership are updated in the correct sequence.

Enhancements:

  • Batch surface-output updates using a single-shot timer in the root surface container to make multi-display configuration changes and recovery smoother.

@sourcery-ai

sourcery-ai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a deferred, single-shot QTimer-based batching mechanism in RootSurfaceContainer to regroup surface-output rearrangement after output add/remove events, fixing VT switch drag issues and smoothing multi-display recovery.

Sequence diagram for deferred surface-output rearrangement with QTimer

sequenceDiagram
    participant RootSurfaceContainer
    participant QTimer
    participant Workspace

    RootSurfaceContainer->>QTimer: start(0)  Note left of RootSurfaceContainer: addOutput/removeOutput
    QTimer-->>QTimer: timeout (singleShot)
    QTimer->>RootSurfaceContainer: [lambda connected to timeout]
    loop for each surface in surfaces()
        RootSurfaceContainer->>RootSurfaceContainer: updateSurfaceOutputs(surface)
    end
    RootSurfaceContainer->>Workspace: updateSurfacesOwnsOutput()
Loading

File-Level Changes

Change Details Files
Introduce a single-shot QTimer in RootSurfaceContainer to batch output rearrangement after display topology changes.
  • Add QTimer forward declaration in the header and a QTimer* member m_outputRearrangeTimer to RootSurfaceContainer.
  • Instantiate m_outputRearrangeTimer in the RootSurfaceContainer constructor with this as parent and configure it as single-shot.
  • Connect the timer's timeout to iterate all current surfaces, calling updateSurfaceOutputs(surface) for each, then trigger workspace()->updateSurfacesOwnsOutput() if a workspace exists.
  • On addOutput and removeOutput, start the timer with 0ms delay to defer and coalesce rearrangement work across multiple output changes.
src/core/rootsurfacecontainer.cpp
src/core/rootsurfacecontainer.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:

  • The lambda connected to m_outputRearrangeTimer->timeout duplicates logic that might be reused elsewhere; consider extracting it into a dedicated private method (e.g. rearrangeOutputs()) and calling that from both the timer and any future callers for clarity and easier maintenance.
  • Instead of calling m_outputRearrangeTimer->start(0) in multiple places, a small helper like scheduleOutputRearrange() would centralize the batching behavior (including any future changes to delay or conditions) and make the intent of the 0ms single-shot timer more self-documenting.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The lambda connected to `m_outputRearrangeTimer->timeout` duplicates logic that might be reused elsewhere; consider extracting it into a dedicated private method (e.g. `rearrangeOutputs()`) and calling that from both the timer and any future callers for clarity and easier maintenance.
- Instead of calling `m_outputRearrangeTimer->start(0)` in multiple places, a small helper like `scheduleOutputRearrange()` would centralize the batching behavior (including any future changes to delay or conditions) and make the intent of the 0ms single-shot timer more self-documenting.

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-bot

deepin-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.8.12
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1036

Comment thread src/workspace/workspace.cpp Outdated
…r VT switch

Add Workspace::addOutput override that iterates all surfaces and calls
updateSurfaceOwnsOutput, following LayerSurfaceContainer's pattern.

实现 Workspace::addOutput 重写,遍历所有 surface 调用
updateSurfaceOwnsOutput,遵循 LayerSurfaceContainer 的设计模式。

Log: 修复VT切换后窗口无法拖动的bug
PMS: BUG-366537
Influence: 切换VT后窗口可正常拖动,普通窗口的 ownsOutput 在 Output 重建后能正确恢复。
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: glyvut, zccrs

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

@zccrs zccrs merged commit ea3498c into linuxdeepin:master Jun 23, 2026
9 checks passed
@glyvut glyvut deleted the winmove branch June 24, 2026 00:30
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