[PATCH v4 2/8] drm/atomic: Add support for mouse hotspots

Pekka Paalanen ppaalanen at gmail.com
Tue Jul 4 08:08:45 UTC 2023


On Mon, 3 Jul 2023 14:06:56 -0700
Michael Banack <banackm at vmware.com> wrote:

> Hi, I can speak to the virtual mouse/console half of this from the 
> VMware-side.
> 
> I believe Zack's preparing a new set of comments here that can speak to 
> most of your concerns, but I'll answer some of the other questions directly.
> 
> On 6/29/23 01:03, Pekka Paalanen wrote:
> >
> > Is it really required that the hotspot coordinates fall inside the
> > cursor plane? Will the atomic commit be rejected otherwise?  
> Most console systems require the hotspot to get within the cursor image, 
> but in theory it's semantically meaningful to have it extend outside the 
> image.
> 
> VMware's clients in particular will clamp the hotspot to the dimension 
> of the cursor image if we receive one that's out of bounds.
> 
> So I would assume the right thing to do here would be to allow it and 
> let the clients figure out how to best handle it.

Hi,

if it is normal that clients clamp the hotspot to inside the cursor
image, then I would come to the opposite conclusion: KMS UAPI needs to
require the hotspot to be within the cursor image. Otherwise the
results would be unpredictable, if clients still continue to clamp it
anyway. I would assume that clients in use today are not prepared to
handle hotspot outside the cursor image.

It is also not a big deal to require that. I think it would be very rare
to not have hotspot inside the cursor image, and even if it happened,
the only consequence would be that the guest display server falls back
to rendered cursor instead of a cursor plane. That may happen any time
anyway, if an application sets e.g. a huge cursor that exceeds cursor
plane size limits.

What I'm after with the question is that the requirement must be spelled
out clearly if it is there, or not even hinted at if it's not there.

> >  
> >>   *
> >>   * This information is only relevant for drivers working on top
> >>   * of para-virtualized hardware. The reason for that is that
> >>   * the hotspot is fairly encapsulated in the system but imagine having
> >>   * multiple windows with virtual machines running on servers
> >>   * across the globe, as you move the mouse across the screen
> >>   * and the cursor moves over those multiple windows you wouldn't
> >>   * want to be sending those mouse events to those machines, so virtual
> >>   * machine monitors implement an optimization where unless the mouse
> >>   * is locked to the VM window (e.g. via a click) instead of propagating
> >>   * those mouse events to those VM's they change the image of the native
> >>   * cursor to what's inside the mouse cursor plane and do not interact
> >>   * with the VM window until mouse is clicked in it.  
> > Surely the mouse events are sent to those machines across the globe
> > regardless?
> >
> > The point I believe you want to make is that in addition that, a
> > virtual machine viewer application independently moves the cursor image
> > on the viewer window to avoid the roundtrip latency across the globe
> > between mouse movement and cursor movement.
> >
> > Why is the locking you mention relevant? Wouldn't you do this
> > optimization always if there is any cursor plane image set?
> >
> > Or if you literally do mean that no input is sent to the VM at all
> > until the pointer is locked to that window, then why bother using the
> > guest cursor image without locking?
> >
> > I suppose different viewers could do different things, so maybe it's
> > not necessary to go into those details. Just the idea of the viewer
> > independently moving the cursor image to reduce hand-eye latency is
> > important, right?  
> 
> Yeah, the discussions of "locking" here are more implementation details 
> of how VMware's console works, and while  there are other consoles that 
> work this way, many of them don't.
> 
> So it's probably more confusing than helpful without some more 
> background that the other layers here don't need to worry about.

Cool.

> The main idea is that the client needs to know where the VM thinks the 
> mouse is to determine whether it /can/ safely accelerate it all the way 
> through to the client's cursor stack.  If something else in the VM is 
> moving the mouse around, like an additional remote connection, then the 
> client needs to fallback to an emulated cursor on the client side for a 
> while.

Good point.

> > The question of which input device corresponds to which cursor plane
> > might be good to answer too. I presume the VM runner is configured to
> > expose exactly one of each, so there can be only one association?  
> As far as I know, all of the VM consoles are written as though they 
> taking the place of what would the the physical monitors and input 
> devices on a native machine.  So they assume that there is one user, 
> sitting in front of one console, and all monitors/input devices are 
> being used by that user.

Ok, but having a single user does not mean that there cannot be
multiple independent pointers, especially on Wayland. The same with
keyboards.

> Any more complicated multi-user/multi-cursor setup would have to be 
> coordinated through a lot of layers (ie from the VM's userspace/kernel 
> and then through hypervisor/client-consoles), and as far as I know 
> nobody has tried to plumb that all the way through.  Even physical 
> multi-user/multi-console configurations like that are rare.

Right.

So if there a VM viewer client running on a Wayland system, that viewer
client may be presented with an arbitrary number of independent
pointer/keyboard/touchscreen input devices. Then it is up to the client
to pick one at a time to pass through to the VM.

That's fine.

I just think it would be good to document, that VM/viewer systems
expect to expose just a single pointer to the guest, hence it is
obvious which input device in the guest is associated with all the
cursor planes in the guest.

Btw. what do you do if a guest display server simultaneously uses
multiple cursor planes, assuming there are multiple outputs each with a
cursor plane? Or does the VM/viewer system limit the number of outputs
to one for the guest?

> >
> > Btw. for my own curiosity, what happens if there are two simultaneous
> > viewer instances open to the same VM/guest instance? Will they fight
> > over controlling the same pointer?  
> 
> I can't speak for all consoles, but VMware at least uses a bunch of 
> heuristics that typically boil down to which mouse input source has been 
> moving the cursor most recently.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20230704/5f38ab39/attachment.sig>


More information about the dri-devel mailing list