Skip to content

feat(multi-pc): presse-papiers partagé, palier 1 (texte et image) - #821

Merged
mgth merged 5 commits into
v6from
feat/mpc-clipboard-text-image
Nov 24, 2026
Merged

mgth merged 5 commits into
v6from
feat/mpc-clipboard-text-image

Conversation

@mgth

@mgth mgth commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Première étape du presse-papiers partagé (docs/multi-pc-etat.md, « Presse-papiers partagé ») : texte et image, dans les deux sens, Linux ↔ Windows.

Ce qui a été tranché

  • KWin : vérifié avec wayland-info sur Plasma 6.8.3 — ext_data_control_manager_v1 v1 est offert à un client ordinaire, zwlr_data_control_manager_v1 ne l'est pas. Seul ext-data-control-v1 est parlé.
  • Annonce immédiate, pas de synchronisation au passage du bord : chaque copie est annoncée (formats seulement), le contenu ne traverse qu'à la première lecture par une application. Synchroniser au bord obligerait le presse-papiers à écouter le flux d'entrée.
  • Dans l'agent, pas dans le hook : connexion Wayland propre à l'agent sous Linux, fenêtre message-only sous Windows, ouvertes seulement quand l'option est cochée et qu'une machine qui partage est liée.

Ce qui change

  • lbm-net : trame bulk (genre 2), pièces de 16 Kio, file à part servie en dernier par l'écrivain du lien (après keepalive, contrôle/entrée, lecture) ; tampon d'envoi noyau réduit à 64 Kio pour que ce qui est déjà dans la socket ne retienne pas un clic. Envoyée seulement à un pair qui annonce la capacité Clipboard. Messages ClipboardOffer/ClipboardRequest/ClipboardAbort.
  • lbm-agent : peers/clipboard.rs (le partage) et clipboard/ (Wayland, Windows, et une doublure en mémoire pour les tests). Secrets non annoncés (x-kde-passwordManagerHint, ExcludeClipboardContentFromMonitorProcessing), pas de réannonce de ce qu'on a reçu, borne de 64 Mio tenue des deux côtés, offre d'un pair lâchée quand son lien tombe. Une offre reçue sous Windows est exclue de l'historique et du nuage (ils liraient chaque copie aussitôt).
  • lbm-ui/lbm-app : deux interrupteurs « Envoyer ce presse-papiers » / « Recevoir celui des autres » sur la page Machines, coupés par défaut.

Essais

  • cargo test -p lbm-net : dont « l'entrée double un transfert de 8 Mio en cours » et « deux côtés qui envoient en même temps finissent ».
  • lbm-agent/tests/clipboard.rs : deux agents en boucle locale avec un presse-papiers en mémoire (texte + image dans les deux sens, option coupée = rien d'ouvert, envoi seul, borne, pair parti, envoi coupé).
  • Conversions (fins de ligne, DIB ↔ PNG) et classement des types MIME.
  • cargo clippy --workspace --all-targets propre sous Linux et pour x86_64-pc-windows-gnu.
  • En local, cargo test --workspace : seuls échouent des tests inotify (fs.inotify.max_user_watches épuisé sur le poste, ENOSPC) et supervise.rs, déjà connu.

Jamais essayé sur du vrai matériel

Ni KWin, ni Windows, ni entre les deux : le code Wayland n'a jamais parlé à un compositeur, le code Windows n'a jamais été exécuté. À surveiller à l'essai : rendu différé quand une application lit CF_DIBV5/CF_BITMAP, Klipper qui lit le texte de chaque sélection (donc le fait traverser), et l'effet du tampon d'envoi réduit en Wi-Fi.

🤖 Generated with Claude Code

Every copy is announced at once to the linked machines that share, formats
only (ClipboardOffer); the content crosses as a bulk transfer the first time
an application on the other side reads it (ClipboardRequest/ClipboardAbort).
Off by default, on each machine and each way; the system clipboard is opened
only while the option is on and a sharing machine is linked.

- lbm-net: a third frame kind, bulk, cut in 16 KiB pieces, in a queue of its
  own that the link's writer serves last (after keepalive, control, input and
  reading); the kernel send buffer of a link is cut to 64 KiB so that what is
  already in the socket cannot hold a click up. Only sent to a peer that
  announced the Clipboard capability.
