1 /* Generated by wayland-scanner 1.22.0 */
2
3 #ifndef VIEWPORTER_CLIENT_PROTOCOL_H
4 #define VIEWPORTER_CLIENT_PROTOCOL_H
5
6 #include <stdint.h>
7 #include <stddef.h>
8 #include "wayland-client.h"
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 /**
15 * @page page_viewporter The viewporter protocol
16 * @section page_ifaces_viewporter Interfaces
17 * - @subpage page_iface_wp_viewporter - surface cropping and scaling
18 * - @subpage page_iface_wp_viewport - crop and scale interface to a wl_surface
19 * @section page_copyright_viewporter Copyright
20 * <pre>
21 *
22 * Copyright © 2013-2016 Collabora, Ltd.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the "Software"),
26 * to deal in the Software without restriction, including without limitation
27 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28 * and/or sell copies of the Software, and to permit persons to whom the
29 * Software is furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice (including the next
32 * paragraph) shall be included in all copies or substantial portions of the
33 * Software.
34 *
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
40 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
41 * DEALINGS IN THE SOFTWARE.
42 * </pre>
43 */
44 struct wl_surface;
45 struct wp_viewport;
46 struct wp_viewporter;
47
48 #ifndef WP_VIEWPORTER_INTERFACE
49 #define WP_VIEWPORTER_INTERFACE
50 /**
51 * @page page_iface_wp_viewporter wp_viewporter
52 * @section page_iface_wp_viewporter_desc Description
53 *
54 * The global interface exposing surface cropping and scaling
55 * capabilities is used to instantiate an interface extension for a
56 * wl_surface object. This extended interface will then allow
57 * cropping and scaling the surface contents, effectively
58 * disconnecting the direct relationship between the buffer and the
59 * surface size.
60 * @section page_iface_wp_viewporter_api API
61 * See @ref iface_wp_viewporter.
62 */
63 /**
64 * @defgroup iface_wp_viewporter The wp_viewporter interface
65 *
66 * The global interface exposing surface cropping and scaling
67 * capabilities is used to instantiate an interface extension for a
68 * wl_surface object. This extended interface will then allow
69 * cropping and scaling the surface contents, effectively
70 * disconnecting the direct relationship between the buffer and the
71 * surface size.
72 */
73 extern const struct wl_interface wp_viewporter_interface;
74 #endif
75 #ifndef WP_VIEWPORT_INTERFACE
76 #define WP_VIEWPORT_INTERFACE
77 /**
78 * @page page_iface_wp_viewport wp_viewport
79 * @section page_iface_wp_viewport_desc Description
80 *
81 * An additional interface to a wl_surface object, which allows the
82 * client to specify the cropping and scaling of the surface
83 * contents.
84 *
85 * This interface works with two concepts: the source rectangle (src_x,
86 * src_y, src_width, src_height), and the destination size (dst_width,
87 * dst_height). The contents of the source rectangle are scaled to the
88 * destination size, and content outside the source rectangle is ignored.
89 * This state is double-buffered, and is applied on the next
90 * wl_surface.commit.
91 *
92 * The two parts of crop and scale state are independent: the source
93 * rectangle, and the destination size. Initially both are unset, that
94 * is, no scaling is applied. The whole of the current wl_buffer is
95 * used as the source, and the surface size is as defined in
96 * wl_surface.attach.
97 *
98 * If the destination size is set, it causes the surface size to become
99 * dst_width, dst_height. The source (rectangle) is scaled to exactly
100 * this size. This overrides whatever the attached wl_buffer size is,
101 * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
102 * has no content and therefore no size. Otherwise, the size is always
103 * at least 1x1 in surface local coordinates.
104 *
105 * If the source rectangle is set, it defines what area of the wl_buffer is
106 * taken as the source. If the source rectangle is set and the destination
107 * size is not set, then src_width and src_height must be integers, and the
108 * surface size becomes the source rectangle size. This results in cropping
109 * without scaling. If src_width or src_height are not integers and
110 * destination size is not set, the bad_size protocol error is raised when
111 * the surface state is applied.
112 *
113 * The coordinate transformations from buffer pixel coordinates up to
114 * the surface-local coordinates happen in the following order:
115 * 1. buffer_transform (wl_surface.set_buffer_transform)
116 * 2. buffer_scale (wl_surface.set_buffer_scale)
117 * 3. crop and scale (wp_viewport.set*)
118 * This means, that the source rectangle coordinates of crop and scale
119 * are given in the coordinates after the buffer transform and scale,
120 * i.e. in the coordinates that would be the surface-local coordinates
121 * if the crop and scale was not applied.
122 *
123 * If src_x or src_y are negative, the bad_value protocol error is raised.
124 * Otherwise, if the source rectangle is partially or completely outside of
125 * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
126 * when the surface state is applied. A NULL wl_buffer does not raise the
127 * out_of_buffer error.
128 *
129 * The x, y arguments of wl_surface.attach are applied as normal to
130 * the surface. They indicate how many pixels to remove from the
131 * surface size from the left and the top. In other words, they are
132 * still in the surface-local coordinate system, just like dst_width
133 * and dst_height are.
134 *
135 * If the wl_surface associated with the wp_viewport is destroyed,
136 * all wp_viewport requests except 'destroy' raise the protocol error
137 * no_surface.
138 *
139 * If the wp_viewport object is destroyed, the crop and scale
140 * state is removed from the wl_surface. The change will be applied
141 * on the next wl_surface.commit.
142 * @section page_iface_wp_viewport_api API
143 * See @ref iface_wp_viewport.
144 */
145 /**
146 * @defgroup iface_wp_viewport The wp_viewport interface
147 *
148 * An additional interface to a wl_surface object, which allows the
149 * client to specify the cropping and scaling of the surface
150 * contents.
151 *
152 * This interface works with two concepts: the source rectangle (src_x,
153 * src_y, src_width, src_height), and the destination size (dst_width,
154 * dst_height). The contents of the source rectangle are scaled to the
155 * destination size, and content outside the source rectangle is ignored.
156 * This state is double-buffered, and is applied on the next
157 * wl_surface.commit.
158 *
159 * The two parts of crop and scale state are independent: the source
160 * rectangle, and the destination size. Initially both are unset, that
161 * is, no scaling is applied. The whole of the current wl_buffer is
162 * used as the source, and the surface size is as defined in
163 * wl_surface.attach.
164 *
165 * If the destination size is set, it causes the surface size to become
166 * dst_width, dst_height. The source (rectangle) is scaled to exactly
167 * this size. This overrides whatever the attached wl_buffer size is,
168 * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
169 * has no content and therefore no size. Otherwise, the size is always
170 * at least 1x1 in surface local coordinates.
171 *
172 * If the source rectangle is set, it defines what area of the wl_buffer is
173 * taken as the source. If the source rectangle is set and the destination
174 * size is not set, then src_width and src_height must be integers, and the
175 * surface size becomes the source rectangle size. This results in cropping
176 * without scaling. If src_width or src_height are not integers and
177 * destination size is not set, the bad_size protocol error is raised when
178 * the surface state is applied.
179 *
180 * The coordinate transformations from buffer pixel coordinates up to
181 * the surface-local coordinates happen in the following order:
182 * 1. buffer_transform (wl_surface.set_buffer_transform)
183 * 2. buffer_scale (wl_surface.set_buffer_scale)
184 * 3. crop and scale (wp_viewport.set*)
185 * This means, that the source rectangle coordinates of crop and scale
186 * are given in the coordinates after the buffer transform and scale,
187 * i.e. in the coordinates that would be the surface-local coordinates
188 * if the crop and scale was not applied.
189 *
190 * If src_x or src_y are negative, the bad_value protocol error is raised.
191 * Otherwise, if the source rectangle is partially or completely outside of
192 * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
193 * when the surface state is applied. A NULL wl_buffer does not raise the
194 * out_of_buffer error.
195 *
196 * The x, y arguments of wl_surface.attach are applied as normal to
197 * the surface. They indicate how many pixels to remove from the
198 * surface size from the left and the top. In other words, they are
199 * still in the surface-local coordinate system, just like dst_width
200 * and dst_height are.
201 *
202 * If the wl_surface associated with the wp_viewport is destroyed,
203 * all wp_viewport requests except 'destroy' raise the protocol error
204 * no_surface.
205 *
206 * If the wp_viewport object is destroyed, the crop and scale
207 * state is removed from the wl_surface. The change will be applied
208 * on the next wl_surface.commit.
209 */
210 extern const struct wl_interface wp_viewport_interface;
211 #endif
212
213 #ifndef WP_VIEWPORTER_ERROR_ENUM
214 #define WP_VIEWPORTER_ERROR_ENUM
215 enum wp_viewporter_error {
216 /**
217 * the surface already has a viewport object associated
218 */
219 WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS = 0,
220 };
221 #endif /* WP_VIEWPORTER_ERROR_ENUM */
222
223 #define WP_VIEWPORTER_DESTROY 0
224 #define WP_VIEWPORTER_GET_VIEWPORT 1
225
226
227 /**
228 * @ingroup iface_wp_viewporter
229 */
230 #define WP_VIEWPORTER_DESTROY_SINCE_VERSION 1
231 /**
232 * @ingroup iface_wp_viewporter
233 */
234 #define WP_VIEWPORTER_GET_VIEWPORT_SINCE_VERSION 1
235
236 /** @ingroup iface_wp_viewporter */
237 static inline void
wp_viewporter_set_user_data(struct wp_viewporter * wp_viewporter,void * user_data)238 wp_viewporter_set_user_data(struct wp_viewporter *wp_viewporter, void *user_data)
239 {
240 wl_proxy_set_user_data((struct wl_proxy *) wp_viewporter, user_data);
241 }
242
243 /** @ingroup iface_wp_viewporter */
244 static inline void *
wp_viewporter_get_user_data(struct wp_viewporter * wp_viewporter)245 wp_viewporter_get_user_data(struct wp_viewporter *wp_viewporter)
246 {
247 return wl_proxy_get_user_data((struct wl_proxy *) wp_viewporter);
248 }
249
250 static inline uint32_t
wp_viewporter_get_version(struct wp_viewporter * wp_viewporter)251 wp_viewporter_get_version(struct wp_viewporter *wp_viewporter)
252 {
253 return wl_proxy_get_version((struct wl_proxy *) wp_viewporter);
254 }
255
256 /**
257 * @ingroup iface_wp_viewporter
258 *
259 * Informs the server that the client will not be using this
260 * protocol object anymore. This does not affect any other objects,
261 * wp_viewport objects included.
262 */
263 static inline void
wp_viewporter_destroy(struct wp_viewporter * wp_viewporter)264 wp_viewporter_destroy(struct wp_viewporter *wp_viewporter)
265 {
266 wl_proxy_marshal_flags((struct wl_proxy *) wp_viewporter,
267 WP_VIEWPORTER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewporter), WL_MARSHAL_FLAG_DESTROY);
268 }
269
270 /**
271 * @ingroup iface_wp_viewporter
272 *
273 * Instantiate an interface extension for the given wl_surface to
274 * crop and scale its content. If the given wl_surface already has
275 * a wp_viewport object associated, the viewport_exists
276 * protocol error is raised.
277 */
278 static inline struct wp_viewport *
wp_viewporter_get_viewport(struct wp_viewporter * wp_viewporter,struct wl_surface * surface)279 wp_viewporter_get_viewport(struct wp_viewporter *wp_viewporter, struct wl_surface *surface)
280 {
281 struct wl_proxy *id;
282
283 id = wl_proxy_marshal_flags((struct wl_proxy *) wp_viewporter,
284 WP_VIEWPORTER_GET_VIEWPORT, &wp_viewport_interface, wl_proxy_get_version((struct wl_proxy *) wp_viewporter), 0, NULL, surface);
285
286 return (struct wp_viewport *) id;
287 }
288
289 #ifndef WP_VIEWPORT_ERROR_ENUM
290 #define WP_VIEWPORT_ERROR_ENUM
291 enum wp_viewport_error {
292 /**
293 * negative or zero values in width or height
294 */
295 WP_VIEWPORT_ERROR_BAD_VALUE = 0,
296 /**
297 * destination size is not integer
298 */
299 WP_VIEWPORT_ERROR_BAD_SIZE = 1,
300 /**
301 * source rectangle extends outside of the content area
302 */
303 WP_VIEWPORT_ERROR_OUT_OF_BUFFER = 2,
304 /**
305 * the wl_surface was destroyed
306 */
307 WP_VIEWPORT_ERROR_NO_SURFACE = 3,
308 };
309 #endif /* WP_VIEWPORT_ERROR_ENUM */
310
311 #define WP_VIEWPORT_DESTROY 0
312 #define WP_VIEWPORT_SET_SOURCE 1
313 #define WP_VIEWPORT_SET_DESTINATION 2
314
315
316 /**
317 * @ingroup iface_wp_viewport
318 */
319 #define WP_VIEWPORT_DESTROY_SINCE_VERSION 1
320 /**
321 * @ingroup iface_wp_viewport
322 */
323 #define WP_VIEWPORT_SET_SOURCE_SINCE_VERSION 1
324 /**
325 * @ingroup iface_wp_viewport
326 */
327 #define WP_VIEWPORT_SET_DESTINATION_SINCE_VERSION 1
328
329 /** @ingroup iface_wp_viewport */
330 static inline void
wp_viewport_set_user_data(struct wp_viewport * wp_viewport,void * user_data)331 wp_viewport_set_user_data(struct wp_viewport *wp_viewport, void *user_data)
332 {
333 wl_proxy_set_user_data((struct wl_proxy *) wp_viewport, user_data);
334 }
335
336 /** @ingroup iface_wp_viewport */
337 static inline void *
wp_viewport_get_user_data(struct wp_viewport * wp_viewport)338 wp_viewport_get_user_data(struct wp_viewport *wp_viewport)
339 {
340 return wl_proxy_get_user_data((struct wl_proxy *) wp_viewport);
341 }
342
343 static inline uint32_t
wp_viewport_get_version(struct wp_viewport * wp_viewport)344 wp_viewport_get_version(struct wp_viewport *wp_viewport)
345 {
346 return wl_proxy_get_version((struct wl_proxy *) wp_viewport);
347 }
348
349 /**
350 * @ingroup iface_wp_viewport
351 *
352 * The associated wl_surface's crop and scale state is removed.
353 * The change is applied on the next wl_surface.commit.
354 */
355 static inline void
wp_viewport_destroy(struct wp_viewport * wp_viewport)356 wp_viewport_destroy(struct wp_viewport *wp_viewport)
357 {
358 wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport,
359 WP_VIEWPORT_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), WL_MARSHAL_FLAG_DESTROY);
360 }
361
362 /**
363 * @ingroup iface_wp_viewport
364 *
365 * Set the source rectangle of the associated wl_surface. See
366 * wp_viewport for the description, and relation to the wl_buffer
367 * size.
368 *
369 * If all of x, y, width and height are -1.0, the source rectangle is
370 * unset instead. Any other set of values where width or height are zero
371 * or negative, or x or y are negative, raise the bad_value protocol
372 * error.
373 *
374 * The crop and scale state is double-buffered state, and will be
375 * applied on the next wl_surface.commit.
376 */
377 static inline void
wp_viewport_set_source(struct wp_viewport * wp_viewport,wl_fixed_t x,wl_fixed_t y,wl_fixed_t width,wl_fixed_t height)378 wp_viewport_set_source(struct wp_viewport *wp_viewport, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height)
379 {
380 wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport,
381 WP_VIEWPORT_SET_SOURCE, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), 0, x, y, width, height);
382 }
383
384 /**
385 * @ingroup iface_wp_viewport
386 *
387 * Set the destination size of the associated wl_surface. See
388 * wp_viewport for the description, and relation to the wl_buffer
389 * size.
390 *
391 * If width is -1 and height is -1, the destination size is unset
392 * instead. Any other pair of values for width and height that
393 * contains zero or negative values raises the bad_value protocol
394 * error.
395 *
396 * The crop and scale state is double-buffered state, and will be
397 * applied on the next wl_surface.commit.
398 */
399 static inline void
wp_viewport_set_destination(struct wp_viewport * wp_viewport,int32_t width,int32_t height)400 wp_viewport_set_destination(struct wp_viewport *wp_viewport, int32_t width, int32_t height)
401 {
402 wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport,
403 WP_VIEWPORT_SET_DESTINATION, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), 0, width, height);
404 }
405
406 #ifdef __cplusplus
407 }
408 #endif
409
410 #endif
411