Skip to content

fix: restore LIBDJK_SUPPORT guard for clipboard - #833

Open
pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:agent/agent/f80a443d514f
Open

pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:agent/agent/f80a443d514f

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

Commit 0617b0f7 ("feat: Remove displayjack kvm depend") removed the #ifdef LIBDJK_SUPPORT guard in XWindowsScreen::openWindow(), causing WaylandUtils::isWayland() ? InputOutput : InputOnly to execute unconditionally. In Wayland sessions, the InputOutput window gets unmapped by enter() (XWindowsScreen.cpp:237), and XSetSelectionOwner on the unmapped window (XWindowsClipboard.cpp:285) is not bridged by XWayland to the native Wayland clipboard, resulting in clipboard sharing failure between connected devices.

Fix

Restore the #ifdef LIBDJK_SUPPORT guard in XWindowsScreen.cpp:1040. When LIBDJK_SUPPORT is undefined (the current state after 0617b0f7 removed FindLibDJK.cmake), inputType falls back to InputOnly, preventing the window from being unmapped by enter() and allowing XSetSelectionOwner to work correctly. This matches the fix already applied in develop/v25 (commit 5b45e349, PMS BUG-341993).

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Target line is not a previous bug fix product; this change restores a guard that was removed by a feature change (0617b0f7), not a fix. No function signatures changed, no public members modified, 0 affected callers (local variable only).
  • Matches existing fix in develop/v25 branch (commit 5b45e349).

Business Impact Scope

Affects cross-device clipboard sharing in Wayland sessions only. X11 sessions are unaffected (WaylandUtils::isWayland() returns false, behavior unchanged). The change is limited to the inputType local variable in openWindow().

Verification Suggestion

Test cross-device clipboard sharing in a Wayland session: connect two devices, copy text/screenshot on one, verify clipboard content appears on the other. Verify X11 session has no regression.


根因分析

commit 0617b0f7("feat: Remove displayjack kvm depend")移除了 XWindowsScreen::openWindow() 中的 #ifdef LIBDJK_SUPPORT 守卫,导致 WaylandUtils::isWayland() ? InputOutput : InputOnly 无条件执行。Wayland 会话下 InputOutput 窗口被 enter() 取消映射(XWindowsScreen.cpp:237),XSetSelectionOwner 在 unmapped 窗口上设置的选区(XWindowsClipboard.cpp:285)不被 XWayland 桥接到原生 Wayland 剪贴板,导致跨端剪贴板共享不生效。

修复方案

恢复 XWindowsScreen.cpp:1040 的 #ifdef LIBDJK_SUPPORT 守卫。未定义 LIBDJK_SUPPORT 时 inputType 回退为 InputOnly,窗口不被 enter() unmap,XSetSelectionOwner 正常工作。与 develop/v25 分支已有修复(commit 5b45e349,PMS BUG-341993)一致。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 目标行非历史修复产物,本次改动不撤销任何已有修复。commit 0617b0f7 是功能变更,非 bug 修复;本次恢复其移除的守卫,修复该功能变更引入的回归。无函数签名变化,无公开成员修改,0 处受影响调用者(仅局部变量)。
  • 与 develop/v25 分支已有修复一致(commit 5b45e349)。

业务影响范围

仅影响 Wayland 会话下跨端剪贴板共享功能。X11 会话不受影响(WaylandUtils::isWayland() 返回 false,行为不变)。改动范围限于 openWindow() 中的 inputType 局部变量。

验证建议

在 Wayland 会话下测试跨端剪贴板共享:连接两台设备,在一台复制文字/截图,验证另一台剪贴板能获取内容。验证 X11 会话无回归。

PMS: BUG-278649

Summary by Sourcery

Bug Fixes:

  • Restore clipboard sharing in Wayland sessions by preventing the screen window from being incorrectly created as an unmapped input/output window when displayjack support is unavailable.

