1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="xwayland_shell_v1">
3
4 <copyright>
5 Copyright © 2022 Joshua Ashton
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 and/or sell copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
16 Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25 </copyright>
26
27 <description summary="Protocol for associating X11 windows to wl_surfaces">
28 This protocol adds a xwayland_surface role which allows an Xwayland
29 server to associate an X11 window to a wl_surface.
30
31 Before this protocol, this would be done via the Xwayland server
32 providing the wl_surface's resource id via the a client message with
33 the WL_SURFACE_ID atom on the X window.
34 This was problematic as a race could occur if the wl_surface
35 associated with a WL_SURFACE_ID for a window was destroyed before the
36 client message was processed by the compositor and another surface
37 (or other object) had taken its id due to recycling.
38
39 This protocol solves the problem by moving the X11 window to wl_surface
40 association step to the Wayland side, which means that the association
41 cannot happen out-of-sync with the resource lifetime of the wl_surface.
42
43 This protocol avoids duplicating the race on the other side by adding a
44 non-zero monotonic serial number which is entirely unique that is set on
45 both the wl_surface (via. xwayland_surface_v1's set_serial method) and
46 the X11 window (via. the `WL_SURFACE_SERIAL` client message) that can be
47 used to associate them, and synchronize the two timelines.
48
49 The key words "must", "must not", "required", "shall", "shall not",
50 "should", "should not", "recommended", "may", and "optional" in this
51 document are to be interpreted as described in IETF RFC 2119.
52
53 Warning! The protocol described in this file is currently in the testing
54 phase. Backward compatible changes may be added together with the
55 corresponding interface version bump. Backward incompatible changes can
56 only be done by creating a new major version of the extension.
57 </description>
58
59 <interface name="xwayland_shell_v1" version="1">
60 <description summary="context object for Xwayland shell">
61 xwayland_shell_v1 is a singleton global object that
62 provides the ability to create a xwayland_surface_v1 object
63 for a given wl_surface.
64
65 This interface is intended to be bound by the Xwayland server.
66
67 A compositor must not allow clients other than Xwayland to
68 bind to this interface. A compositor should hide this global
69 from other clients' wl_registry.
70 A client the compositor does not consider to be an Xwayland
71 server attempting to bind this interface will result in
72 an implementation-defined error.
73
74 An Xwayland server that has bound this interface must not
75 set the `WL_SURFACE_ID` atom on a window.
76 </description>
77
78 <enum name="error">
79 <entry name="role" value="0" summary="given wl_surface has another role"/>
80 </enum>
81
82 <request name="destroy" type="destructor">
83 <description summary="destroy the Xwayland shell object">
84 Destroy the xwayland_shell_v1 object.
85
86 The child objects created via this interface are unaffected.
87 </description>
88 </request>
89
90 <request name="get_xwayland_surface">
91 <description summary="assign the xwayland_surface surface role">
92 Create an xwayland_surface_v1 interface for a given wl_surface
93 object and gives it the xwayland_surface role.
94
95 It is illegal to create an xwayland_surface_v1 for a wl_surface
96 which already has an assigned role and this will result in the
97 `role` protocol error.
98
99 See the documentation of xwayland_surface_v1 for more details
100 about what an xwayland_surface_v1 is and how it is used.
101 </description>
102
103 <arg name="id" type="new_id" interface="xwayland_surface_v1"/>
104 <arg name="surface" type="object" interface="wl_surface"/>
105 </request>
106 </interface>
107
108 <interface name="xwayland_surface_v1" version="1">
109 <description summary="interface for associating Xwayland windows to wl_surfaces">
110 An Xwayland surface is a surface managed by an Xwayland server.
111 It is used for associating surfaces to Xwayland windows.
112
113 The Xwayland server associated with actions in this interface is
114 determined by the Wayland client making the request.
115
116 The client must call wl_surface.commit on the corresponding wl_surface
117 for the xwayland_surface_v1 state to take effect.
118 </description>
119
120 <enum name="error">
121 <entry name="already_associated" value="0" summary="given wl_surface is already associated with an X11 window"/>
122 <entry name="invalid_serial" value="1" summary="serial was not valid"/>
123 </enum>
124
125 <request name="set_serial">
126 <description summary="associates a Xwayland window to a wl_surface">
127 Associates an Xwayland window to a wl_surface.
128 The association state is double-buffered, see wl_surface.commit.
129
130 The `serial_lo` and `serial_hi` parameters specify a non-zero
131 monotonic serial number which is entirely unique and provided by the
132 Xwayland server equal to the serial value provided by a client message
133 with a message type of the `WL_SURFACE_SERIAL` atom on the X11 window
134 for this surface to be associated to.
135
136 The serial value in the `WL_SURFACE_SERIAL` client message is specified
137 as having the lo-bits specified in `l[0]` and the hi-bits specified
138 in `l[1]`.
139
140 If the serial value provided by `serial_lo` and `serial_hi` is not
141 valid, the `invalid_serial` protocol error will be raised.
142
143 An X11 window may be associated with multiple surfaces throughout its
144 lifespan. (eg. unmapping and remapping a window).
145
146 For each wl_surface, this state must not be committed more than once,
147 otherwise the `already_associated` protocol error will be raised.
148 </description>
149 <arg name="serial_lo" type="uint" summary="The lower 32-bits of the serial number associated with the X11 window"/>
150 <arg name="serial_hi" type="uint" summary="The upper 32-bits of the serial number associated with the X11 window"/>
151 </request>
152
153 <request name="destroy" type="destructor">
154 <description summary="destroy the Xwayland surface object">
155 Destroy the xwayland_surface_v1 object.
156
157 Any already existing associations are unaffected by this action.
158 </description>
159 </request>
160 </interface>
161</protocol>