[PATCH] wayland: Add wl_keyboard:keys_update()

Martin Minarik minarik11 at student.fiit.stuba.sk
Mon Jun 10 10:35:39 PDT 2013

This is going to be used by compositor for the following use cases:

* Hot plugging/unplugging an input device with already held keys.
* Handling an input lag gracefully.

However, for backward compatibility, the wl_keyboard.enter()
still uses the keys array, not using this method in that case.

The reason I added this here because:
* The wl_keyboard.enter() seems it can not be used on already entered
  surface without leave() in between.
* Regardless, can't deliver keys release using wl_keyboard.enter().
* The client are perhaps more interested in knowing which keys changed,
  not what is the actual state. Delivering state is less flexible because
  it requires the client to keep track of state, if it wants to know what
  changed. But the compositor knows what changed. Client would have to compute
  this again.
 protocol/wayland.xml |   37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index f3ba296..17320ce 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1381,7 +1381,7 @@
-  <interface name="wl_keyboard" version="1">
+  <interface name="wl_keyboard" version="2">
     <description summary="keyboard input device">
       The wl_keyboard interface represents one or more keyboards
       associated with a seat.
@@ -1460,6 +1460,41 @@
       <arg name="mods_locked" type="uint"/>
       <arg name="group" type="uint"/>
+    <!-- Version 2 additions -->
+    <enum name="key_update">
+      <description summary="update of the key state">
+	Describes how the state changed for one or a multiple keys which
+	provoked this key event.
+      </description>
+      <entry name="released" value="0" summary="the keys has been released"/>
+      <entry name="pressed" value="1" summary="the keys has been pressed"/>
+    </enum>
+    <event name="keys_update">
+      <description summary="keys update event">
+	When the compositor first discovers that the state of one or multiple
+	keys has changed, it delivers this event. The exact time of the keys
+	state change is undefined, hovewer it is known to be prior to timestamp.
+	The timestamp represents the time when the compositor detected the
+	updated key state.
+	The client is recommended to handle this event a bit more carefully than
+	a key. In particular, by depressing or releasing the UI elements without
+	triggering the associated action, if feasible. If this is unfeasible,
+	the client can handle this exactly like calling wl_keyboard.key() event
+	on every item in keys array.
+	For backwards compatibility, on surface enter, the keys are not
+	delivered using this event. They are still delivered using the previous
+	wl_keyboard.enter()
+      </description>
+      <arg name="serial" type="uint"/>
+      <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
+      <arg name="keys" type="array" summary="the currently pressed keys"/>
+      <arg name="state_update" type="uint"/>
+    </event>
   <interface name="wl_touch" version="1">

More information about the wayland-devel mailing list