1. Root cause: commit 0617b0f removed the #ifdef LIBDJK_SUPPORT
   guard in openWindow(), making WaylandUtils::isWayland() ?
   InputOutput : InputOnly execute unconditionally; in Wayland
   sessions the InputOutput window gets unmapped by enter(), and
   XSetSelectionOwner on the unmapped window is not bridged by
   XWayland to the native Wayland clipboard
2. Fix: restore the #ifdef LIBDJK_SUPPORT guard so that when
   LIBDJK_SUPPORT is undefined inputType falls back to InputOnly,
   preventing the window from being unmapped and allowing
   XSetSelectionOwner to work correctly
3. Impact: only affects Wayland session window creation type; X11
   sessions are unaffected (WaylandUtils::isWayland() returns false)

Log: fix clipboard sharing not working in Wayland sessions

Influence:
1. Test cross-device clipboard sharing in Wayland session
2. Verify X11 session cross-device cooperation has no regression

fix: 恢复 LIBDJK_SUPPORT 守卫修复剪贴板共享

1. 根因:commit 0617b0f 移除了 openWindow() 中的 #ifdef
   LIBDJK_SUPPORT 守卫,导致 WaylandUtils::isWayland() ?
   InputOutput : InputOnly 无条件执行;Wayland 会话下
   InputOutput 窗口被 enter() 取消映射,XSetSelectionOwner
   在 unmapped 窗口上设置的选区不被 XWayland 桥接到原生
   Wayland 剪贴板
2. 方案:恢复 #ifdef LIBDJK_SUPPORT 守卫,未定义时 inputType
   回退为 InputOnly,窗口不被 enter() unmap,
   XSetSelectionOwner 正常工作
3. 影响:仅影响 Wayland 会话下窗口创建类型;X11 会话不受影响

Log: 修复 Wayland 会话下剪贴板共享不生效的问题

Influence:
1. 测试 Wayland 会话下跨端剪贴板共享功能
2. 验证 X11 会话下跨端协同功能无回归

PMS: BUG-278649
@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

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

Reviewer's Guide

The PR restores the LIBDJK_SUPPORT compile-time guard in XWindowsScreen::openWindow(), limiting the Wayland-specific InputOutput window behavior to builds that support it and restoring InputOnly behavior for current builds. This prevents the window from being unmapped before XSetSelectionOwner can bridge clipboard contents under Wayland, while preserving existing X11 behavior.

Sequence diagram for Wayland clipboard ownership after window creation

sequenceDiagram
    participant Screen as XWindowsScreen
    participant Wayland as WaylandUtils
    participant X11 as XServer
    participant Clipboard as XWindowsClipboard

    Screen->>Screen: openWindow()
    alt LIBDJK_SUPPORT defined
        Screen->>Wayland: isWayland()
        Wayland-->>Screen: true or false
        Screen->>X11: XCreateWindow(inputType)
    else LIBDJK_SUPPORT undefined
        Screen->>X11: XCreateWindow(InputOnly)
    end
    Clipboard->>X11: XSetSelectionOwner()
    X11-->>Clipboard: clipboard ownership available
Loading

File-Level Changes

Change Details Files
Restores conditional window input-type selection to prevent Wayland clipboard regressions when displayjack support is unavailable.
  • Uses Wayland-aware InputOutput behavior only when LIBDJK_SUPPORT is defined.
  • Falls back to InputOnly otherwise, keeping the window mapped for XWayland clipboard ownership.
3rdparty/barrier/src/lib/platform/XWindowsScreen.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 ✨

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pppanghu77

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 XWindowsScreen::openWindow() 中缺失的 LIBDJK_SUPPORT 预处理宏守卫,通过条件编译在未启用 LIBDJK_SUPPORT 时回退到 InputOnly 默认行为,避免编译问题。变更范围小、逻辑清晰,四维度均无问题,OCR 与启发式扫描均未发现隐患。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

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

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

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

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

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

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例


本报告由 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