Skip to content

fix: restore LIBDJK_SUPPORT guard for clipboard - #782

Closed
Johnson-zs wants to merge 1 commit into
release/v20from
agent/pms-bug-bot/d218fec7
Closed

Johnson-zs wants to merge 1 commit into
release/v20from
agent/pms-bug-bot/d218fec7

Conversation

@Johnson-zs

@Johnson-zs Johnson-zs commented Aug 23, 2026 •

Copy link
Copy Markdown

Root Cause Analysis

In XWindowsScreen::openWindow() (XWindowsScreen.cpp:1040), commit 6c1ee78b removed the #ifdef LIBDJK_SUPPORT conditional guard, causing m_window to be created as InputOutput on Wayland sessions. This window serves double duty: input grabbing and clipboard selection ownership (XWindowsClipboard reuses it at :161, XSetSelectionOwner at XWindowsClipboard.cpp:285). During screen switch, enter() calls XUnmapWindow (:279), then setClipboard runs XSetSelectionOwner on the now-unmapped InputOutput window. XWayland does not bridge selections on unmapped InputOutput windows to the native Wayland clipboard, so the receiver's clipboard stays empty.

Fix

Restored the #ifdef LIBDJK_SUPPORT guard in openWindow(). When LIBDJK_SUPPORT is undefined (confirmed not defined in the baseline CMake), inputType falls back to InputOnly, matching pre-regression behavior and the develop/v25 branch fix.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Restoring a conditional compilation guard; no signature changes, no public API changes, no new callers
  • Only 2 internal references to openWindow() (both within XWindowsScreen class), both unaffected by the change
  • The regression was introduced by commit 0617b0f7 which removed the guard; this fix restores only the guard, not the full commit, preserving the displayjack dependency removal

Business Impact Scope

Affects clipboard sharing during screen switch in Wayland sessions only. Non-Wayland (X11) sessions are unchanged (already InputOnly). The fix restores InputOnly window type so clipboard selection ownership remains valid after XUnmapWindow, allowing XWayland to bridge the selection to the native Wayland clipboard.

Verification Suggestion

  1. Wayland session: establish cooperation, copy text on sender, switch cursor to receiver, verify receiver clipboard displays content
  2. X11 session: clipboard sharing regression test (ensure non-Wayland unaffected)
  3. Repeated screen switches: verify clipboard selection ownership persists

根因分析

XWindowsScreen::openWindow()(XWindowsScreen.cpp:1040)中,commit 6c1ee78b 移除了 #ifdef LIBDJK_SUPPORT 条件编译守卫,导致 Wayland 会话下 m_window 被创建为 InputOutput 类型。该窗口同时承担输入抓取和剪贴板选区所有权双重职责(XWindowsClipboard 在 :161 复用该窗口,XWindowsClipboard.cpp:285 执行 XSetSelectionOwner)。屏幕切换时 enter() 先 XUnmapWindow(:279),紧接着 setClipboard 在已 unmapped 的 InputOutput 窗口上执行 XSetSelectionOwner,XWayland 不桥接该选区到原生 Wayland 剪贴板,导致接收端剪贴板为空。

修复方案

恢复 openWindow() 中的 #ifdef LIBDJK_SUPPORT 守卫。当前基线未定义 LIBDJK_SUPPORT,inputType 回退为 InputOnly,与回归前行为及 develop/v25 分支修复一致。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 仅恢复条件编译守卫,不修改函数签名、公开 API,无新增调用者
  • openWindow() 仅有 2 处内部引用(均在 XWindowsScreen 类内),均不受影响
  • 回归由 commit 0617b0f7 移除守卫引入,本次仅恢复守卫部分,不影响移除 displayjack 依赖的初衷

业务影响范围

仅影响 Wayland 会话下屏幕切换时的协同剪贴板共享。非 Wayland(X11)会话行为不变(原本即为 InputOnly)。恢复 InputOnly 窗口类型后,XUnmapWindow 后剪贴板选区所有权仍有效,XWayland 可正常桥接到原生 Wayland 剪贴板。

验证建议

  1. Wayland 会话:建立协同后发起端复制文字,光标切到接收端,验证接收端剪贴板正确显示
  2. X11 会话:剪贴板共享功能回归测试(确保非 Wayland 环境不受影响)
  3. 多次反复切换屏幕,验证剪贴板选区所有权持续有效

PMS: BUG-341993

Summary by Sourcery

Bug Fixes:

  • Restore clipboard sharing during screen switches in Wayland sessions by ensuring the X window uses the compatible input-only type when the optional display support is unavailable.

1. Root cause: commit 6c1ee78 removed the #ifdef LIBDJK_SUPPORT
   guard in XWindowsScreen::openWindow(), making m_window an
   InputOutput window on Wayland; after enter() unmaps it,
   XSetSelectionOwner on an unmapped InputOutput 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,
   matching the pre-regression behavior and the develop/v25 fix
3. Impact: Wayland sessions revert to InputOnly window for
   clipboard selection ownership; non-Wayland behavior unchanged

Log: fix clipboard content not showing on receiver after screen switch

Influence:
1. Test clipboard sharing in Wayland session after screen switch
2. Verify clipboard sharing regression in X11 session
3. Test repeated screen switches for clipboard reliability

fix: 恢复 LIBDJK_SUPPORT 守卫修复协同剪贴板

1. 根因:commit 6c1ee78 移除了 XWindowsScreen::openWindow() 中的
   #ifdef LIBDJK_SUPPORT 守卫,导致 Wayland 下 m_window 创建为
   InputOutput 类型;enter() unmap 该窗口后,XSetSelectionOwner
   在 unmapped 的 InputOutput 窗口上设置的选区无法被 XWayland
   桥接到原生 Wayland 剪贴板
2. 方案:恢复 #ifdef LIBDJK_SUPPORT 守卫,未定义时 inputType 回退
   为 InputOnly,与回归前行为及 develop/v25 修复一致
3. 影响:Wayland 会话恢复使用 InputOnly 窗口持有剪贴板选区所有权,
   非 Wayland 环境行为不变

Log: 修复协同后接收端剪贴板内容不显示的问题

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: Johnson-zs

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 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 @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Aug 23, 2026

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

Reviewer's Guide

Restores the LIBDJK_SUPPORT conditional guard around the X11 window input type selection so that, in non-LIBDJK builds (including current baseline), the Barrier X11 window used for clipboard and input on Wayland is created as InputOnly instead of InputOutput, matching pre-regression behavior and fixing clipboard sharing on Wayland/XWayland during screen switches.

Sequence diagram for Wayland clipboard sharing during screen switch

sequenceDiagram
    participant Screen as XWindowsScreen
    participant XServer as X11/XWayland
    participant Clipboard as XWindowsClipboard
    participant Wayland as NativeWaylandClipboard

    Screen->>XServer: XCreateWindow(inputType=InputOnly)
    Screen->>XServer: XUnmapWindow(m_window)
    Clipboard->>XServer: XSetSelectionOwner(m_window)
    XServer->>Wayland: Bridge clipboard selection
    Wayland-->>Clipboard: Clipboard content available
Loading

File-Level Changes

Change Details Files
Restore conditional compilation guard around X11 window input type to fix Wayland clipboard behavior.
  • Reintroduce #ifdef LIBDJK_SUPPORT around inputType selection in XWindowsScreen::openWindow()
  • Ensure non-LIBDJK builds always use InputOnly window type regardless of Wayland presence
  • Preserve existing behavior for LIBDJK-supporting builds, using InputOutput on Wayland and InputOnly otherwise
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

@Johnson-zs Johnson-zs closed this Aug 24, 2026
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