mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-15 14:15:52 -06:00
[GH-ISSUE #390] Advice needed: how to send events back from an emulation implementation #203
Labels
No labels
Xorg
documentation
enhancement
macos
pull-request
question
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/lan-mouse#203
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @whot on GitHub (Feb 19, 2026).
Original GitHub issue: https://github.com/feschber/lan-mouse/issues/390
I've been working on trying to get clipboard support in here but I keep running into a wall trying to understand the architecture and how to send events back from an emulation client (currently working on on the remote desktop part).
What I have right now is an extended
LibeiEmulationthat connects to the clipboard portal and gets notifications from that. I have a wire protocol to send clipboard bits left and right and (I think) they work.What I'm stuck on is a simple thing: I need to send an event back from
LibeiEmulation- in particular i need to send a "SelectionOwnerChanged" event (sent by the portal when I copy something) which contains mime-types and whatnot. And I need to send a "TransferRequest" event (sent when I paste something). And I cannot for the life of me figure out how I can send something back "up".So basically what I have is:
LibeiEmulationhas a spawned task that receives the SelectionOwnerChanged/TransferRequest signal from the portal. I need to send the data from those signals to the remote end. The remote end will (eventually) reply with some protocol message at which point I can send data.But right now I'm stuck at the "how do I actually notify the remote end from the emulation code". Any hints would be much appreciated, right now I'm stuck and I've stared at this for too long.
@feschber commented on GitHub (Feb 19, 2026):
Yeah, this is something, the input-emulation was absolutely not designed to do (yet)... (as I hinted at in #387)
Currently it's a simple one way channel to send events.
I'm not sure if it would be better to separate this entirely from the
input-emulationcrate. Reason being that some other emulation backends most certainly won't be handling clipboard events at all and some clipboard functionality is probably also going to be handled by theinput-capture, e.g.layer-shell(which makes more sense in my mind tbh).Since we already have the restore tokens now, maybe it's easiest to add an entirely separate crate
clipboard-provider, and implement it in there as a new xdg-rdp client.But we can also extend the
input-emulation- I drafted a little patch:@feschber commented on GitHub (Feb 19, 2026):
Thinking about this a bit more, I think we should definitely first extend input-emulation the way you started before we overcomplicate things for no reason.
I can still extract this into some other crate in the future, if I ever feel the need to do so.
@whot commented on GitHub (Feb 19, 2026):
Yeah, going the simpler path seems to be the better choice for now :) I'm wondering: since we need both emulation and capture on both ends anyway and capture is definitely not a one-way street - we could integrate clipboard into the input capture session and go from there? At least with portals this should work just fine. The only requirement here is of course to be able to send events to and from the capture session but I think this is already possible (without checking, I've mainly focused on the remote desktop code so far).
Oh, and just ftr, my very much WIP branch is here and it has bits and pieces in place (for emulation), so it's the connection between portal code and core code that's missing.
@nbolton commented on GitHub (Feb 19, 2026):
Heads up: link is broken
https://github.com/whot/lan-mouse/tree/wip/inputcapture-clipboard
@feschber commented on GitHub (Feb 20, 2026):
Would
Are you suggesting to spawn a remote desktop session within the input-capture?
Logically I'd say it would make sense for the input-capture to generate clipboard content (i.e. receive from the compositor) and the input-emulation to consume clipboard content (i.e. send it to the compositor).
However, since the remote desktop portal seems to do both of these things, we can't really put it into either of those.
Thus, I would almost prefer to put it into a separate crate that does all of the clipboard stuff independently.
Btw, are there any plans to support drag & drop in xdg-desktop-portal?
Because that would have to be integrated with the input-capture portal in some capacity...
fixed link
just a heads up, in case you haven't noticed: The network protocol is unreliable atm.
For key and pointer events we simply don't care about that (worst case, a key gets stuck until the user presses it again).
For larger clipboard contents there probably should be a mechanism to re-request clipboard contents until the whole thing is received, or potentially a reliable data channel of some sort that handles this.
@whot commented on GitHub (Feb 20, 2026):
Link is fixed, thanks @nbolton
no, on the dbus side the clipboard portal sort-of attaches itself to a session, so we can simply attach to the input-capture session and receive and write out clipboard from that. And we leave the remote session as-is so we don't need to rewrite that.
You mean drag-and-drop across hosts? I don't have an answer for that, would have to dig through the portal sources/PRs and see what is currently being worked on (this is a a side-gig for me, mainly :)
oh. I did not notice... the approach you say seems fine, but can (hopefully) be tacked on once we get something working :)
@feschber commented on GitHub (Feb 20, 2026):
Interesting. That would require changes in ashpd as well, right?
@whot commented on GitHub (Feb 22, 2026):
yes, but I have those ready locally.
@whot commented on GitHub (Feb 24, 2026):
ftr https://github.com/bilelmoussaoui/ashpd/pull/364 is the last remaining bit on the ashpd side, assuming the portal MR gets merged, the clipboard support for inputcapture is already in the portal and ashpd git (technically in 0.13.0 but a bug prevents it from working)