Skip to content

fix: skip popup position clamping on Wayland#640

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/wayland-popup-position
Jun 17, 2026
Merged

fix: skip popup position clamping on Wayland#640
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/wayland-popup-position

Conversation

@yixinshark

Copy link
Copy Markdown
Contributor

Summary

  • Skip global screen-bound popup clamping on Wayland.
  • Preserve Qt/Wayland popup placement relative to the parent surface.
  • Keep the existing X11 position adjustment unchanged.

Test plan

  • Tested with dde-shell dock context menu on Wayland/Treeland with popup blur enabled.
  • Confirmed the menu opens at the expected pointer position.

Pms: BUG-295233

@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.

Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@yixinshark yixinshark force-pushed the fix/wayland-popup-position branch from 0062ae5 to 4832a7d Compare June 17, 2026 03:42
@deepin-bot

deepin-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.7.44
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #641

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, yixinshark

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

Wayland QQuickPopupWindow positions are relative to the parent surface instead of global screen coordinates.
Skip the global screen-bound clamping for popup windows on Wayland so Qt and the compositor keep the intended popup placement.

Wayland 下 QQuickPopupWindow 的位置是相对父 surface 的,不是屏幕全局坐标。
在 Wayland 下跳过 popup 窗口的全局屏幕边界裁剪,让 Qt 和合成器保留原本的弹出位置。
X11下需要整个屏幕的尺寸去计算边缘溢出屏幕。

Log: skip popup position clamping on Wayland
Pms: BUG-295233
Change-Id: I5cdaea0094fc124609e8f016da8d846cb4106929
@yixinshark yixinshark force-pushed the fix/wayland-popup-position branch from 4832a7d to 62512cf Compare June 17, 2026 07:07
@yixinshark

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码准确修复了Wayland平台下弹窗定位异常及边界计算错误问题。
逻辑严谨且无任何安全风险,符合满分标准。

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

DPopupWindowHandle::adjustPopupPosition() 函数入口处增加了对Wayland平台的判断,直接返回交由合成器处理,完美规避了X11专属位置调整逻辑在Wayland下的越界与翻转错误。将 screen->availableGeometry() 替换为 screen->geometry(),修正了包含任务栏等区域在内的完整屏幕边界计算基准,逻辑严密无误。
建议:保持现有逻辑,无需额外修改。

  • 2.代码质量(良好)✓

代码改动极其精简且直击痛点,两处修改分别对应两个核心BUG点。平台判断前置,避免了后续无意义的尺寸获取与屏幕计算,符合“早返回”的编码规范。
建议:建议在新增的Wayland平台判断语句上方补充单行注释,说明跳过调整的具体原因以提升可读性。

  • 3.代码性能(高效)✓

新增的 DGuiApplicationHelper::testAttribute 调用开销极小。在Wayland环境下直接跳过后续的尺寸获取、屏幕遍历及矩形边界计算,显著减少了不必要的CPU计算开销。geometry() 与原 availableGeometry() 接口调用性能一致。
建议:无需优化。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改仅涉及UI坐标计算与平台分支逻辑,不涉及内存操作、外部输入解析、命令执行或权限变更,无任何安全攻击面。
建议:无需修复。

■ 【改进建议代码示例】

--- a/src/private/dpopupwindowhandle.cpp
+++ b/src/private/dpopupwindowhandle.cpp
@@ -206,6 +206,9 @@ void DPopupWindowHandle::adjustPopupPosition()
     if (!isEnabled() ||!m_popupWin)
         return;
 
+    // Wayland平台下跳过位置调整,交由合成器处理以避免定位错乱
+    if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform))
+        return;
+
     const QSize size = m_popupWin->size();
     if (size.width() <= 0 || size.height() <= 0)
         return;
@@ -235,7 +238,8 @@ void DPopupWindowHandle::adjustPopupPosition()
     if (!screen)
         return;
 
-    const QRectF bounds(screen->availableGeometry());
+    // 使用完整屏幕几何尺寸进行边界计算,排除任务栏区域导致的基准错误
+    const QRectF bounds(screen->geometry());
     QRectF rect(QPointF(m_popupWin->position()), QSizeF(size));
 
     // Horizontal flip for submenus:

@deepin-bot

deepin-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit d049fdf into linuxdeepin:master Jun 17, 2026
22 of 25 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