protocol: explicitly describe wl_keyboard state

And the allowed state transitions.

There has been some confusion regarding which state transitions are
allowed. This change should clarify this.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
This commit is contained in:
Julian Orth 2024-04-17 11:24:50 +02:00 committed by Simon Ser
parent 6963320218
commit 9e4f256927

View file

@ -2424,6 +2424,16 @@
<description summary="keyboard input device"> <description summary="keyboard input device">
The wl_keyboard interface represents one or more keyboards The wl_keyboard interface represents one or more keyboards
associated with a seat. associated with a seat.
Each wl_keyboard has the following logical state:
- an active surface (possibly null),
- the keys currently logically down,
- the active modifiers,
- the active group.
By default, the active surface is null, the keys currently logically down
are empty, the active modifiers and the active group are 0.
</description> </description>
<enum name="keymap_format"> <enum name="keymap_format">
@ -2458,10 +2468,15 @@
The compositor must send the wl_keyboard.modifiers event after this The compositor must send the wl_keyboard.modifiers event after this
event. event.
In the wl_keyboard logical state, this event sets the active surface to
the surface argument and the keys currently logically down to the keys
in the keys argument. The compositor must not send this event if the
wl_keyboard already had an active surface immediately before this event.
</description> </description>
<arg name="serial" type="uint" summary="serial number of the enter event"/> <arg name="serial" type="uint" summary="serial number of the enter event"/>
<arg name="surface" type="object" interface="wl_surface" summary="surface gaining keyboard focus"/> <arg name="surface" type="object" interface="wl_surface" summary="surface gaining keyboard focus"/>
<arg name="keys" type="array" summary="the currently pressed keys"/> <arg name="keys" type="array" summary="the keys currently logically down"/>
</event> </event>
<event name="leave"> <event name="leave">
@ -2472,10 +2487,10 @@
The leave notification is sent before the enter notification The leave notification is sent before the enter notification
for the new focus. for the new focus.
After this event client must assume that no keys are pressed, In the wl_keyboard logical state, this event resets all values to their
it must stop key repeating if there's some going on and until defaults. The compositor must not send this event if the active surface
it receives the next wl_keyboard.modifiers event, the client of the wl_keyboard was not equal to the surface argument immediately
must also assume no modifiers are active. before this event.
</description> </description>
<arg name="serial" type="uint" summary="serial number of the leave event"/> <arg name="serial" type="uint" summary="serial number of the leave event"/>
<arg name="surface" type="object" interface="wl_surface" summary="surface that lost keyboard focus"/> <arg name="surface" type="object" interface="wl_surface" summary="surface that lost keyboard focus"/>
@ -2501,8 +2516,14 @@
If this event produces a change in modifiers, then the resulting If this event produces a change in modifiers, then the resulting
wl_keyboard.modifiers event must be sent after this event. wl_keyboard.modifiers event must be sent after this event.
The compositor must not send this event without a surface of the client In the wl_keyboard logical state, this event adds the key to the keys
having keyboard focus. currently logically down (if the state argument is pressed) or removes
the key from the keys currently logically down (if the state argument is
released). The compositor must not send this event if the wl_keyboard
did not have an active surface immediately before this event. The
compositor must not send this event if state is pressed (resp. released)
and the key was already logically down (resp. was not logically down)
immediately before this event.
</description> </description>
<arg name="serial" type="uint" summary="serial number of the key event"/> <arg name="serial" type="uint" summary="serial number of the key event"/>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/> <arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
@ -2522,6 +2543,9 @@
valid until it receives the next wl_keyboard.modifiers event. In order to valid until it receives the next wl_keyboard.modifiers event. In order to
reset the modifier state again, the compositor can send a reset the modifier state again, the compositor can send a
wl_keyboard.modifiers event with no pressed modifiers. wl_keyboard.modifiers event with no pressed modifiers.
In the wl_keyboard logical state, this event updates the modifiers and
group.
</description> </description>
<arg name="serial" type="uint" summary="serial number of the modifiers event"/> <arg name="serial" type="uint" summary="serial number of the modifiers event"/>
<arg name="mods_depressed" type="uint" summary="depressed modifiers"/> <arg name="mods_depressed" type="uint" summary="depressed modifiers"/>