Mouse input events sent to the wrong virt-viewer window if two vms open

With two vms open (virt-manager 4.0/virt-viewer), input events are sometimes sent to the wrong vm window.

For example, in a dual monitor setup, having one vm open on the left screen and one on the right screen, clicking and moving the mouse in the right one does not work well. At least half the clicks and move events are sent to the left vm, even though that window is not focused. If it matters, the left vm is running CentOS with spiced working by default (clipboard and mouse integration), the right vm is running Fedora where spiced does not work by default (no clipboard integration, need to click to grab the pointer first). In other words: Mouse and keyboard events are randomly sent to the wrong vm (or in some cases both to the host and to the vm).

It happens a lot and it’s probably related to the fact that at least one vm has desktop integration which works at least partially (so clipboard and mouse, but automatic screen resolution adaption never seems to work by default with Fedora Linux).

Moving the mouse cursor in the right vm is almost impossible, as the mouse cursor in the left vm is moved instead. It’s similar with clicks and hotkeys.

Is there a trick to prevent any vm that’s not focused from receiving input events?