Skip to content

feat(dock): draw windowless app tooltips on treeland - #1772

Draft
glyvut wants to merge 2 commits into
linuxdeepin:masterfrom
glyvut:p
Draft

glyvut wants to merge 2 commits into
linuxdeepin:masterfrom
glyvut:p

Conversation

@glyvut

@glyvut glyvut commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Add requestTooltip to the window monitor and route the plain-text tooltip
of app items without windows through the treeland dock preview context,
so the compositor can animate between tooltip and window preview.
The preview context is now created lazily and shared by both requests.

无窗口应用的悬停提示改由合成器绘制,preview context 改为惰性创建并
在预览与 tooltip 之间复用,使两者切换动画连续。

Log: 无窗口应用的 tooltip 交由合成器绘制
PMS: TASK-396711
Influence: wayland(treeland)下无窗口应用的 tooltip 由合成器绘制,与窗口预览切换更连贯;X11 行为不变。

Summary by Sourcery

Support compositor-rendered tooltips for windowless dock applications while preserving fallback behavior and smooth transitions to window previews.

New Features:

  • Route windowless app tooltip text through the Treeland compositor on Wayland so it can share the dock preview transition experience.

Bug Fixes:

  • Prevent pending or active tooltips from appearing after pointer exit or app activation, and preserve native tooltip behavior when compositor support is unavailable.

Enhancements:

  • Share a lazily created Treeland preview context between window previews and tooltips, while switching cleanly from tooltips to window previews when an app opens a window.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: glyvut

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

@sourcery-ai

sourcery-ai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Windowless dock application tooltips now render through Treeland on Wayland via a new requestTooltip path, while X11 retains native tooltips. The Treeland dock preview context is created lazily and reused for both tooltip and window previews, enabling continuous transitions when an application gains windows during hover.

Sequence diagram for Wayland windowless app tooltip rendering

sequenceDiagram
    actor User
    participant AppItem
    participant TaskManager
    participant WindowMonitor
    participant Treeland

    User->>AppItem: onEntered()
    AppItem->>TaskManager: requestTooltip(text, Panel.rootObject, xOffset, yOffset, direction)
    TaskManager->>WindowMonitor: requestTooltip(text, relativePositionItem, xOffset, yOffset, direction)
    WindowMonitor->>WindowMonitor: ensureDockPreviewContext(relativePositionItem)
    WindowMonitor->>Treeland: get_dock_preview_context(wlSurface)
    WindowMonitor->>Treeland: show_tooltip(text, xOffset, yOffset, direction)
    Treeland-->>User: Render compositor tooltip
Loading

Sequence diagram for tooltip to window preview transition

sequenceDiagram
    actor User
    participant AppItem
    participant TaskManager
    participant WindowMonitor
    participant Treeland

    User->>AppItem: onEntered()
    AppItem->>TaskManager: requestTooltip(text, Panel.rootObject, xOffset, yOffset, direction)
    TaskManager->>WindowMonitor: requestTooltip(text, relativePositionItem, xOffset, yOffset, direction)
    WindowMonitor->>Treeland: show_tooltip(text, xOffset, yOffset, direction)
    AppItem->>AppItem: windows change from empty to non-empty
    AppItem->>TaskManager: requestPreview(modelIndex, Panel.rootObject, xOffset, yOffset, direction)
    TaskManager->>WindowMonitor: requestPreview(sourceModel, relativePositionItem, xOffset, yOffset, direction)
    WindowMonitor->>Treeland: showWindowsPreview(windowIds, xOffset, yOffset, direction)
    Treeland-->>User: Animate from tooltip to window preview
Loading

File-Level Changes

Change Details Files
Routes windowless app tooltips to the Treeland compositor while preserving native X11 tooltip behavior.
  • Adds Wayland-only tooltip selection and lifecycle handling in dock and task-manager QML.
  • Exposes tooltip requests through the task manager and abstract window-monitor interfaces.
  • Uses compositor preview APIs for tooltip display and hides them on hover exit or activation.
