wayland-viewporter-client-protocol.h (14737B)
1 /* Generated by wayland-scanner */ 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 /** 49 * @page page_iface_wp_viewporter wp_viewporter 50 * @section page_iface_wp_viewporter_desc Description 51 * 52 * The global interface exposing surface cropping and scaling 53 * capabilities is used to instantiate an interface extension for a 54 * wl_surface object. This extended interface will then allow 55 * cropping and scaling the surface contents, effectively 56 * disconnecting the direct relationship between the buffer and the 57 * surface size. 58 * @section page_iface_wp_viewporter_api API 59 * See @ref iface_wp_viewporter. 60 */ 61 /** 62 * @defgroup iface_wp_viewporter The wp_viewporter interface 63 * 64 * The global interface exposing surface cropping and scaling 65 * capabilities is used to instantiate an interface extension for a 66 * wl_surface object. This extended interface will then allow 67 * cropping and scaling the surface contents, effectively 68 * disconnecting the direct relationship between the buffer and the 69 * surface size. 70 */ 71 extern const struct wl_interface wp_viewporter_interface; 72 /** 73 * @page page_iface_wp_viewport wp_viewport 74 * @section page_iface_wp_viewport_desc Description 75 * 76 * An additional interface to a wl_surface object, which allows the 77 * client to specify the cropping and scaling of the surface 78 * contents. 79 * 80 * This interface works with two concepts: the source rectangle (src_x, 81 * src_y, src_width, src_height), and the destination size (dst_width, 82 * dst_height). The contents of the source rectangle are scaled to the 83 * destination size, and content outside the source rectangle is ignored. 84 * This state is double-buffered, and is applied on the next 85 * wl_surface.commit. 86 * 87 * The two parts of crop and scale state are independent: the source 88 * rectangle, and the destination size. Initially both are unset, that 89 * is, no scaling is applied. The whole of the current wl_buffer is 90 * used as the source, and the surface size is as defined in 91 * wl_surface.attach. 92 * 93 * If the destination size is set, it causes the surface size to become 94 * dst_width, dst_height. The source (rectangle) is scaled to exactly 95 * this size. This overrides whatever the attached wl_buffer size is, 96 * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface 97 * has no content and therefore no size. Otherwise, the size is always 98 * at least 1x1 in surface local coordinates. 99 * 100 * If the source rectangle is set, it defines what area of the wl_buffer is 101 * taken as the source. If the source rectangle is set and the destination 102 * size is not set, then src_width and src_height must be integers, and the 103 * surface size becomes the source rectangle size. This results in cropping 104 * without scaling. If src_width or src_height are not integers and 105 * destination size is not set, the bad_size protocol error is raised when 106 * the surface state is applied. 107 * 108 * The coordinate transformations from buffer pixel coordinates up to 109 * the surface-local coordinates happen in the following order: 110 * 1. buffer_transform (wl_surface.set_buffer_transform) 111 * 2. buffer_scale (wl_surface.set_buffer_scale) 112 * 3. crop and scale (wp_viewport.set*) 113 * This means, that the source rectangle coordinates of crop and scale 114 * are given in the coordinates after the buffer transform and scale, 115 * i.e. in the coordinates that would be the surface-local coordinates 116 * if the crop and scale was not applied. 117 * 118 * If src_x or src_y are negative, the bad_value protocol error is raised. 119 * Otherwise, if the source rectangle is partially or completely outside of 120 * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised 121 * when the surface state is applied. A NULL wl_buffer does not raise the 122 * out_of_buffer error. 123 * 124 * The x, y arguments of wl_surface.attach are applied as normal to 125 * the surface. They indicate how many pixels to remove from the 126 * surface size from the left and the top. In other words, they are 127 * still in the surface-local coordinate system, just like dst_width 128 * and dst_height are. 129 * 130 * If the wl_surface associated with the wp_viewport is destroyed, 131 * all wp_viewport requests except 'destroy' raise the protocol error 132 * no_surface. 133 * 134 * If the wp_viewport object is destroyed, the crop and scale 135 * state is removed from the wl_surface. The change will be applied 136 * on the next wl_surface.commit. 137 * @section page_iface_wp_viewport_api API 138 * See @ref iface_wp_viewport. 139 */ 140 /** 141 * @defgroup iface_wp_viewport The wp_viewport interface 142 * 143 * An additional interface to a wl_surface object, which allows the 144 * client to specify the cropping and scaling of the surface 145 * contents. 146 * 147 * This interface works with two concepts: the source rectangle (src_x, 148 * src_y, src_width, src_height), and the destination size (dst_width, 149 * dst_height). The contents of the source rectangle are scaled to the 150 * destination size, and content outside the source rectangle is ignored. 151 * This state is double-buffered, and is applied on the next 152 * wl_surface.commit. 153 * 154 * The two parts of crop and scale state are independent: the source 155 * rectangle, and the destination size. Initially both are unset, that 156 * is, no scaling is applied. The whole of the current wl_buffer is 157 * used as the source, and the surface size is as defined in 158 * wl_surface.attach. 159 * 160 * If the destination size is set, it causes the surface size to become 161 * dst_width, dst_height. The source (rectangle) is scaled to exactly 162 * this size. This overrides whatever the attached wl_buffer size is, 163 * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface 164 * has no content and therefore no size. Otherwise, the size is always 165 * at least 1x1 in surface local coordinates. 166 * 167 * If the source rectangle is set, it defines what area of the wl_buffer is 168 * taken as the source. If the source rectangle is set and the destination 169 * size is not set, then src_width and src_height must be integers, and the 170 * surface size becomes the source rectangle size. This results in cropping 171 * without scaling. If src_width or src_height are not integers and 172 * destination size is not set, the bad_size protocol error is raised when 173 * the surface state is applied. 174 * 175 * The coordinate transformations from buffer pixel coordinates up to 176 * the surface-local coordinates happen in the following order: 177 * 1. buffer_transform (wl_surface.set_buffer_transform) 178 * 2. buffer_scale (wl_surface.set_buffer_scale) 179 * 3. crop and scale (wp_viewport.set*) 180 * This means, that the source rectangle coordinates of crop and scale 181 * are given in the coordinates after the buffer transform and scale, 182 * i.e. in the coordinates that would be the surface-local coordinates 183 * if the crop and scale was not applied. 184 * 185 * If src_x or src_y are negative, the bad_value protocol error is raised. 186 * Otherwise, if the source rectangle is partially or completely outside of 187 * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised 188 * when the surface state is applied. A NULL wl_buffer does not raise the 189 * out_of_buffer error. 190 * 191 * The x, y arguments of wl_surface.attach are applied as normal to 192 * the surface. They indicate how many pixels to remove from the 193 * surface size from the left and the top. In other words, they are 194 * still in the surface-local coordinate system, just like dst_width 195 * and dst_height are. 196 * 197 * If the wl_surface associated with the wp_viewport is destroyed, 198 * all wp_viewport requests except 'destroy' raise the protocol error 199 * no_surface. 200 * 201 * If the wp_viewport object is destroyed, the crop and scale 202 * state is removed from the wl_surface. The change will be applied 203 * on the next wl_surface.commit. 204 */ 205 extern const struct wl_interface wp_viewport_interface; 206 207 #ifndef WP_VIEWPORTER_ERROR_ENUM 208 #define WP_VIEWPORTER_ERROR_ENUM 209 enum wp_viewporter_error { 210 /** 211 * the surface already has a viewport object associated 212 */ 213 WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS = 0, 214 }; 215 #endif /* WP_VIEWPORTER_ERROR_ENUM */ 216 217 #define WP_VIEWPORTER_DESTROY 0 218 #define WP_VIEWPORTER_GET_VIEWPORT 1 219 220 221 /** 222 * @ingroup iface_wp_viewporter 223 */ 224 #define WP_VIEWPORTER_DESTROY_SINCE_VERSION 1 225 /** 226 * @ingroup iface_wp_viewporter 227 */ 228 #define WP_VIEWPORTER_GET_VIEWPORT_SINCE_VERSION 1 229 230 /** @ingroup iface_wp_viewporter */ 231 static inline void 232 wp_viewporter_set_user_data(struct wp_viewporter *wp_viewporter, void *user_data) 233 { 234 wl_proxy_set_user_data((struct wl_proxy *) wp_viewporter, user_data); 235 } 236 237 /** @ingroup iface_wp_viewporter */ 238 static inline void * 239 wp_viewporter_get_user_data(struct wp_viewporter *wp_viewporter) 240 { 241 return wl_proxy_get_user_data((struct wl_proxy *) wp_viewporter); 242 } 243 244 static inline uint32_t 245 wp_viewporter_get_version(struct wp_viewporter *wp_viewporter) 246 { 247 return wl_proxy_get_version((struct wl_proxy *) wp_viewporter); 248 } 249 250 /** 251 * @ingroup iface_wp_viewporter 252 * 253 * Informs the server that the client will not be using this 254 * protocol object anymore. This does not affect any other objects, 255 * wp_viewport objects included. 256 */ 257 static inline void 258 wp_viewporter_destroy(struct wp_viewporter *wp_viewporter) 259 { 260 wl_proxy_marshal((struct wl_proxy *) wp_viewporter, 261 WP_VIEWPORTER_DESTROY); 262 263 wl_proxy_destroy((struct wl_proxy *) wp_viewporter); 264 } 265 266 /** 267 * @ingroup iface_wp_viewporter 268 * 269 * Instantiate an interface extension for the given wl_surface to 270 * crop and scale its content. If the given wl_surface already has 271 * a wp_viewport object associated, the viewport_exists 272 * protocol error is raised. 273 */ 274 static inline struct wp_viewport * 275 wp_viewporter_get_viewport(struct wp_viewporter *wp_viewporter, struct wl_surface *surface) 276 { 277 struct wl_proxy *id; 278 279 id = wl_proxy_marshal_constructor((struct wl_proxy *) wp_viewporter, 280 WP_VIEWPORTER_GET_VIEWPORT, &wp_viewport_interface, NULL, surface); 281 282 return (struct wp_viewport *) id; 283 } 284 285 #ifndef WP_VIEWPORT_ERROR_ENUM 286 #define WP_VIEWPORT_ERROR_ENUM 287 enum wp_viewport_error { 288 /** 289 * negative or zero values in width or height 290 */ 291 WP_VIEWPORT_ERROR_BAD_VALUE = 0, 292 /** 293 * destination size is not integer 294 */ 295 WP_VIEWPORT_ERROR_BAD_SIZE = 1, 296 /** 297 * source rectangle extends outside of the content area 298 */ 299 WP_VIEWPORT_ERROR_OUT_OF_BUFFER = 2, 300 /** 301 * the wl_surface was destroyed 302 */ 303 WP_VIEWPORT_ERROR_NO_SURFACE = 3, 304 }; 305 #endif /* WP_VIEWPORT_ERROR_ENUM */ 306 307 #define WP_VIEWPORT_DESTROY 0 308 #define WP_VIEWPORT_SET_SOURCE 1 309 #define WP_VIEWPORT_SET_DESTINATION 2 310 311 312 /** 313 * @ingroup iface_wp_viewport 314 */ 315 #define WP_VIEWPORT_DESTROY_SINCE_VERSION 1 316 /** 317 * @ingroup iface_wp_viewport 318 */ 319 #define WP_VIEWPORT_SET_SOURCE_SINCE_VERSION 1 320 /** 321 * @ingroup iface_wp_viewport 322 */ 323 #define WP_VIEWPORT_SET_DESTINATION_SINCE_VERSION 1 324 325 /** @ingroup iface_wp_viewport */ 326 static inline void 327 wp_viewport_set_user_data(struct wp_viewport *wp_viewport, void *user_data) 328 { 329 wl_proxy_set_user_data((struct wl_proxy *) wp_viewport, user_data); 330 } 331 332 /** @ingroup iface_wp_viewport */ 333 static inline void * 334 wp_viewport_get_user_data(struct wp_viewport *wp_viewport) 335 { 336 return wl_proxy_get_user_data((struct wl_proxy *) wp_viewport); 337 } 338 339 static inline uint32_t 340 wp_viewport_get_version(struct wp_viewport *wp_viewport) 341 { 342 return wl_proxy_get_version((struct wl_proxy *) wp_viewport); 343 } 344 345 /** 346 * @ingroup iface_wp_viewport 347 * 348 * The associated wl_surface's crop and scale state is removed. 349 * The change is applied on the next wl_surface.commit. 350 */ 351 static inline void 352 wp_viewport_destroy(struct wp_viewport *wp_viewport) 353 { 354 wl_proxy_marshal((struct wl_proxy *) wp_viewport, 355 WP_VIEWPORT_DESTROY); 356 357 wl_proxy_destroy((struct wl_proxy *) wp_viewport); 358 } 359 360 /** 361 * @ingroup iface_wp_viewport 362 * 363 * Set the source rectangle of the associated wl_surface. See 364 * wp_viewport for the description, and relation to the wl_buffer 365 * size. 366 * 367 * If all of x, y, width and height are -1.0, the source rectangle is 368 * unset instead. Any other set of values where width or height are zero 369 * or negative, or x or y are negative, raise the bad_value protocol 370 * error. 371 * 372 * The crop and scale state is double-buffered state, and will be 373 * applied on the next wl_surface.commit. 374 */ 375 static inline void 376 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) 377 { 378 wl_proxy_marshal((struct wl_proxy *) wp_viewport, 379 WP_VIEWPORT_SET_SOURCE, x, y, width, height); 380 } 381 382 /** 383 * @ingroup iface_wp_viewport 384 * 385 * Set the destination size of the associated wl_surface. See 386 * wp_viewport for the description, and relation to the wl_buffer 387 * size. 388 * 389 * If width is -1 and height is -1, the destination size is unset 390 * instead. Any other pair of values for width and height that 391 * contains zero or negative values raises the bad_value protocol 392 * error. 393 * 394 * The crop and scale state is double-buffered state, and will be 395 * applied on the next wl_surface.commit. 396 */ 397 static inline void 398 wp_viewport_set_destination(struct wp_viewport *wp_viewport, int32_t width, int32_t height) 399 { 400 wl_proxy_marshal((struct wl_proxy *) wp_viewport, 401 WP_VIEWPORT_SET_DESTINATION, width, height); 402 } 403 404 #ifdef __cplusplus 405 } 406 #endif 407 408 #endif