Skip to content

fix: push clipboard data to remote clients on primary screen grab - #778

Closed
LiHua000 wants to merge 1 commit into
linuxdeepin:release/v20from
LiHua000:agent/bugfix-leader/a896408f
Closed

LiHua000 wants to merge 1 commit into
linuxdeepin:release/v20from
LiHua000:agent/bugfix-leader/a896408f

Conversation

@LiHua000

@LiHua000 LiHua000 commented Aug 21, 2026 •

Copy link
Copy Markdown

When the primary screen (server side) grabs the clipboard, handleClipboardGrabbed only marked ownership and notified other screens to grab — it never read or sent the actual clipboard data. Real data was only transferred during screen switches (switchScreen/onClipboardChanged), so if the user copied text on the server side without moving the mouse to a client screen, remote clients never received the clipboard content.

Fix: in handleClipboardGrabbed, when the grabber is the primary client, read the clipboard data via getClipboard and push it to all non-grabber clients via setClipboard. This mirrors the client-side pattern in Client::handleClipboardGrabbed which sends clipboard data immediately when not active.

Log: PMS Bug 341993 — 协同后复制文本接收端剪贴板未显示

Summary by Sourcery

Bug Fixes:

  • Push clipboard contents to all remote clients immediately when the primary screen captures the clipboard, ensuring copied data is available without a screen switch.

When the primary screen (server side) grabs the clipboard, handleClipboardGrabbed
only marked ownership and notified other screens to grab — it never read or sent
the actual clipboard data. Real data was only transferred during screen switches
(switchScreen/onClipboardChanged), so if the user copied text on the server side
without moving the mouse to a client screen, remote clients never received the
clipboard content.

Fix: in handleClipboardGrabbed, when the grabber is the primary client, read
the clipboard data via getClipboard and push it to all non-grabber clients via
setClipboard. This mirrors the client-side pattern in Client::handleClipboardGrabbed
which sends clipboard data immediately when not active.

Log: PMS Bug 341993 — 协同后复制文本接收端剪贴板未显示

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

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000

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 Aug 21, 2026

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

Reviewer's Guide

Updates server-side clipboard handling so that when the primary screen grabs the clipboard, it immediately reads and broadcasts the actual clipboard data to all other clients, ensuring remote clipboards stay in sync even without a screen switch.

Sequence diagram for updated server clipboard grab handling

sequenceDiagram
    participant User
    participant PrimaryClient
    participant Server
    participant OtherClient

    User->>PrimaryClient: copy
    PrimaryClient->>Server: handleClipboardGrabbed
    Server->>PrimaryClient: getClipboard
    PrimaryClient-->>Server: clipboard.m_clipboard
    Server->>Server: clipboard.m_clipboardData = clipboard.m_clipboard.marshall
    loop for each non_grabber client
        Server->>OtherClient: setClipboard
    end
Loading

File-Level Changes

Change Details Files
Ensure primary server clipboard grabs immediately read and broadcast clipboard data to all other clients, not just mark ownership.
  • Add a check for the primary client as the clipboard grabber in handleClipboardGrabbed
  • Invoke getClipboard on the primary client to read clipboard contents at grab time
  • Marshall the retrieved clipboard data into clipboard.m_clipboardData
  • Iterate over all connected clients and call setClipboard for each non-grabber client to push the clipboard contents
3rdparty/barrier/src/lib/server/Server.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

@LiHua000 LiHua000 closed this Sep 20, 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.

2 participants