panels/dock/multitaskview/package/multitaskview.qml
panels/dock/taskmanager/package/AppItem.qml
panels/dock/taskmanager/abstractwindowmonitor.h
panels/dock/taskmanager/abstractwindowmonitor.cpp
panels/dock/taskmanager/taskmanager.h
panels/dock/taskmanager/taskmanager.cpp
Shares a lazily initialized Treeland dock preview context between tooltip and window-preview requests.
  • Extracts context creation and lifecycle wiring into a reusable helper.
  • Adds tooltip rendering to the dock preview context.
  • Transitions from a compositor tooltip to a window preview when a hovered app opens a window.
panels/dock/taskmanager/treelandwindowmonitor.h
panels/dock/taskmanager/treelandwindowmonitor.cpp
panels/dock/taskmanager/package/AppItem.qml
Tightens Treeland window-preview validation now that windowless applications use the tooltip path.
  • Rejects preview requests with no model rows or valid window IDs.
  • Removes the previous placeholder tooltip fallback from window-preview requests.
  • Keeps preview requests dependent on an active Treeland foreign-toplevel manager.
panels/dock/taskmanager/treelandwindowmonitor.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

@glyvut
glyvut force-pushed the p branch 2 times, most recently from 5e03ba8 to d847bad Compare October 20, 2026 12:42
@deepin-bot

deepin-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.60
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1773

@glyvut
glyvut marked this pull request as ready for review October 21, 2026 01:19

@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 2 issues

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

## Individual Comments

### Comment 1
<location path="panels/dock/taskmanager/package/AppItem.qml" line_range="439" />
<code_context>
         sourceSize: Qt.size(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE, Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE)
     }

+    readonly property bool useCompositorTooltip: Qt.platform.pluginName === "wayland"
+    property bool compositorTooltipActive: false
+    function compositorTooltipApplet() {
</code_context>
<issue_to_address>
**Wayland tooltips disappear**

When the dock runs on Wayland and the Treeland foreign-toplevel manager or protocol is unavailable or inactive, `useCompositorTooltip` selects the compositor path, so the QML callers skip or suppress `PanelToolTip`; `requestTooltip` then returns without displaying a tooltip or reporting success. Windowless-app and multitasking-view tooltips disappear.

Use the compositor path only when the Treeland protocol is available and active, or fall back to `PanelToolTip` when `requestTooltip` cannot display the tooltip.

Also at `panels/dock/multitaskview/package/multitaskview.qml:37`, `panels/dock/multitaskview/package/multitaskview.qml:81-82`, `panels/dock/taskmanager/package/AppItem.qml:465-467`, `panels/dock/taskmanager/package/AppItem.qml:472`, `panels/dock/taskmanager/treelandwindowmonitor.cpp:203-205`.
</issue_to_address>

### Comment 2
<location path="panels/dock/taskmanager/package/AppItem.qml" line_range="491" />
<code_context>
+            // 无窗口应用:交给合成器绘制 tooltip,以便与窗口预览保持连续的过渡动画
+            tooltipTimer.xOffset = xOffset
+            tooltipTimer.yOffset = yOffset
+            tooltipTimer.start()
+            return
+        }
</code_context>
<issue_to_address>
**Click leaves tooltip visible**

When the user presses the app before the 50 ms tooltip delay expires, `tooltipTimer` can fire after the user presses the windowless app: the press handler closes the native tooltip and preview but does not stop this timer. Its callback then requests a compositor tooltip while the app is being launched.

Stop `tooltipTimer` in the press handler before closing the tooltip or preview.
</issue_to_address>

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

Comment thread panels/dock/taskmanager/package/AppItem.qml
Comment thread panels/dock/taskmanager/package/AppItem.qml
@glyvut
glyvut force-pushed the p branch 2 times, most recently from 8a2a8fc to c1748f5 Compare October 21, 2026 03:16
Add requestTooltip to the window monitor and route the plain-text tooltip
of app items without windows through the treeland dock preview context,
so the compositor can animate between tooltip and window preview.
The preview context is now created lazily and shared by both requests.

无窗口应用的悬停提示改由合成器绘制,preview context 改为惰性创建并
在预览与 tooltip 之间复用,使两者切换动画连续。

