Skip to content

fix: isolate smart-hide state per workspace in X11 dock helper - #1754

Open
wjyrich wants to merge 1 commit into
masterfrom
fix/smart-hide-per-workspace
Open

wjyrich wants to merge 1 commit into
masterfrom
fix/smart-hide-per-workspace

Conversation

@wjyrich

@wjyrich wjyrich commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Fix smart-hide state not being isolated per workspace in X11 dock helper. When a window overlaps the dock in one workspace causing it to hide, switching to another workspace without overlapping windows would incorrectly keep the dock hidden.

Modifications (3 changes in panels/dock/x11dockhelper.cpp)

  1. isWindowOverlap() — Filter by current workspace: only count windows whose workspace matches the current workspace or allWorkspace (0xffffffff).

  2. currentWorkspaceChanged handler — Simplified to always emit isWindowOverlapChanged(isWindowOverlap()) on workspace switch, removing the static bool updating reentry guard and the "only emit when overlap exists" logic.

  3. onWindowWorkspaceChanged() — Added Q_EMIT isWindowOverlapChanged(isWindowOverlap()) after updating data->workspace, ensuring overlap state is re-evaluated when windows move between workspaces.

Related

  • Multica issue: DDE-392
  • PMS: BUG-378341

Summary by Sourcery

Bug Fixes:

  • Isolate X11 dock smart-hide overlap state to the active workspace, including when switching workspaces or moving windows between them.

1. Filter window overlap by current workspace in isWindowOverlap()
2. Always re-evaluate overlap on workspace switch without reentry guard
3. Emit isWindowOverlapChanged when window workspace changes

Log: Smart-hide now respects per-workspace window overlap state

Influence:
1. Test smart-hide with window overlap in workspace 1, switch to workspace 2
2. Test smart-hide with windows spanning all workspaces
3. Test window moved between workspaces updates dock hide state

fix: 隔离智能隐藏状态按工作区独立

1. isWindowOverlap() 中按当前工作区过滤窗口重叠
2. 切换工作区后始终重新评估重叠,移除重入守卫
3. 窗口跨工作区移动时补充 emit isWindowOverlapChanged

Log: 智能隐藏现在按工作区独立维护窗口重叠状态

Influence:
1. 测试工作区一窗口重叠隐藏后切换到工作区二的显示状态
2. 测试跨所有工作区的窗口对智能隐藏的影响
3. 测试窗口在工作区间移动后任务栏隐藏状态更新

PMS: BUG-378341
@wjyrich
wjyrich marked this pull request as draft September 24, 2026 03:17
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 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

@sourcery-ai

sourcery-ai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The X11 dock helper now isolates smart-hide overlap state by workspace: overlap checks only consider windows in the active workspace or all workspaces, and state changes are emitted whenever the active workspace or a tracked window’s workspace assignment changes.

Sequence diagram for workspace-aware dock smart-hide updates

sequenceDiagram
    participant Workspace as X11Workspace
    participant Dock as X11DockHelper
    participant Window as TrackedWindow
    participant DockState as SmartHideState

    Workspace->>Dock: currentWorkspaceChanged()
    Dock->>Dock: getCurrentWorkspace()
    Dock->>Dock: isWindowOverlap()
    Dock->>DockState: isWindowOverlapChanged(overlap)

    Window->>Dock: onWindowWorkspaceChanged(window)
    Dock->>Dock: getWindowWorkspace(window)
    Dock->>Dock: isWindowOverlap()
    Dock->>DockState: isWindowOverlapChanged(overlap)
Loading

Flow diagram for workspace-filtered overlap detection

flowchart TD
    A["isWindowOverlap()"] --> B["getCurrentWorkspace()"]
    B --> C{Tracked window overlaps dock?}
    C -- No --> E[Return false]
    C -- Yes --> D{Window workspace is current or all workspaces?}
    D -- Yes --> F[Return true]
    D -- No --> C
Loading

File-Level Changes

Change Details Files
Scope overlap detection to the active workspace, including windows marked as present on all workspaces.
  • Read the current workspace before evaluating overlaps.
  • Ignore overlapping windows assigned to other workspaces.
  • Preserve all-workspace windows as eligible to hide the dock.
panels/dock/x11dockhelper.cpp
Recompute and publish dock overlap state whenever workspace context changes.
  • Emit the overlap state unconditionally on current-workspace changes.
  • Re-evaluate after a tracked window changes workspace.
  • Remove the reentry guard and conditional emission logic.
panels/dock/x11dockhelper.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

@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 reviewed your changes and they look great!


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

@wjyrich
wjyrich marked this pull request as ready for review September 24, 2026 06:33
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 99 分,大于 70 分通过阈值,代码质量符合要求。本次提交修复了智能隐藏按工作区隔离的Bug,代码逻辑正确,结构清晰,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 代码逻辑正确,isWindowOverlap()正确过滤当前工作区窗口,currentWorkspaceChanged处理器简化合理,onWindowWorkspaceChanged补充信号发射逻辑完整。移除重入守卫安全,因为isWindowOverlap()为只读操作不会触发重入。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 注释拼写错误已修复(widnow->window),注释内容已更新以反映新行为。代码从14行简化为1行,显著降低复杂度。工作区过滤逻辑统一收敛到isWindowOverlap()中,符合DRY原则。原lambda中无意义的return overlap |= window->overlap被替换为清晰的if语句。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. panels/dock/x11dockhelper.cpp:529 - isWindowOverlap()使用std::for_each遍历所有窗口,无法提前退出。建议使用std::any_of实现短路求值,在找到首个重叠窗口时立即返回。

建议: 建议将std::for_each替换为std::any_of,在找到首个重叠窗口时立即返回true,避免不必要的遍历。对于窗口数量较多的场景可提升性能。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 无安全风险,代码为桌面环境UI逻辑,不涉及用户输入、网络操作或文件IO。


💡 改进建议代码示例

// 建议使用 std::any_of 替代 std::for_each,实现短路求值
bool X11DockHelper::isWindowOverlap()
{
    if (m_showingDesktop) {
        return false;
    }

    // any window overlap in current workspace
    uint32_t currentWorkspace = m_xcbHelper->getCurrentWorkspace();
    return std::any_of(m_windows.begin(), m_windows.end(),
        [currentWorkspace](const auto &window) {
            return window->overlap
                && (window->workspace == currentWorkspace
                    || window->workspace == allWorkspace);
        });
}

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

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.

2 participants