Skip to content

fix: adjust search box position for wayland dock overlap#754

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-345751
Apr 27, 2026
Merged

fix: adjust search box position for wayland dock overlap#754
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-345751

Conversation

@wjyrich
Copy link
Copy Markdown
Contributor

@wjyrich wjyrich commented Apr 27, 2026

Replace DS import with direct dock applet access via DS.applet to
calculate dock spacing, improving accuracy by using dock's root object
dimensions instead of scaled geometry values.

Log: Improved dock spacing calculation in FullscreenFrame

Influence:

  1. Test fullscreen frame display with different dock positions (top,
    bottom, left, right)
  2. Verify dock spacing is correctly applied when dock is hidden or shown
  3. Test with different display scale factors
  4. Verify no regressions in dock area padding

refactor: 优化全屏框架中的 dock 间距计算

将 DS 导入替换为通过 DS.applet 直接访问 dock 应用,使用 dock 的根对象尺
寸而非缩放后的几何值来计算 dock 间距,提高计算准确性。

Log: 优化全屏框架中的 dock 间距计算

Influence:

  1. 测试不同 dock 位置(上、下、左、右)下的全屏框架显示
  2. 验证 dock 隐藏或显示时间距计算是否正确
  3. 测试不同显示缩放比例下的表现
  4. 验证 dock 区域边距无回归问题

wayland下使用 Screen.devicePixelRatio 在1.25倍下,返回为2,因为在 Wayland 下往往会返回一个取整后的整数(如 2)
因此采用直接获取任务栏宽高方式,在wayland环境实现基于任务栏的大小从而保证启动器搜索框,以及指示器,关闭按钮的正确位移。

PMS: BUG-345751 BUG-345737

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the fullscreen search box layout to avoid overlap with the dock on Wayland by importing the correct DS namespace and adding a dynamic bottom margin based on dock height, applied only on Wayland.

Sequence diagram for fullscreen search box margin calculation on Wayland

sequenceDiagram
    participant FullscreenFrame
    participant SearchEdit
    participant DS
    participant DockApplet
    participant DockRoot

    FullscreenFrame->>SearchEdit: evaluate Layout.bottomMargin
    SearchEdit->>DS: applet(org.deepin.ds.dock)
    DS-->>SearchEdit: DockApplet
    alt dock applet available
        SearchEdit->>DockApplet: rootObject
        DockApplet-->>SearchEdit: DockRoot
        SearchEdit->>DockRoot: read height
        DockRoot-->>SearchEdit: dockHeight
        SearchEdit->>SearchEdit: isWayland = Qt.platform.pluginName === wayland
        alt isWayland
            SearchEdit->>SearchEdit: bottomMargin = dockHeight + 10
        else not Wayland
            SearchEdit->>SearchEdit: bottomMargin = 0
        end
    else dock applet not available
        SearchEdit->>SearchEdit: dockHeight = 0
        SearchEdit->>SearchEdit: bottomMargin = 0
    end
Loading

Flow diagram for computing search box bottom margin

flowchart TD
    A[Evaluate Layout.bottomMargin] --> B[Call DS.applet org.deepin.ds.dock]
    B --> C{Dock applet exists?}
    C -- No --> D[Set dockHeight = 0]
    D --> E[Set bottomMargin = 0]
    C -- Yes --> F[Access dock.rootObject]
    F --> G{rootObject exists?}
    G -- No --> D
    G -- Yes --> H[Read dockHeight = rootObject.height]
    H --> I{Qt.platform.pluginName == wayland}
    I -- Yes --> J[bottomMargin = dockHeight + 10]
    I -- No --> E
    J --> K[Apply Layout.bottomMargin]
    E --> K
Loading

File-Level Changes

Change Details Files
Use DS applet API from the correct import to query dock information.
  • Replace org.deepin.dtk.style import with org.deepin.ds to access DS.applet API
  • Ensure existing DS usages (if any) resolve via the new import without breaking styles or other dependencies
qml/FullscreenFrame.qml
Add a Wayland-only dynamic bottom margin to the fullscreen search box based on dock height.
  • Bind searchEdit Layout.bottomMargin to a function that queries DS.applet("org.deepin.ds.dock")
  • Compute dockHeight from dock.rootObject.height, defaulting to 0 when dock or rootObject is missing
  • Apply margin only when Qt.platform.pluginName is "wayland", adding a small padding offset (+10) to the dock height; otherwise keep margin 0
qml/FullscreenFrame.qml

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

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, and left some high level feedback:

  • You replaced import org.deepin.dtk.style 1.0 as DS with import org.deepin.ds 1.0 but still reference DS.applet, so either restore the alias (as DS) or update the code to use the correct namespace to avoid runtime errors.
  • The Layout.bottomMargin binding calls DS.applet("org.deepin.ds.dock") each time it re-evaluates; consider caching the dock reference or exposing the dock height via a property to avoid repeated lookups and make future changes easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You replaced `import org.deepin.dtk.style 1.0 as DS` with `import org.deepin.ds 1.0` but still reference `DS.applet`, so either restore the alias (`as DS`) or update the code to use the correct namespace to avoid runtime errors.
- The `Layout.bottomMargin` binding calls `DS.applet("org.deepin.ds.dock")` each time it re-evaluates; consider caching the dock reference or exposing the dock height via a property to avoid repeated lookups and make future changes easier.

## Individual Comments

### Comment 1
<location path="qml/FullscreenFrame.qml" line_range="763-766" />
<code_context>
                 id: searchEdit

                 Layout.alignment: Qt.AlignHCenter
+                Layout.bottomMargin: {
+                    var dock = DS.applet("org.deepin.ds.dock")
+                    var dockHeight = (dock && dock.rootObject) ? dock.rootObject.height : 0
+                    return Qt.platform.pluginName === "wayland" ? dockHeight + 10 : 0
+                }
                 implicitWidth: (parent.width / 2) > 280 ? 280 : (parent.width / 2)
</code_context>
<issue_to_address>
**issue (bug_risk):** The `DS` identifier is used here but no alias `DS` is defined after the import change.

