Repository navigation
feat: expose KWin split menu platform functions - #345
Conversation
Reviewer's GuideAdds unified platform-native split-menu functions for QWidget/QML consumers, using KWin’s X11 client messages or the Deepin Wayland client-management protocol, with capability checks, asynchronous-request filtering, and backend diagnostics. Sequence diagram for the Wayland split-menu requestsequenceDiagram
participant Client as QWidget or QML
participant Hook as DWaylandInterfaceHook
participant Management as DClientManagement
participant Compositor as KWin compositor
Client->>Hook: supportSplitMenu(wid)
Hook->>Management: isValid()
Management->>Compositor: bind com_deepin_client_management
Client->>Hook: showSplitMenu(wid, buttonRect)
Hook->>Management: showSplitMenu(wid, buttonRect)
Management->>Compositor: get_window_from_point()
Compositor-->>Management: windowFromPoint(windowId)
Management->>Management: handleWindowFromPoint(windowId)
Management->>Compositor: show_split_menu(buttonRect, windowId)
Client->>Hook: hideSplitMenu(wid, delay)
Hook->>Management: hideSplitMenu(wid, delay)
Management->>Compositor: hide_split_menu(delay)
Sequence diagram for the X11 split-menu requestsequenceDiagram
participant Client as QWidget or QML
participant Utility as X11 Utility
participant KWin as KWin via X11
Client->>Utility: supportSplitMenu(wid)
Utility->>KWin: Check _WM_TOGGLE_SPLIT_MENU and compositing support
KWin-->>Utility: Capability result
Client->>Utility: showSplitMenu(wid, buttonRect)
Utility->>KWin: ClientMessage(_WM_TOGGLE_SPLIT_MENU, show, buttonRect)
Client->>Utility: hideSplitMenu(wid, delay)
Utility->>KWin: ClientMessage(_WM_TOGGLE_SPLIT_MENU, hide, delay)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="xcb/utility_x11.cpp" line_range="530-538" />
<code_context>
+
+void DClientManagement::showSplitMenu(WId wid, const QRect &buttonRect)
+{
+ if (!wid || !buttonRect.isValid()) {
+ qCDebug(lcWaylandSplitMenu) << "Ignore invalid SplitMenu show request, wid:" << wid
+ << "button rect:" << buttonRect;
</code_context>
<issue_to_address>
**nitpick (broader_impact):** The X11 show and hide paths send `_WM_TOGGLE_SPLIT_MENU` messages without checking whether the compositor supports the atom. `internAtom(..., false)` creates the atom on unsupported compositors, then sends a message that cannot be handled instead of gracefully ignoring the request.
**Triggers:** When a client calls showSplitMenu or hideSplitMenu on a compositor that does not advertise `_WM_TOGGLE_SPLIT_MENU`.
**Suggested fix:** Check `supportSplitMenu` or intern the atom with `only_if_exists=true` before sending, and return when the atom is unavailable.
</issue_to_address>| if (!wid || !buttonRect.isValid()) { | ||
| qCDebug(lcDxcbSplitMenu) << "Ignore invalid SplitMenu show request, wid:" << wid | ||
| << "button rect:" << buttonRect; | ||
| return; | ||
| } | ||
|
|
||
| xcb_client_message_event_t event{}; | ||
| event.response_type = XCB_CLIENT_MESSAGE; | ||
| event.type = internAtom("_WM_TOGGLE_SPLIT_MENU", false); |
There was a problem hiding this comment.
nitpick (broader_impact): The X11 show and hide paths send _WM_TOGGLE_SPLIT_MENU messages without checking whether the compositor supports the atom. internAtom(..., false) creates the atom on unsupported compositors, then sends a message that cannot be handled instead of gracefully ignoring the request.
Triggers: When a client calls showSplitMenu or hideSplitMenu on a compositor that does not advertise _WM_TOGGLE_SPLIT_MENU.
Suggested fix: Check supportSplitMenu or intern the atom with only_if_exists=true before sending, and return when the atom is unavailable.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 单例模式在 Qt 平台插件中是标准做法,可保持现状。如需改进,可使用 Q_GLOBAL_STATIC 或智能指针管理生命周期。 2. 代码质量 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 为公共 API 函数添加 Doxygen 风格的文档注释,说明参数含义(wid 为窗口 ID,buttonRect 为按钮区域坐标)。在 #define private public 处添加注释说明这是访问 QtWaylandClient 私有 API 的必要手段。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: Wayland 协议调用为异步非阻塞设计,使用 wl_display_flush 确保消息发送。XCB 实现使用单次 xcb_send_event + xcb_flush,性能优良。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 输入验证完善(wid != 0、buttonRect.isValid() 检查)。supportForSplittingWindowByType 从 reinterpret_cast 改为 static_cast 是安全性改进。无安全漏洞。 💡 改进建议代码示例// 改进建议:为公共 API 添加文档注释
/// 检查窗口是否支持分屏菜单功能
/// \param wid 窗口 ID
/// \return 支持返回 true,不支持返回 false
bool DClientManagement::supportSplitMenu(WId wid);
/// 显示分屏菜单
/// \param wid 目标窗口 ID
/// \param buttonRect 触发按钮的矩形区域坐标
void DClientManagement::showSplitMenu(WId wid, const QRect &buttonRect);
/// 隐藏分屏菜单
/// \param wid 目标窗口 ID
/// \param delay 是否延迟隐藏
void DClientManagement::hideSplitMenu(WId wid, bool delay);
// 改进建议:在 #define private public 处添加注释
// 访问 QtWaylandClient 私有 API 所需,用于获取 Wayland display 的 globals 列表
#define private public
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#undef private本报告由 AI 代码审查工具自动生成 |
c5bd363 to
b26f4ae
Compare
9c3383d to
b074127
Compare
1. Add DClientManagement class for Wayland client management protocol 2. Implement showSplitMenu, hideSplitMenu, and supportSplitMenu functions 3. Add Wayland protocol binding for com_deepin_client_management interface 4. Implement XCB split menu via _WM_TOGGLE_SPLIT_MENU client messages 5. Register new function pointers in both Wayland and XCB hooks 6. Fix potential out-of-bounds read in supportForSplittingWindowByType 7. Add logging categories for split menu debugging 8. Update copyright year and CMake configuration for Wayland protocols Log: Added split menu support for window splitting feature Influence: 1. Test SplitMenu display when hovering over split button on XCB platform 2. Test SplitMenu display and hide on Wayland platform 3. Verify supportSplitMenu returns correct values based on window properties 4. Test menu positioning with different button rectangle coordinates 5. Verify menu hides properly with and without delay parameter 6. Test behavior when compositor does not support the protocol 7. Verify window switching triggers proper menu hide 8. Test edge cases with invalid window IDs and button rectangles feat: 为 Wayland 和 XCB 添加分屏菜单支持 1. 新增 DClientManagement 类用于 Wayland 客户端管理协议 2. 实现 showSplitMenu、hideSplitMenu 和 supportSplitMenu 函数 3. 添加 com_deepin_client_management 接口的 Wayland 协议绑定 4. 通过 _WM_TOGGLE_SPLIT_MENU 客户端消息实现 XCB 分屏菜单 5. 在 Wayland 和 XCB 钩子中注册新的函数指针 6. 修复 supportForSplittingWindowByType 中潜在的越界读取问题 7. 添加分屏菜单调试日志分类 8. 更新版权年份和 Wayland 协议的 CMake 配置 Log: 新增窗口分屏菜单功能 Influence: 1. 测试 XCB 平台下悬停分屏按钮时菜单的显示 2. 测试 Wayland 平台下分屏菜单的显示和隐藏 3. 验证 supportSplitMenu 根据窗口属性返回正确的值 4. 测试不同按钮矩形坐标下的菜单位置 5. 验证带延迟和不带延迟参数时菜单的正确隐藏 6. 测试合成器不支持该协议时的行为 7. 验证窗口切换时是否正确隐藏菜单 8. 测试无效窗口 ID 和按钮矩形的边界情况 PMS: BUG-370181
b074127 to
f11da78
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia 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 |
为 QWidget 与 QML 标题栏提供统一的平台函数
_d_supportSplitMenu、_d_showSplitMenu、_d_hideSplitMenu,使客户端能够请求 KWin 显示分屏菜单。X11 通过
_WM_TOGGLE_SPLIT_MENU发送按钮全局矩形和隐藏请求;Wayland 通过 client-management 协议请求菜单,过滤过期的异步窗口查询响应,并避免其他窗口的隐藏请求干扰当前菜单。窗口关闭或消失后的菜单清理由窗管负责。验证:实现工作目录中 Qt5 X11/Wayland、Qt6 X11 构建通过,均使用最多 6 个核心;PR 分支基于最新 master,差异检查通过。仓库当前未启用 Qt6 Wayland 构建,真实 KWin 桌面显示效果尚未实测。
关联调用端:
Summary by Sourcery
Expose cross-platform KWin split-menu platform functions for client applications.
New Features:
Bug Fixes:
Enhancements:
Build: