Repository navigation
feat: add compositor-managed tooltip window for Wayland - #1813
Conversation
Reviewer's GuideAPIDefine the dock preview-context entry points and the monitor/helper interfaces that let dock applets and task management share a Wayland preview context.
Uses of the APIPass the dock panel into the Wayland window monitor so it can obtain the panel-owned preview context.
ImplementationForward the dock panel's preview-context request to its helper and initialize the helper pointer safely.
Replace the monitor-owned preview context with the panel-provided context, and manage its acquisition, preview requests, and cleanup.
Implement the shared Treeland preview context and tooltip-shell lifecycle, including tooltip positioning, frame handling, and cleanup.
UIUpdate PanelToolTip to bind to the active shared tooltip window and close safely when its item or host window disappears.
ConfigurationRequire the Treeland protocol version that provides the shared foreign-toplevel preview context and generate its client protocol bindings.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 7 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="frame/wayland/dtooltipwindow.cpp" line_range="72-79" />
<code_context>
+ invalidateContent();
+ });
+ connect(window, &QQuickWindow::frameSwapped, this, [this] {
+ const auto generation = m_generation.load();
+ QMetaObject::invokeMethod(this, [this, generation] {
+ if (!m_enabled || m_suspended || !m_window->isVisible() || generation != m_generation.load())
+ return;
+ m_hasContent = true;
+ Q_EMIT contentCommitted();
+ }, Qt::QueuedConnection);
+ }, Qt::DirectConnection);
+}
+
</code_context>
<issue_to_address>
**Stale tooltip content appears**
When an old frame callback runs after retirement and resume, or a tooltip is canceled before its first show and reopened before the queued callback runs, `frameSwapped` captures the generation when its callback runs, and closing the not-yet-visible tooltip does not invalidate that generation. The old callback can match the new request, commit stale content, and show the previous tooltip.
Capture the generation when the frame is submitted and invalidate it when closing a not-yet-visible tooltip.
Also at `frame/qml/PanelToolTip.qml:125-128`.
</issue_to_address>
### Comment 2
<location path="frame/qml/PanelToolTip.qml" line_range="89" />
<code_context>
+ if (nativeWindow) {
+ // Re-register a reused window with the compositor. close() clears
+ // the previous request from the shared dock preview context.
+ if (!compositorTooltipRequested && !showOnCompositor(nativeWindow))
return
-
</code_context>
<issue_to_address>
**Reused tooltip never appears**
When a tooltip owner reuses a retained `nativeWindow` after its compositor request cannot be prepared, including after monitor cleanup, `beginOpen()` returns when `showOnCompositor(nativeWindow)` fails, without falling back to `toolTipWindow` or clearing `openPending`. The tooltip remains logically visible but never appears.
On compositor registration failure, clear the pending state and open the tooltip through `toolTipWindow` instead.
Also at `frame/qml/PanelToolTip.qml:90`, `panels/dock/taskmanager/treelandwindowmonitor.cpp:203`.
</issue_to_address>
### Comment 3
<location path="panels/dock/tray/SurfacePopup.qml" line_range="32-34" />
<code_context>
+ if (isWayland && shellSurface)
+ DockCompositor.closeShellSurface(shellSurface)
+ }
+ onShellSurfaceChanged: {
+ if (isWayland)
+ close(false)
+ }
</code_context>
<issue_to_address>
**Replaced surfaces remain open**
When a live tooltip shell surface is replaced during rapid tooltip changes, `close(false)` suppresses `closed()`, and Wayland disables `autoClose`, so replacing the shell surface leaves the old plugin surface open.
Close the old shell surface through the compositor before replacing it.
Also at `panels/dock/tray/TrayItemSurfacePopup.qml:138-141`, `panels/dock/cardleft/package/CardLeftDockArea.qml:426-429`.
</issue_to_address>
### Comment 4
<location path="panels/dock/taskmanager/treelandwindowmonitor.cpp" line_range="129" />
<code_context>
void TreeLandWindowMonitor::stop()
{
m_foreignToplevelManager.reset(nullptr);
+ clearTooltipWindows();
}
</code_context>
<issue_to_address>
**Restart reuses stale preview context**
When the monitor is stopped and later started again, `stop()` resets the foreign-toplevel manager but leaves `m_dockPreview` alive. After a subsequent `start()`, `ensureDockPreviewContext()` returns early for that non-null context, so tooltip and preview requests use the context associated with the old manager instead of creating one for the new connection.
Reset `m_dockPreview` when stopping the monitor, before creating a replacement foreign-toplevel manager.
Also at `panels/dock/taskmanager/treelandwindowmonitor.cpp:165`.
</issue_to_address>
### Comment 5
<location path="panels/dock/taskmanager/package/AppItem.qml" line_range="539" />
<code_context>
Timer {
id: previewTimer
- interval: 500
+ interval: toolTip.isWayland ? 300 : 500
running: false
repeat: false
</code_context>
<issue_to_address>
**Wayland tooltips appear too quickly**
When the pointer briefly crosses the overflow button or app-runtime item on Wayland, `TaskOverflowButton.qml` still uses a 50 ms show timer, and `appruntimeitem.qml` opens its tooltip immediately, so these tooltips bypass the new 300 ms delay and flash during brief pointer crossings.
Apply the 300 ms Wayland delay to the overflow-button and app-runtime tooltips.
Also at `frame/qml/PanelToolTip.qml:24-25`.
</issue_to_address>
### Comment 6
<location path="panels/dock/tray/TrayItemSurfacePopup.qml" line_range="133" />
<code_context>
id: toolTip
property alias shellSurface: toolTipContent.shellSurface
+ contentReady: !!shellSurface && toolTipContent.hasSurfaceContent && shellSurface.width > 1 && shellSurface.height > 1
+ onWindowCreated: window => toolTipContent.createOutput(window)
+ onClosed: {
+ if (isWayland && shellSurface)
</code_context>
<issue_to_address>
**Tooltip overlaps tray menu**
When a tray item requests a menu while its compositor-managed tooltip is visible, `TrayItemSurfacePopup` opens its menu in the `TrayPopupTypeMenu` branch without closing the compositor-managed tooltip. The tooltip remains an independent native surface while the menu opens, so both surfaces can be shown at once.
Close the tooltip when the tray menu opens, and close the menu if the tooltip opens, matching the mutual-exclusion handling in `SurfacePopup.qml`.
</issue_to_address>
### Comment 7
<location path="panels/dock/tray/SurfacePopup.qml" line_range="26" />
<code_context>
- if (visible && menuWindow.visible)
+ property alias shellSurface: surfaceLayer.shellSurface
+ contentReady: !!shellSurface && surfaceLayer.hasSurfaceContent && shellSurface.width > 1 && shellSurface.height > 1
+ toolTipDirection: Dock.Bottom
+ onWindowCreated: window => surfaceLayer.createOutput(window)
+ onClosed: {
</code_context>
<issue_to_address>
**Tray tooltip uses the wrong dock edge**
When a tray surface tooltip is shown while the panel is not at the bottom of the screen, `DockPanel.requestTooltip()` uses the supplied direction to select the tooltip rectangle’s anchor edge, so the hard-coded bottom direction anchors tray tooltips to the wrong edge when the panel is on the top, left, or right side.
Remove the fixed direction or derive it from the panel position so the compositor request follows the current dock edge.
</issue_to_address>
|
689182e to
085ba82
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
| 🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['将 dockPreviewContext() 的查询与创建职责拆分,eventFilter 中先查询是否存在再创建,避免副作用作为条件', '在 delete-from-slot 的 lambda 处补充注释,说明 Qt 连接机制保证安全性'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['考虑为 DockPanel 的 Q_INVOKABLE 与 DockHelper 的 virtual 取不同方法名(如 requestDockPreviewContext / dockPreviewContext)以区分调用层级', '将 hideTimer 间隔抽为命名常量(如 static constexpr int HideTimeoutMs = 800)'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['可选:dynamic_cast 可在开启 RTTI 的 Qt 构建中保留,若需极致优化可改用 qobject_cast 配合 Q_DECLARE_INTERFACE,但当前场景非必要'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// waylanddockhelper.cpp — 拆分 dockPreviewContext 的查询与创建职责(可选优化)
bool WaylandDockHelper::hasDockPreviewContext(QWindow *anchor) const
{
return m_dockPreview && m_previewAnchor == anchor;
}
QObject *WaylandDockHelper::dockPreviewContext(QWindow *anchor)
{
if (!anchor || !m_previewManager->isActive())
return nullptr;
if (hasDockPreviewContext(anchor))
return m_dockPreview.get();
// ... 创建逻辑保持不变
}
// eventFilter 中改为:
// case QEvent::Show:
// if (!hasDockPreviewContext(m_panel->window()))
// dockPreviewContext(m_panel->window()); // 显式创建
// ...本报告由 AI 代码审查工具自动生成 |
e74387d to
085ba82
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1. Add a shared dock preview context API to DockPanel and DockHelper so applets share the panel's Wayland context. 2. Move TreeLandDockPreviewManager and TreeLandDockPreviewContext into WaylandDockHelper with a single context per anchor. 3. Add tooltip surface support with a dedicated shell integration that defers role assignment until the first buffer commit. 4. Connect tooltip window show/hide and frameSwapped events to show and close the tooltip via the preview context. 5. Make TreeLandWindowMonitor use the panel-provided preview context instead of creating its own. 6. Bump TreelandProtocols requirement to 0.9.0 and add the foreign- toplevel-manager protocol. Log: Dock tooltip and window preview now share a unified Wayland preview context Influence: Dock tooltips and previews become more stable on Treeland feat(dock): 通过共享上下文统一处理任务栏提示与预览 1. 在 DockPanel 和 DockHelper 中新增共享的停靠预览上下文接口,使各插件复 用面板的 Wayland 上下文。 2. 将 TreeLandDockPreviewManager 和 TreeLandDockPreviewContext 移入 WaylandDockHelper,每个锚点仅维护一个上下文。 3. 新增工具提示 surface 支持,使用专用 shell integration 延迟角色分配至 首个缓冲区提交。 4. 连接提示窗口的显示/隐藏及帧交换事件,通过预览上下文显示和关闭提示。 5. 使 TreeLandWindowMonitor 使用面板提供的预览上下文,不再自行创建。 6. 将 TreelandProtocols 依赖升级至 0.9.0,并新增 foreign-toplevel- manager 协议。 Log: 任务栏提示与窗口预览现共用统一的 Wayland 预览上下文 Influence: 提升 Treeland 下任务栏提示与预览的稳定性 PMS: TASK-398771
085ba82 to
8729ab7
Compare
Log: Tooltips on Wayland are now rendered as compositor-managed surfaces with smooth transitions to window previews
Influence:
feat: 为 Wayland 增加合成器托管的提示窗口
动画。
Log: Wayland 下提示现以合成器托管表面渲染,并可与窗口预览平滑过渡
Influence:
PMS: TASK-398771
Summary by Sourcery
Enable compositor-managed Wayland tooltips with reliable lifecycle handling and smooth integration with dock window previews.
New Features:
Bug Fixes:
Enhancements:
Build:
Tests: