There are 3 major situations you have to deal with.
1. Typical desktop --- Single user, just give the user's X Server rights to all inputs by default and everything is great.
2. Single seat, Multi User --- multiple users logged in, but only one is active at a time. You give only the active X Server rights to all inputs and deny it to everybody else. When they switch from one X Session to another the rights follow the active one.
3. Multi seat, Multi User --- Multiple users logged in, multiple sessions being used simultaneously. With this you depend on the administrator (privileged user) to manually delegate which X session gets which input.
Really the solution is just very obvious for all 3:
Your going to need a privileged "input proxy" that relays the input via sockets to the correct X Server. Then that proxy decides, probably (optionally) with assistance with packagekit and dbus, to give which user the inputs based on criteria like:
Is the X Session the current one in focus on the machine?
What X Session was given rights to what input by administrator?
I a user already using it?
To make it simple for administrators and users you just serve up input to whatever X session is active first. This is already what behavior people naturally expect anyways.
It's something that should be very lightweight. Just relay the raw input directly to the X Server and let the existing X Server code for auto detecting inputs and such take care of the details. You'd just have to change things around so that instead of reading from multiple file descriptors in /dev/input your reading from sockets in /var/something.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds