[RFC] Declare enumeration wl_output.transform as bitfield.
Nils Christopher Brause
nilschrbrause at gmail.com
Wed Nov 25 04:08:29 PST 2015
The definition of a bitfield is that each bit has a distinct meaning, which is
the case for the enumeration wl_output.transform:
- bit 0: rotate by 90 degree
- bit 1: rotate by 180 degree
- bit 2: flip around vertical axis
Every other value can be constructed by ORing together the above bits:
- "270" = "90" | "180"
- "flipped_90" = "90" | "flipped"
- "flipped_180" = "180" | "flipped"
- "flipped_270" = "90" | "180" | "flipped"
Therefore add the bitfield="true" attribute to the enumeration declaration.
Also, modify the argument type of each usage of the bitfield
wl_output.transform to be an uint instead of an int to comply with the scanner
rules. This is a valid change, beause:
1. It does not change the wire protocol. Since bitfields do not have any
numerical meaning, it doesn't make any difference wether they are
transferred as signed or unsigned integers over the wire.
2. It does not change the ABI. On the ABI level, values are passed to function
calls via registers or on the stack (depending on the architecture and
calling convention) and neither argument passing method cares about the
signdness of the passed arguments.
3. The API change is negligible. Every request that accepts this bitfield
expects a number in the range of zero to seven. These numbers can be
represented in and converted between signed and unsigned 32 bit integers
without any loss and generated compiler warnings are harmless.
---
protocol/wayland.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index f9e6d76..633a3fe 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1292,7 +1292,7 @@
wl_output.transform enum the invalid_transform protocol error
is raised.
</description>
- <arg name="transform" type="int"/>
+ <arg name="transform" type="uint"/>
</request>
<!-- Version 3 additions -->
@@ -1787,7 +1787,7 @@
<entry name="vertical_bgr" value="5"/>
</enum>
- <enum name="transform">
+ <enum name="transform" bitfield="true">
<description summary="transform from framebuffer to output">
This describes the transform that a compositor will apply to a
surface to compensate for the rotation or mirroring of an
@@ -1832,7 +1832,7 @@
summary="textual description of the manufacturer"/>
<arg name="model" type="string"
summary="textual description of the model"/>
- <arg name="transform" type="int" enum="transform"
+ <arg name="transform" type="uint" enum="transform"
summary="transform that maps framebuffer to output"/>
</event>
--
2.6.2
More information about the wayland-devel
mailing list