From 56004836b9cf48f0f8ebec00f89a388839441263 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 7 Mar 2023 19:47:34 +1000 Subject: [PATCH] proto: add the context-type attribute to events and requests This allows us to mark/filter requests and events that are only available on a given context type. --- doc/protocol/interface.md.tmpl | 20 +++++++++++++ proto/ei-scanner | 8 ++++++ proto/protocol.dtd | 2 ++ proto/protocol.xml | 52 +++++++++++++++++----------------- 4 files changed, 56 insertions(+), 26 deletions(-) diff --git a/doc/protocol/interface.md.tmpl b/doc/protocol/interface.md.tmpl index 8ce3c39..662fcf8 100644 --- a/doc/protocol/interface.md.tmpl +++ b/doc/protocol/interface.md.tmpl @@ -70,6 +70,16 @@ by the EIS implementation. It must no longer be used by the client. {% endraw %} {% endif %} +{% if request.context_type %} +{% raw %} +{{% notice style="note" %}} +{% endraw %} +This request is only available for clients of `ei_handshake.context_type.{{request.context_type}}`. +{% raw %} +{{% /notice %}} +{% endraw %} +{% endif %} + {{request.description.text|ei_escape_names}} {% endfor %} @@ -106,6 +116,16 @@ by the EIS implementation. It must no longer be used by the client. {% endraw %} {% endif %} +{% if event.context_type %} +{% raw %} +{{% notice style="note" %}} +{% endraw %} +This event is only available for clients of `ei_handshake.context_type.{{event.context_type}}`. +{% raw %} +{{% /notice %}} +{% endraw %} +{% endif %} + {{event.description.text|ei_escape_names}} diff --git a/proto/ei-scanner b/proto/ei-scanner index 122d3e9..8a4b9da 100755 --- a/proto/ei-scanner +++ b/proto/ei-scanner @@ -139,9 +139,15 @@ class Message: interface: "Interface" = attr.ib() description: Optional[Description] = attr.ib(default=None) is_destructor: bool = attr.ib(default=False) + context_type: Optional[str] = attr.ib(default=None) arguments: list[Argument] = attr.ib(init=False, factory=list) + @context_type.validator # type: ignore + def _context_type_validate(self, attr, value): + if value not in [None, "sender", "receiver"]: + raise ValueError(f"Invalid context type {value}") + def add_argument(self, arg: Argument) -> None: if arg.name in [a.name for a in self.arguments]: raise ValueError(f"Duplicate argument name '{arg.name}'") @@ -570,6 +576,7 @@ class ProtocolParser(xml.sax.handler.ContentHandler): interface=self.current_interface, is_destructor=is_destructor, ) + request.context_type = attrs.get("context-type") try: self.current_interface.add_request(request) except ValueError as e: @@ -604,6 +611,7 @@ class ProtocolParser(xml.sax.handler.ContentHandler): interface=self.current_interface, is_destructor=is_destructor, ) + event.context_type = attrs.get("context-type") try: self.current_interface.add_event(event) except ValueError as e: diff --git a/proto/protocol.dtd b/proto/protocol.dtd index 4a8522f..635f828 100644 --- a/proto/protocol.dtd +++ b/proto/protocol.dtd @@ -10,9 +10,11 @@ + + diff --git a/proto/protocol.xml b/proto/protocol.xml index 345782d..2a3b5e1 100644 --- a/proto/protocol.xml +++ b/proto/protocol.xml @@ -735,7 +735,7 @@ - + Notify the EIS implementation that the given device is about to start sending events. This should be seen more as a transactional boundary than a @@ -767,7 +767,7 @@ - + Notify the EIS implementation that the given device is no longer sending events. See ei_device.start_emulating for details. @@ -778,7 +778,7 @@ - + Generate a frame event to group the current set of events into a logical hardware event. This function must be called after one @@ -1053,7 +1053,7 @@ - + See the ei_device.start_emulating request for details. @@ -1064,7 +1064,7 @@ - + See the ei_device.stop_emulating request for details. @@ -1074,7 +1074,7 @@ - + See the ei_device.frame request for details. @@ -1110,7 +1110,7 @@ - + Generate a relative motion event on this pointer. @@ -1127,7 +1127,7 @@ - + Generate an absolute motion event on this pointer. The x/y coordinates must be within the device's regions or the event @@ -1146,7 +1146,7 @@ - + Generate a a smooth (pixel-precise) scroll event on this pointer. Clients must not send ei_pointer.scroll_discrete events for the same event, @@ -1163,7 +1163,7 @@ - + Generate a a discrete (e.g. wheel) scroll event on this pointer. Clients must not send ei_pointer.scroll events for the same event, @@ -1184,7 +1184,7 @@ - + Generate a a scroll stop or cancel event on this pointer. @@ -1222,7 +1222,7 @@ - + Generate a button event on this pointer. @@ -1252,7 +1252,7 @@ - + See the ei_pointer.motion_relative request for details. @@ -1263,7 +1263,7 @@ - + See the ei_pointer.motion_absolute request for details. @@ -1274,7 +1274,7 @@ - + See the ei_pointer.scroll request for details. @@ -1285,7 +1285,7 @@ - + See the ei_pointer.scroll_discrete request for details. @@ -1296,7 +1296,7 @@ - + See the ei_pointer.scroll_stop request for details. @@ -1308,7 +1308,7 @@ - + See the ei_pointer.button request for details. @@ -1356,7 +1356,7 @@ - + Generate a key event on this keyboard. If the device has an ei_device.keymap, the key code corresponds to that keymap. @@ -1419,7 +1419,7 @@ - + See the ei_keyboard.key request for details. @@ -1481,7 +1481,7 @@ - + Notifies the EIS implementation about a new touch logically down at the given coordinates. The touchid is a unique id for this touch. Touchids @@ -1498,7 +1498,7 @@ - + Notifies the EIS implementation about an existing touch changing position to the given coordinates. The touchid is the unique id for this touch previously @@ -1515,7 +1515,7 @@ - + Notifies the EIS implementation about an existing touch being logically up. The touchid is the unique id for this touch previously @@ -1543,7 +1543,7 @@ - + See the ei_touchscreen.down request for details. @@ -1558,7 +1558,7 @@ - + See the ei_touchscreen.motion request for details. @@ -1573,7 +1573,7 @@ - + See the ei_touchscreen.up request for details.