- lbm-agent: the sharing in the peer manager (peers/clipboard.rs) and the
  system clipboards: ext-data-control-v1 under Wayland (what KWin 6.8 offers,
  checked with wayland-info), a message-only window with a clipboard format
  listener and delayed rendering under Windows. Secrets are not announced,
  a received copy is never sent back, 64 MiB bound held by both sides.
- lbm-ui/lbm-app: the two switches on the Machines page.

Tested: two agents over loopback with an in-memory clipboard, conversions
(line ends, DIB <-> PNG) and MIME classification, input overtaking an 8 MiB
transfer at the link level. Never run against KWin, Windows or between the
two: see docs/multi-pc-etat.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les six tests d’intégration fournis passent sur boucle locale. Un test supplémentaire avec deux copies simultanées échoue aux deux extrémités. Les deux autres remarques viennent de la lecture des backends natifs, sans essai sur un bureau Windows ou Wayland.

Windows gives up on WM_RENDERFORMAT after 30 s; waiting 60 s only kept the
clipboard thread from the next request. Document Qt's one-second wait under
Wayland too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recontrôlé sur 300f87f, arrivé pendant la review. Le délai de rendu Windows passe de 60 à 25 secondes. Les trois remarques restent applicables à ce commit, y compris le cas de copies simultanées qui échoue sur les deux machines.

… paire réelle

Essai du mainteneur le 2026-11-24 : KDE Plasma 6.8.3 Wayland <-> Windows 11
(vm124), les deux agents à f1c0419.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recontrôlé sur 0ddf4d7c. Le dernier commit documente le passage du texte et de l’image dans les deux sens sur KDE et Windows 11. Le diff depuis 300f87fd touche uniquement docs/multi-pc-etat.md. Les trois fils restent donc ouverts pour les copies simultanées, la lecture différée d’une sélection remplacée et le réveil du thread Wayland.

…/mpc-clipboard-text-image

# Conflicts:
#	docs/multi-pc.md
#	rust/crates/lbm-agent/src/peers/actor.rs
#	rust/crates/lbm-agent/src/peers/mod.rs

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recontrôlé sur 39146ec9 après l’intégration de v6. La CI passe. Le code des copies simultanées, de la lecture différée de la sélection et du réveil Wayland est identique à celui de la précédente review. Les trois fils restent ouverts.

…ed, never lose a wake-up

From the review of #821:

- Two machines that copied before hearing of each other's copy each took
  the other's offer and could serve neither. Every offer now says the last
  serial its sender heard from the receiver (Seen) and whether it takes
  offers (Receiving); an offer that crossed the receiver's own announcement
  is settled the same way on both sides, the lower machine id keeping its
  copy.
- A read named only a format, so the backend read whatever the clipboard
  held by then, a newer copy or a secret included. The clipboard now numbers
  each copy (Wayland: each selection announced; Windows: the sequence
  number) and a read names the copy it is for; anything else is refused, on
  Windows with the clipboard open.
- The Wayland thread drained its wake-up pipe after emptying the command
  queue: a command sent in between was left waiting while the thread slept.
  The pipe is drained first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mgth mgth left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vérifié sur a7fab674. Les huit tests d’intégration passent en boucle locale, y compris les copies simultanées et le refus d’une sélection remplacée. J’ai aussi vérifié la garde de génération dans les backends Windows et Wayland et l’ordre de lecture du socket de réveil avant la file de commandes. Les trois remarques précédentes sont corrigées. Pas d’essai sur un bureau natif pour cette vérification.

@mgth
mgth merged commit b5a145e into v6 Nov 24, 2026
3 checks passed
@mgth
mgth deleted the feat/mpc-clipboard-text-image branch November 24, 2026 19:09
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.

1 participant