mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
conf: Add grabToggle to evdev input
Add support for customizable grabToggle key combinations with <input type='evdev'>. Signed-off-by: Justin Gatzen <justin.gatzen@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e286a62941
commit
e7d579a2dd
@ -5747,7 +5747,7 @@ to provide a graphics tablet for absolute cursor movement.
|
|||||||
<source evdev='/dev/input/event1'/>
|
<source evdev='/dev/input/event1'/>
|
||||||
</input>
|
</input>
|
||||||
<input type='evdev'>
|
<input type='evdev'>
|
||||||
<source dev='/dev/input/event1234' grab='all' repeat='on'/>
|
<source dev='/dev/input/event1234' grab='all' repeat='on' grabToggle='ctrl-ctrl'/>
|
||||||
</input>
|
</input>
|
||||||
</devices>
|
</devices>
|
||||||
...
|
...
|
||||||
@ -5768,10 +5768,12 @@ On S390, ``address`` can be used to provide a CCW address for an input device (
|
|||||||
sub-element ``source`` must have an ``evdev`` (for ``passthrough``) or ``dev``
|
sub-element ``source`` must have an ``evdev`` (for ``passthrough``) or ``dev``
|
||||||
(for ``evdev``) attribute containing the absolute path to the event device
|
(for ``evdev``) attribute containing the absolute path to the event device
|
||||||
passed through to guests.
|
passed through to guests.
|
||||||
For type ``evdev``, ``source`` can have two optional attributes ``grab`` with
|
For type ``evdev``, ``source`` has three optional attributes ``grab`` with
|
||||||
value 'all' which when enabled grabs all input devices instead of just one and
|
value 'all' which when enabled grabs all input devices instead of just one,
|
||||||
``repeat`` with value 'on'/'off' to enable/disable auto-repeat events (
|
``repeat`` with value 'on'/'off' to enable/disable auto-repeat events and
|
||||||
:since:`Since 7.4.0`).
|
``grabToggle`` (:since:`since 7.6.0`) with values ``ctrl-ctrl``, ``alt-alt``,
|
||||||
|
``shift-shift``, ``meta-meta``, ``scrolllock`` or ``ctrl-scrolllock`` to
|
||||||
|
change the grab key combination.
|
||||||
``input`` type ``evdev`` is currently supported only on linux devices.
|
``input`` type ``evdev`` is currently supported only on linux devices.
|
||||||
(KVM only) :since:`Since 5.2.0` , the ``input`` element accepts a
|
(KVM only) :since:`Since 5.2.0` , the ``input`` element accepts a
|
||||||
``model`` attribute which has the values 'virtio', 'virtio-transitional' and
|
``model`` attribute which has the values 'virtio', 'virtio-transitional' and
|
||||||
|
@ -5484,6 +5484,18 @@
|
|||||||
<value>all</value>
|
<value>all</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name="grabToggle">
|
||||||
|
<choice>
|
||||||
|
<value>ctrl-ctrl</value>
|
||||||
|
<value>alt-alt</value>
|
||||||
|
<value>shift-shift</value>
|
||||||
|
<value>meta-meta</value>
|
||||||
|
<value>scrolllock</value>
|
||||||
|
<value>ctrl-scrolllock</value>
|
||||||
|
</choice>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name="repeat">
|
<attribute name="repeat">
|
||||||
<ref name="virOnOff"/>
|
<ref name="virOnOff"/>
|
||||||
|
@ -891,6 +891,17 @@ VIR_ENUM_IMPL(virDomainInputSourceGrab,
|
|||||||
"all",
|
"all",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
VIR_ENUM_IMPL(virDomainInputSourceGrabToggle,
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_LAST,
|
||||||
|
"default",
|
||||||
|
"ctrl-ctrl",
|
||||||
|
"alt-alt",
|
||||||
|
"shift-shift",
|
||||||
|
"meta-meta",
|
||||||
|
"scrolllock",
|
||||||
|
"ctrl-scrolllock",
|
||||||
|
);
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virDomainGraphics,
|
VIR_ENUM_IMPL(virDomainGraphics,
|
||||||
VIR_DOMAIN_GRAPHICS_TYPE_LAST,
|
VIR_DOMAIN_GRAPHICS_TYPE_LAST,
|
||||||
"sdl",
|
"sdl",
|
||||||
@ -12011,6 +12022,11 @@ virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
VIR_XML_PROP_NONZERO, &def->source.grab) < 0)
|
VIR_XML_PROP_NONZERO, &def->source.grab) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (virXMLPropEnum(source, "grabToggle",
|
||||||
|
virDomainInputSourceGrabToggleTypeFromString,
|
||||||
|
VIR_XML_PROP_NONZERO, &def->source.grabToggle) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (virXMLPropTristateSwitch(source, "repeat",
|
if (virXMLPropTristateSwitch(source, "repeat",
|
||||||
VIR_XML_PROP_NONE, &def->source.repeat) < 0)
|
VIR_XML_PROP_NONE, &def->source.repeat) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -25998,6 +26014,7 @@ virDomainInputDefFormat(virBuffer *buf,
|
|||||||
const char *type = virDomainInputTypeToString(def->type);
|
const char *type = virDomainInputTypeToString(def->type);
|
||||||
const char *bus = virDomainInputBusTypeToString(def->bus);
|
const char *bus = virDomainInputBusTypeToString(def->bus);
|
||||||
const char *grab = virDomainInputSourceGrabTypeToString(def->source.grab);
|
const char *grab = virDomainInputSourceGrabTypeToString(def->source.grab);
|
||||||
|
const char *grabToggle = virDomainInputSourceGrabToggleTypeToString(def->source.grabToggle);
|
||||||
const char *repeat = virTristateSwitchTypeToString(def->source.repeat);
|
const char *repeat = virTristateSwitchTypeToString(def->source.repeat);
|
||||||
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
||||||
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
||||||
@ -26049,6 +26066,8 @@ virDomainInputDefFormat(virBuffer *buf,
|
|||||||
|
|
||||||
if (def->source.grab)
|
if (def->source.grab)
|
||||||
virBufferAsprintf(&sourceAttrBuf, " grab='%s'", grab);
|
virBufferAsprintf(&sourceAttrBuf, " grab='%s'", grab);
|
||||||
|
if (def->source.grabToggle)
|
||||||
|
virBufferAsprintf(&sourceAttrBuf, " grabToggle='%s'", grabToggle);
|
||||||
if (def->source.repeat)
|
if (def->source.repeat)
|
||||||
virBufferAsprintf(&sourceAttrBuf, " repeat='%s'", repeat);
|
virBufferAsprintf(&sourceAttrBuf, " repeat='%s'", repeat);
|
||||||
|
|
||||||
|
@ -1420,6 +1420,18 @@ typedef enum {
|
|||||||
VIR_DOMAIN_INPUT_SOURCE_GRAB_LAST
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_LAST
|
||||||
} virDomainInputSourceGrab;
|
} virDomainInputSourceGrab;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_DEFAULT,
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_CTRL_CTRL,
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_ALT_ALT,
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_SHIFT_SHIFT,
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_META_META,
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_SCROLLLOCK,
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_CTRL_SCROLLLOCK,
|
||||||
|
|
||||||
|
VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_LAST
|
||||||
|
} virDomainInputSourceGrabToggle;
|
||||||
|
|
||||||
struct _virDomainInputDef {
|
struct _virDomainInputDef {
|
||||||
int type;
|
int type;
|
||||||
int bus;
|
int bus;
|
||||||
@ -1427,6 +1439,7 @@ struct _virDomainInputDef {
|
|||||||
struct {
|
struct {
|
||||||
char *evdev;
|
char *evdev;
|
||||||
virDomainInputSourceGrab grab;
|
virDomainInputSourceGrab grab;
|
||||||
|
virDomainInputSourceGrabToggle grabToggle;
|
||||||
virTristateSwitch repeat;
|
virTristateSwitch repeat;
|
||||||
} source;
|
} source;
|
||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
@ -3871,6 +3884,7 @@ VIR_ENUM_DECL(virDomainInput);
|
|||||||
VIR_ENUM_DECL(virDomainInputBus);
|
VIR_ENUM_DECL(virDomainInputBus);
|
||||||
VIR_ENUM_DECL(virDomainInputModel);
|
VIR_ENUM_DECL(virDomainInputModel);
|
||||||
VIR_ENUM_DECL(virDomainInputSourceGrab);
|
VIR_ENUM_DECL(virDomainInputSourceGrab);
|
||||||
|
VIR_ENUM_DECL(virDomainInputSourceGrabToggle);
|
||||||
VIR_ENUM_DECL(virDomainGraphics);
|
VIR_ENUM_DECL(virDomainGraphics);
|
||||||
VIR_ENUM_DECL(virDomainGraphicsListen);
|
VIR_ENUM_DECL(virDomainGraphicsListen);
|
||||||
VIR_ENUM_DECL(virDomainGraphicsAuthConnected);
|
VIR_ENUM_DECL(virDomainGraphicsAuthConnected);
|
||||||
|
@ -476,6 +476,8 @@ virDomainInputBusTypeToString;
|
|||||||
virDomainInputDefFind;
|
virDomainInputDefFind;
|
||||||
virDomainInputDefFree;
|
virDomainInputDefFree;
|
||||||
virDomainInputDefGetPath;
|
virDomainInputDefGetPath;
|
||||||
|
virDomainInputSourceGrabToggleTypeFromString;
|
||||||
|
virDomainInputSourceGrabToggleTypeToString;
|
||||||
virDomainInputSourceGrabTypeFromString;
|
virDomainInputSourceGrabTypeFromString;
|
||||||
virDomainInputSourceGrabTypeToString;
|
virDomainInputSourceGrabTypeToString;
|
||||||
virDomainInputTypeToString;
|
virDomainInputTypeToString;
|
||||||
|
@ -3947,6 +3947,11 @@ qemuBuildObjectInputDevStr(virDomainInputDef *dev,
|
|||||||
if (dev->source.grab == VIR_DOMAIN_INPUT_SOURCE_GRAB_ALL)
|
if (dev->source.grab == VIR_DOMAIN_INPUT_SOURCE_GRAB_ALL)
|
||||||
virJSONValueObjectAdd(props, "b:grab_all", true, NULL);
|
virJSONValueObjectAdd(props, "b:grab_all", true, NULL);
|
||||||
|
|
||||||
|
if (dev->source.grabToggle != VIR_DOMAIN_INPUT_SOURCE_GRAB_TOGGLE_DEFAULT)
|
||||||
|
virJSONValueObjectAdd(props, "s:grab-toggle",
|
||||||
|
virDomainInputSourceGrabToggleTypeToString(dev->source.grabToggle),
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0)
|
if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
|
|||||||
-no-acpi \
|
-no-acpi \
|
||||||
-boot strict=on \
|
-boot strict=on \
|
||||||
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
|
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
|
||||||
-object '{"qom-type":"input-linux","id":"input0","evdev":"/dev/input/event1234","repeat":true,"grab_all":true}' \
|
-object '{"qom-type":"input-linux","id":"input0","evdev":"/dev/input/event1234","repeat":true,"grab_all":true,"grab-toggle":"alt-alt"}' \
|
||||||
-audiodev id=audio1,driver=none \
|
-audiodev id=audio1,driver=none \
|
||||||
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
|
||||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
</controller>
|
</controller>
|
||||||
<input type='evdev'>
|
<input type='evdev'>
|
||||||
<source dev='/dev/input/event1234' grab='all' repeat='on'/>
|
<source dev='/dev/input/event1234' grab='all' grabToggle='alt-alt' repeat='on'/>
|
||||||
</input>
|
</input>
|
||||||
<input type='mouse' bus='ps2'/>
|
<input type='mouse' bus='ps2'/>
|
||||||
<input type='keyboard' bus='ps2'/>
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
Loading…
Reference in New Issue
Block a user