Previously `org.deepin.dtk.style 1.0 as DS` introduced the `DS` alias, but `import org.deepin.ds 1.0` does not. As written, `DS.applet("org.deepin.ds.dock")` will throw at runtime unless `DS` is defined elsewhere. Please either reintroduce an alias on the new import or call the appropriate exported object from `org.deepin.ds` directly instead of `DS`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread qml/FullscreenFrame.qml Outdated
Comment on lines +763 to +766
Layout.bottomMargin: {
var dock = DS.applet("org.deepin.ds.dock")
var dockHeight = (dock && dock.rootObject) ? dock.rootObject.height : 0
return Qt.platform.pluginName === "wayland" ? dockHeight + 10 : 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The DS identifier is used here but no alias DS is defined after the import change.

Previously org.deepin.dtk.style 1.0 as DS introduced the DS alias, but import org.deepin.ds 1.0 does not. As written, DS.applet("org.deepin.ds.dock") will throw at runtime unless DS is defined elsewhere. Please either reintroduce an alias on the new import or call the appropriate exported object from org.deepin.ds directly instead of DS.

Copy link
Copy Markdown
Member

@BLumia BLumia left a comment

Choose a reason for hiding this comment

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

四个方向

Replace DS import with direct dock applet access via DS.applet to
calculate dock spacing, improving accuracy by using dock's root object
dimensions instead of scaled geometry values.

Log: Improved dock spacing calculation in FullscreenFrame

Influence:
1. Test fullscreen frame display with different dock positions (top,
bottom, left, right)
2. Verify dock spacing is correctly applied when dock is hidden or shown
3. Test with different display scale factors
4. Verify no regressions in dock area padding

refactor: 优化全屏框架中的 dock 间距计算

将 DS 导入替换为通过 DS.applet 直接访问 dock 应用,使用 dock 的根对象尺
寸而非缩放后的几何值来计算 dock 间距,提高计算准确性。

Log: 优化全屏框架中的 dock 间距计算

Influence:
1. 测试不同 dock 位置(上、下、左、右)下的全屏框架显示
2. 验证 dock 隐藏或显示时间距计算是否正确
3. 测试不同显示缩放比例下的表现
4. 验证 dock 区域边距无回归问题

wayland下使用 Screen.devicePixelRatio 在1.25倍下,返回为2,因为在 Wayland 下往往会返回一个取整后的整数(如 2)
因此采用直接获取任务栏宽高方式,在wayland环境实现基于任务栏的大小从而保证启动器搜索框,以及指示器,关闭按钮的正确位移。

PMS: BUG-345751 BUG-345737
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

这段代码的 diff 主要涉及 QML 文件 FullscreenFrame.qml 中的导入变更和 dockSpacing 属性的计算逻辑修改。以下是对该代码的审查意见,包括语法逻辑、代码质量、代码性能和代码安全方面的改进建议:

1. 语法逻辑审查

  • 导入变更

    • 移除了 import org.deepin.dtk.style 1.0 as DS,新增了 import org.deepin.ds 1.0
    • 问题:代码中使用了 DS.applet("org.deepin.ds.dock"),但 DS 现在指向的是 org.deepin.ds 1.0,而之前的 DSorg.deepin.dtk.style 1.0 的别名。需要确认 org.deepin.ds 1.0 是否提供了 applet 方法。如果未提供,代码会报错。
    • 建议:确保 org.deepin.ds 1.0 模块确实包含 applet 方法,或者调整导入和命名空间。
  • dockSpacing 计算逻辑

    • 原代码通过 DesktopIntegration.dockGeometryScreen.devicePixelRatio 计算 dockSpacing
    • 新代码通过 DS.applet("org.deepin.ds.dock").rootObject 获取 dock 的尺寸。
    • 问题
      • 如果 DS.applet("org.deepin.ds.dock") 返回 nullrootObjectnull,代码会抛出异常。
      • 新代码未考虑 Screen.devicePixelRatio,可能导致在高 DPI 屏幕上计算错误。
    • 建议
      • 添加对 dockdock.rootObject 的非空检查。
      • 如果需要支持高 DPI,应重新引入 Screen.devicePixelRatio 的计算。

2. 代码质量审查

  • 可读性

    • 新代码的 dockSpacing 计算逻辑更直观,直接从 dock 的 rootObject 获取尺寸,但缺少注释说明为何这样修改。
    • 建议:添加注释说明 DS.applet("org.deepin.ds.dock") 的作用和返回值的含义。
  • 错误处理

    • 新代码未处理 DS.applet 可能返回 null 的情况。
    • 建议:添加默认值或错误处理逻辑,例如:
      readonly property int dockSpacing: {
          var dock = DS.applet("org.deepin.ds.dock")
          if (!dock || !dock.rootObject) {
              return 0
          }
          return isHorizontalDock ? dock.rootObject.height : dock.rootObject.width
      }

3. 代码性能审查

  • 性能影响
    • 新代码每次访问 dockSpacing 时都会调用 DS.applet("org.deepin.ds.dock"),可能会带来不必要的性能开销。
    • 建议:将 dock 对象缓存为属性,避免重复调用:
      readonly property var dock: DS.applet("org.deepin.ds.dock")
      readonly property int dockSpacing: {
          if (!dock || !dock.rootObject) {
              return 0
          }
          return isHorizontalDock ? dock.rootObject.height : dock.rootObject.width
      }

4. 代码安全审查

  • 空指针风险

    • 如果 DS.applet("org.deepin.ds.dock") 返回 nullrootObjectnull,会导致运行时错误。
    • 建议:如前所述,添加非空检查。
  • 模块依赖

    • 新代码依赖 org.deepin.ds 1.0 模块的 applet 方法,需确保该模块的稳定性和兼容性。
    • 建议:在文档中明确依赖关系,并在模块变更时及时更新代码。

改进后的代码示例

import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import org.deepin.dtk 1.0
import org.deepin.ds 1.0 as DS

import org.deepin.launchpad 1.0
import org.deepin.launchpad.models 1.0

InputEventItem {
    // ... 其他代码 ...

    readonly property bool isHorizontalDock: DesktopIntegration.dockPosition === Qt.UpArrow || DesktopIntegration.dockPosition === Qt.DownArrow
    readonly property var dock: DS.applet("org.deepin.ds.dock")
    readonly property int dockSpacing: {
        if (!dock || !dock.rootObject) {
            return 0
        }
        return isHorizontalDock ? dock.rootObject.height : dock.rootObject.width
    }

    leftPadding: (DesktopIntegration.dockPosition === Qt.LeftArrow ? dockSpacing : 0)
    rightPadding: (DesktopIntegration.dockPosition === Qt.RightArrow ? dockSpacing : 0)
    topPadding: (DesktopIntegration.dockPosition === Qt.UpArrow ? dockSpacing : 0) + 20
    // ... 其他代码 ...
}

总结

  • 主要问题:新代码缺少对 DS.applet 返回值的非空检查,且未考虑高 DPI 屏幕的适配。
  • 改进方向:添加错误处理、缓存 dock 对象、补充注释、确保模块兼容性。
  • 安全性:通过非空检查和默认值避免运行时错误。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, wjyrich

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

@wjyrich
Copy link
Copy Markdown
Contributor Author

wjyrich commented Apr 27, 2026

/forcemerge

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Apr 27, 2026

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit ca88a70 into linuxdeepin:master Apr 27, 2026
10 of 11 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