Skip to content

fix: restore LIBDJK_SUPPORT guard for window input type - #839

Draft
pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:fix/pms-341993-restore-libdjk-guard
Draft

pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:fix/pms-341993-restore-libdjk-guard

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

Commit 0617b0f7 ("feat: Remove displayjack kvm depend") removed the #ifdef LIBDJK_SUPPORT conditional compilation guard in XWindowsScreen::openWindow(), making inputType unconditionally WaylandUtils::isWayland() ? InputOutput : InputOnly. On Wayland sessions, this creates an InputOutput window that gets unmapped via XUnmapWindow in enter(); XWindowsClipboard then calls XSetSelectionOwner on this unmapped InputOutput window, but XWayland does not bridge that selection to the native Wayland clipboard — so the receiver's clipboard never displays the copied text.

Fix

Restore the #ifdef LIBDJK_SUPPORT guard so that when LIBDJK_SUPPORT is undefined (which it always is — no find_package(LibDJK) call exists in the project), inputType falls back to InputOnly. This matches the pre-regression behavior from commit 45446393 and the develop/v25 branch (commit 5b45e349).

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The change only adds a conditional compilation guard around a local variable (inputType) in openWindow() — no function signature changes, no public member changes, zero external callers (reference list empty)
  • The target line is a regression introduced by commit 0617b0f7, not a historical fix product; this change does not revert any existing fix

Business Impact Scope

Affected module: Cross-device cooperation — clipboard sync. After establishing cooperation, the sender copies text and the receiver's clipboard should display it. On Wayland sessions, the window type changes from InputOutput (broken) back to InputOnly (correct). X11 sessions are unaffected — InputOnly and InputOutput behave identically for clipboard selection ownership on plain X11.

Verification Suggestion

Test clipboard sync after establishing cooperation on Wayland. Verify X11 clipboard sync as regression (behavior unchanged). Verify mouse sharing and file transfer still work.


根因分析

commit 0617b0f7("feat: Remove displayjack kvm depend")移除了 XWindowsScreen::openWindow() 中的 #ifdef LIBDJK_SUPPORT 条件编译守卫,使 inputType 无条件使用 WaylandUtils::isWayland() ? InputOutput : InputOnly。Wayland 会话下创建 InputOutput 窗口,在 enter() 中被 XUnmapWindow 取消映射;XWindowsClipboard 在该未映射 InputOutput 窗口上调用 XSetSelectionOwner,但 XWayland 不将该选区桥接到原生 Wayland 剪贴板,导致接收端剪贴板不显示复制的文本。

修复方案

恢复 #ifdef LIBDJK_SUPPORT 守卫,使 LIBDJK_SUPPORT 未定义时(项目中无 find_package(LibDJK) 调用,永远未定义)inputType 回退为 InputOnly,与 commit 45446393 的回归前行为及 develop/v25 分支(commit 5b45e349)一致。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 改动仅在 openWindow() 内为局部变量 inputType 恢复条件编译守卫,不修改函数签名、不增删公开成员、无外部调用者(引用列表为空)
  • 目标行为是 commit 0617b0f7 引入的回归,非历史修复产物,本次改动不撤销任何已有修复

业务影响范围

受影响模块:跨端协同 — 剪贴板同步。建立协同后,发送端复制文本,接收端剪贴板应正确显示。Wayland 会话下窗口类型从 InputOutput(回归)恢复为 InputOnly(正确)。X11 会话不受影响——InputOnly 与 InputOutput 在 X11 选区所有权行为一致。

验证建议

测试 Wayland 会话下建立协同后的剪贴板同步。验证 X11 会话剪贴板同步(回归验证,行为不变)。验证鼠标共享和文件传输功能正常。

Summary by Sourcery

Bug Fixes:

  • Restore the conditional window input type selection to fix clipboard synchronization on Wayland while preserving existing X11 behavior.

1. Root cause: commit 0617b0f removed the #ifdef LIBDJK_SUPPORT
   guard, making inputType unconditionally use WaylandUtils::isWayland()
   ? InputOutput : InputOnly; on Wayland sessions this creates an
   InputOutput window which gets unmapped in enter() via XUnmapWindow,
   and XWindowsClipboard's XSetSelectionOwner on the unmapped
   InputOutput window is not bridged by XWayland to the native Wayland
   clipboard, causing the receiver's clipboard to not display
2. Fix: restore the #ifdef LIBDJK_SUPPORT conditional compilation
   guard so that when LIBDJK_SUPPORT is undefined (which it always is,
   as no find_package(LibDJK) call exists), inputType falls back to
   InputOnly, matching the pre-regression behavior from commit 4544639
   and the develop/v25 branch (commit 5b45e34)
3. Impact: only affects Wayland sessions where the window type changes
   from InputOutput back to InputOnly; X11 sessions are unaffected as
   InputOnly and InputOutput behave identically for clipboard selection
   ownership on plain X11

Influence:
1. Test clipboard sync after establishing cooperation on Wayland
2. Verify clipboard sync on X11 session (regression, no behavior change)
3. Verify mouse sharing and file transfer still work after cooperation

fix: 恢复窗口输入类型的 LIBDJK_SUPPORT 条件编译守卫

1. 根因:commit 0617b0f 移除了 #ifdef LIBDJK_SUPPORT 守卫,使
   inputType 无条件使用 WaylandUtils::isWayland() ? InputOutput :
   InputOnly;Wayland 会话下创建 InputOutput 窗口,在 enter() 中被
   XUnmapWindow 取消映射,XWindowsClipboard 在该未映射 InputOutput 窗口
   上 XSetSelectionOwner 的选区不被 XWayland 桥接到原生 Wayland 剪贴板,
   导致接收端剪贴板不显示
2. 方案:恢复 #ifdef LIBDJK_SUPPORT 条件编译守卫,LIBDJK_SUPPORT 未定义时
   (项目中无 find_package(LibDJK) 调用,永远未定义)inputType 回退为
   InputOnly,与 commit 4544639 的回归前行为及 develop/v25 分支
   (commit 5b45e34)一致
3. 影响:仅影响 Wayland 会话,窗口类型从 InputOutput 恢复为 InputOnly;
   X11 会话不受影响(InputOnly 与 InputOutput 在 X11 选区所有权行为一致)

Influence:
1. 测试 Wayland 会话下建立协同后的剪贴板同步
2. 验证 X11 会话下剪贴板同步(回归验证,行为不变)
3. 验证建立协同后鼠标共享和文件传输功能正常

PMS: BUG-341993
@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

@pppanghu77
pppanghu77 marked this pull request as draft October 29, 2026 19:28
@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

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

Reviewer's Guide

This low-risk fix restores the LIBDJK_SUPPORT compilation guard in XWindowsScreen::openWindow(), causing builds without LibDJK support to create InputOnly windows and restoring clipboard synchronization on Wayland while preserving existing X11 behavior.

Sequence diagram for Wayland clipboard synchronization

sequenceDiagram
    participant Sender
    participant XWindowsScreen
    participant XWindowsClipboard
    participant XWayland
    participant Receiver
    Sender->>XWindowsScreen: openWindow()
    XWindowsScreen->>XWindowsScreen: XCreateWindow(inputType = InputOnly)
    Sender->>XWindowsClipboard: copy text
    XWindowsClipboard->>XWayland: XSetSelectionOwner(InputOnly window)
    XWayland-->>Receiver: clipboard selection
Loading

Flow diagram for guarded window input type selection

flowchart TD
    A["openWindow()"] --> B{LIBDJK_SUPPORT defined?}
    B -->|Yes| C["WaylandUtils.isWayland()"]
    C -->|Wayland| D[InputOutput]
    C -->|X11| E[InputOnly]
    B -->|No| E
    D --> F[XCreateWindow]
    E --> F
    F --> G[Clipboard synchronization]
Loading

File-Level Changes

Change Details Files
Restores conditional window input-type selection to prevent broken clipboard ownership on Wayland.
  • Uses Wayland-specific InputOutput behavior only when LIBDJK_SUPPORT is enabled.
  • Falls back to InputOnly when LIBDJK_SUPPORT is undefined, matching pre-regression behavior.
  • Leaves X11 behavior and the surrounding window creation logic unchanged.
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 ✨

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