Skip to content

fix: defer splash toplevel registration until real surface - #1383

Merged
wineee merged 1 commit into
linuxdeepin:masterfrom
Groveer:fix_dock_point
Sep 9, 2026
Merged

fix: defer splash toplevel registration until real surface#1383
wineee merged 1 commit into
linuxdeepin:masterfrom
Groveer:fix_dock_point

Conversation

@Groveer

@Groveer Groveer commented Sep 8, 2026

Copy link
Copy Markdown
Contributor
  1. Register prelaunch splash surfaces only after the real window takes over (surfaceItemCreated), so clients never receive a half-initialized handle whose rectangleChanged has no listener.
  2. Track pending splash wrappers and keep the unregistered-surface error check in removeSurface for genuine caller bugs.
  3. Lower rectangleChanged logging to debug and keep a warning only for the missing-dock-wrapper case.

Log: Fix minimize animation flying to top-left (0,0) for slow-starting XWayland apps whose icon geometry request was silently dropped during the splash phase.

Influence:

  1. Launch browser and verify the minimize animation targets the dock icon.
  2. Rapidly open/close apps with splash screens and check no crashes.
  3. Verify dock preview and window list still work after launch.

fix: 延迟 splash 顶层注册至真实窗口接管

  1. 预启动 splash 表面仅在真实窗口接管(surfaceItemCreated)后注册, 避免客户端拿到 rectangleChanged 尚无监听者的半初始化句柄。
  2. 跟踪 pending splash 包装器,removeSurface 中保留对真实调用错误的 未注册表面错误检查。
  3. rectangleChanged 常规日志降级为 debug,仅保留找不到 dock 包装器的 警告。

Log: 修复慢启动 XWayland 应用最小化动画飞到左上角 (0,0) 的问题——其
splash 阶段的图标几何请求被静默丢弃。

Influence:

  1. 启动浏览器验证最小化动画指向 dock 图标。
  2. 快速开关带 splash 的应用验证无崩溃。
  3. 验证启动后 dock 预览与窗口列表正常。

PMS: BUG-375731

Summary by Sourcery

Ensure splash toplevels handle geometry updates reliably before real windows take over.

Bug Fixes:

  • Preserve splash-phase icon geometry updates so slow-starting applications target the correct dock icon during minimize animations.

Enhancements:

  • Centralize rectangle-change handling for splash and normal toplevels, with clearer diagnostics for missing dock wrappers and debug-level geometry logging.

@sourcery-ai

sourcery-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Delays splash foreign-toplevel exposure until the real surface takes over, preventing early rectangle requests from being lost and fixing minimize animations that fall back to (0,0). Pending splash teardown is handled safely, and rectangle-change logging now distinguishes expected debug activity from missing dock-wrapper warnings.

Sequence diagram for deferred splash toplevel registration

sequenceDiagram
    participant Splash as SplashSurfaceWrapper
    participant Manager as ForeignToplevelManager
    participant Client as ToplevelClient
    participant Dock as DockSurface

    Manager->>Splash: addSurface(wrapper)
    Manager->>Manager: insert into m_pendingSplashSurfaces
    Splash-->>Manager: surfaceItemCreated()
    Manager->>Manager: onSplashSurfaceItemCreated()
    Manager->>Manager: addSurface(wrapper)
    Manager->>Client: expose initialized toplevel handle
    Client->>Manager: set_rectangle(rect)
    Manager->>Dock: getSurface(surface)
    Dock-->>Manager: dockWrapper
    Manager->>Splash: setIconGeometry(iconGeometry)
Loading

State diagram for splash surface registration lifecycle

stateDiagram-v2
    [*] --> PendingSplash: addSurface(splash)
    PendingSplash --> RegisteredToplevel: surfaceItemCreated()
    PendingSplash --> [*]: removeSurface(splash)
    RegisteredToplevel --> [*]: removeSurface(wrapper)
    RegisteredToplevel --> RegisteredToplevel: rectangleChanged -> setIconGeometry
Loading

File-Level Changes

