Skip to content

Multi-PC: the driven machine knows it, and the tray shows it without hovering - #816

Merged
mgth merged 4 commits into
v6from
feat/mpc-driven-indicator
Nov 24, 2026
Merged

mgth merged 4 commits into
v6from
feat/mpc-driven-indicator

Conversation

@mgth

@mgth mgth commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Follow-up to #813, from the maintainer's real trial on 2026-11-24 (master: Linux KDE; remote: Windows vm124). Two defects:

  1. The remote showed nothing. Only the master's Machines page said "Has the mouse and keyboard".
  2. The tray tooltip is useless for this. Reading it means hovering the icon, so the pointer is on the master, which is exactly when it is not on the remote.

What changes

Remote side (lbm-agent/src/peers/actor.rs): the link's forward task already sees the master's batches go to the hook. It now tells the manager when the master's stream crosses in and when it leaves (Internal::Driving):

  • an Enter that reaches the hook → driven by that master;
  • a Leave, a session ended here (full queue, hook lost input → InputReset), or the end of the link → no longer driven. The end of the stream counts as a Leave.

Only the link that drives can clear it, so a second master's Leave does not clear the first one's. The state carries it as PeersState::driven_by (machine id) and Snapshot::DrivenBy (name). Both are additive (#[serde(default)]), so an older agent's state means "nobody".

Machines page (lbm-ui, lbm-app): the remote shows "Driven by : its mouse and keyboard are on this machine", and the master's row gets "Drives this machine". Being driven never rebuilds the map.

Tray icon (icons.rs, tray/): a new Badge sits on top of the engine state. The icon changes when the state changes at a crossing; nothing is polled.

  • Away: on a master whose pointer has gone to another machine, the icon fades to 35 % opacity.
  • Driven: on the machine a master drives, a magenta dot with a dark ring appears in the bottom-right corner. It is visible at 16 px, and magenta is not used by any engine state.

The badge is painted into the icon's own pixels, for both the StatusNotifierItem pixmaps and the Windows HICONs (12 icons are made up front instead of 4). Alternatives considered:

  • the SNI OverlayIconPixmap: not every host draws it, and the Windows notification area has nothing like it;
  • Status::NeedsAttention: it means an alert, and some hosts make it blink.

ksni already sends NewIcon when the pixmap changes. The tooltip also says "driven by ".

docs/multi-pc-etat.md is updated.

Tests

  • tests/peers.rs::the_remotes_state_says_which_master_drives_it: a test master linked to a real manager. Motion before any crossing → nobody; Enter → driven_by = master; Leave → none; Enter again then the link closes with no Leave → none.
  • tray model: the badge follows DrivenMachine / DrivenBy for every engine state, and Away wins when both are set. On Linux, the SNI pixmaps carry the badge. On Windows, every state and badge has its own icon index.
  • icons.rs: no badge gives the plain icon; Away keeps the colour and lowers the alpha; Driven puts the dot at its centre on every size and state and leaves the rest of the icon untouched.
  • page: input_goes_to for a driven machine, a kittest of the page, and the app reader for DrivenBy.
  • cargo clippy --workspace --all-targets is clean on Linux and for x86_64-pc-windows-gnu.

Locally, the 10 inotify tests (watch, wallpaper_watch) fail with ENOSPC: this machine has no inotify watches left. Nothing in this PR touches them.

Never run on real hardware

  • The remote's "Driven by" state with a real master. It is only covered by the integration test against a test master.
  • The faded icon and the dot in the Plasma tray and in the Windows notification area. They were rendered to PNG and checked by eye, never seen in either tray.
  • The remote's Machines page on screen (kittest only).
  • The Windows remote can be tried on vm124.

🤖 Generated with Claude Code

…thout hovering

Tried for real on 2026-11-24 (Linux KDE master, Windows vm124 remote), the
indicator of #813 had two holes: only the master's Machines page said who has
the mouse and keyboard, and the tray said it in a tooltip, which can only be
read with the pointer on the master — never while it is elsewhere.

- The remote follows its master's stream: `forward` tells the manager when an
  `Enter` reaches the hook and when a `Leave`, a session ended here or the end
  of the link takes the pointer away. `PeersState::driven_by` and
  `Snapshot::DrivenBy` (additive) carry it; the Machines page says "Driven by
  <master>" and marks the master "Drives this machine".
- The tray icon changes on the crossing, nothing polled: faded on a master
  whose pointer went to another machine, a magenta dot on the machine a master
  drives. Painted into the icon's pixels, so that every StatusNotifierItem host
  and the Windows notification area show it alike.

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.

Le test d’intégration avec un maître passe. J’ai reproduit un badge périmé avec deux maîtres appairés sur des connexions locales.

mgth and others added 3 commits November 24, 2026 16:05
…ne driving

Review of #816: the remote's masters share its one connection to the hook. One
going closes it, so that the hook releases what it left pressed, which ends the
session of the master driving at that moment too; that one was never told, and
DrivenBy went on naming it. A release now counts as a loss of everything written
on the connection: the driving master's link resets its session, clears DrivenBy
and says InputReset, which brings that master's pointer home.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/mpc-driven-indicator

# Conflicts:
#	docs/multi-pc-etat.md
#	rust/crates/lbm-agent/src/api.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.

Contrôle après intégration de v6 sur c4e3c430. La résolution dans Snapshot conserve DrivenBy et InputSharing. J’ai relancé le scénario à deux maîtres. Après la déconnexion de B, le hook se ferme, driven_by se vide et A reçoit InputReset. Le correctif précédent tient après fusion.

mgth added a commit that referenced this pull request Nov 24, 2026
Review of #819: #816, #817 and #818 are still open, so "none" was wrong.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mgth
mgth merged commit d51f72d into v6 Nov 24, 2026
3 checks passed
@mgth
mgth deleted the feat/mpc-driven-indicator branch November 24, 2026 15:53
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