Log: 无窗口应用的 tooltip 交由合成器绘制
PMS: TASK-396711
Influence: wayland(treeland)下无窗口应用的 tooltip 由合成器绘制,与窗口预览切换更连贯;X11 行为不变。
Resolve the task manager applet of the same dock panel and reuse its dock
preview context, so the multitasking view tooltip is drawn by the
compositor on wayland and falls back to PanelToolTip otherwise.

多任务视图在 wayland 下复用同面板 taskmanager 的 dock preview context,
由合成器绘制 tooltip;其余情况回退到 PanelToolTip。

Log: 多任务视图 tooltip 改用合成器绘制
PMS: TASK-396711
Influence: wayland 下多任务视图 tooltip 与任务栏 tooltip 一致;找不到 taskmanager 或非 wayland 时行为不变。
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交为 dde-shell 的 dock 模块新增了在 TreeLand 合成器上绘制无窗口应用 tooltip 的功能, 涉及 8 个文件、约 208 行新增、46 行删除。代码结构清晰,重构提取了 ensureDockPreviewContext 公共方法减少重复,回退逻辑正确(合成器协议不可用时回退原生 tooltip),null 检查链完整。 未发现安全漏洞。存在少量代码质量改进建议(日志分类一致性、防御性 null 检查)和性能微优化建议 (缓存 compositorTooltipApplet 结果),但不影响功能正确性和安全性。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

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

建议: ['multitaskview.qml toolTipShowTimer.onTriggered 中 var xOffset, yOffset, interval = 10 声明方式易误解,建议分行声明或添加注释说明仅 interval 被赋初值。']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

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

建议: ['建议将 treelandwindowmonitor.cpp 中的 qWarning() 替换为 qCWarning(taskManagerLog) 以保持日志分类一致性。', '建议在 ensureDockPreviewContext() 开头添加 if (!m_foreignToplevelManager) return; 使函数自包含。']


3. 代码性能 ✅

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

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

建议: ['可考虑在 compositorTooltipActive 状态变更时缓存 compositorTooltipApplet() 的返回值,避免重复遍历。']


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

// treelandwindowmonitor.cpp - 建议在 ensureDockPreviewContext 中添加防御性 null 检查
void TreeLandWindowMonitor::ensureDockPreviewContext(QWindow *relativePositionItem)
{
    if (!m_dockPreview.isNull())
        return;

    if (!m_foreignToplevelManager)  // 防御性检查,使函数自包含
        return;

    auto window = relativePositionItem;
    if (!window) return;
    auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow*>(window->handle());
    if (!waylandWindow) return;

    auto context = m_foreignToplevelManager->get_dock_preview_context(waylandWindow->wlSurface());
    m_dockPreview.reset(new TreeLandDockPreviewContext(context));
    connect(window, &QWindow::visibleChanged, m_dockPreview.get(), [this]() {
        m_dockPreview.reset();
    });
    connect(m_dockPreview.get(), &TreeLandDockPreviewContext::closed, this, [this]() {
        emit previewShouldClear();
    });
}

// treelandwindowmonitor.cpp - 建议统一日志分类
// 将 qWarning() 替换为 qCWarning(taskManagerLog)
qCWarning(taskManagerLog) << "requestPreview called without any window";
qCWarning(taskManagerLog) << "requestPreview called without any valid window id";

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

@mhduiy
mhduiy requested a review from 18202781743 October 21, 2026 03:32
@18202781743
18202781743 requested a review from BLumia October 21, 2026 09:53
sourceSize: Qt.size(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE, Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE)
}

readonly property bool useCompositorTooltip: Qt.platform.pluginName === "wayland"

@18202781743 18202781743 Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

能否给dock定制一个PanelToolTip,覆盖掉dde-shell提供的默认的实现,
在这个控件里区分是x11还是treeland,在treeland情况下调用预览的show_tooltip接口,在x11下保持原来的,沿用PanelToolTipWindow去实现,
ToolTip相对位置,文本等,PanelToolTip已经存在已有的接口现,只有显示时不一样,
dde-shell不仅仅只有这几个tooltip,还有启动器等插件,

@glyvut
glyvut marked this pull request as draft October 22, 2026 06:51
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