Change Details Files
Defers foreign-toplevel registration for splash surfaces until the real surface item is created, while preserving cleanup validation.
  • Tracks splash wrappers in a pending set instead of immediately creating a client-visible handle.
  • Registers the converted wrapper from the surfaceItemCreated callback.
  • Treats pending splash teardown as valid while retaining critical logging for other unregistered removals.
src/modules/foreign-toplevel/foreigntoplevelmanagerv1.cpp
src/modules/foreign-toplevel/foreigntoplevelmanagerv1.h
Improves rectangle-change diagnostics while retaining icon geometry updates.
  • Warns when the dock wrapper cannot be resolved.
  • Logs normal rectangle and computed icon geometry changes at debug level.
  • Continues applying dock-relative icon geometry to the wrapper.
src/modules/foreign-toplevel/foreigntoplevelmanagerv1.cpp

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/modules/foreign-toplevel/foreigntoplevelmanagerv1.cpp" line_range="333-334" />
<code_context>
 {
     auto it = d->m_surfaces.find(wrapper);
     if (it == d->m_surfaces.end()) {
+        // A splash that was torn down before the real surface took over is a
+        // legitimate unregistered surface, not a caller bug.
+        if (d->m_pendingSplashSurfaces.remove(wrapper))
+            return;
         qCCritical(lcTlProtocol) << wrapper << " is not registered in foreign toplevel";
         return;
</code_context>
<issue_to_address>
**issue (bug_risk):** removeSurface removes a pending splash from m_pendingSplashSurfaces and returns without disconnecting the surfaceItemCreated connection. If that wrapper later emits surfaceItemCreated while still alive, onSplashSurfaceItemCreated calls addSurface and registers a surface that was already explicitly removed.

**Triggers:** When a pending splash is removed before conversion but its wrapper later completes conversion.

**Suggested fix:** Disconnect the pending signal when removing the splash, or have onSplashSurfaceItemCreated verify that the wrapper is still pending before registering it.

```suggestion
    if (!d->m_pendingSplashSurfaces.remove(wrapper))
        return;
    addSurface(wrapper);
```
</issue_to_address>

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

Comment thread src/modules/foreign-toplevel/foreigntoplevelmanagerv1.cpp Outdated
Comment thread src/modules/foreign-toplevel/foreigntoplevelmanagerv1.cpp
Comment thread src/modules/foreign-toplevel/foreigntoplevelmanagerv1.cpp Outdated
@Groveer
Groveer force-pushed the fix_dock_point branch 6 times, most recently from bedcc5b to df8bc15 Compare September 9, 2026 03:50
wineee
wineee previously approved these changes Sep 9, 2026
1. Connect the foreign-toplevel rectangleChanged handler in
   setupHandleForWrapper for both splash and normal handles, so a
   client's set_rectangle sent during the splash phase is not
   silently dropped.
2. Keep splash toplevels registered in the taskbar as designed; the
   lost signal connection is moved earlier instead of deferring
   registration.

Log: Fix minimize animation flying to top-left (0,0) for slow-starting
XWayland apps whose icon geometry request was dropped during the
splash phase.

Influence:
1. Launch browser and verify the minimize animation targets the dock icon.
2. Rapidly open/close apps with splash screens and check no crashes.
3. Verify splash icon still appears in the taskbar during launch.

fix: 在 splash 交接前提前连接 dock rectangle 处理

1. 在 setupHandleForWrapper 中对 splash 与普通 handle 统一提前连接
   foreign-toplevel 的 rectangleChanged,避免 splash 阶段客户端的
   set_rectangle 被静默丢弃。
2. 保留 splash 顶层注册到任务栏的设计,将丢失的信号连接提前而非
   延迟注册。

Log: 修复慢启动 XWayland 应用最小化动画飞到左上角 (0,0) 的问题——
其 splash 阶段的图标几何请求被丢弃。

Influence:
1. 启动浏览器验证最小化动画指向 dock 图标。
2. 快速开关带 splash 的应用验证无崩溃。
3. 验证启动过程中 splash 图标仍出现在任务栏。

PMS: BUG-375731
Signed-off-by: groveer <guoyao@uniontech.com>
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Groveer, wineee

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

@wineee
wineee merged commit 4f1bd38 into linuxdeepin:master Sep 9, 2026
7 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