blob: f3358b40800e4d40081ad87e8f2278fca0244ea5 [file] [log] [blame]
Kristian Høgsbergffd710e2008-12-02 15:15:01 -05001/*
2 * Copyright © 2008 Kristian Høgsberg
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040023#include <stdlib.h>
24#include <stdint.h>
25#include <stddef.h>
26#include <stdio.h>
27#include <errno.h>
28#include <string.h>
29#include <unistd.h>
30#include <sys/socket.h>
31#include <sys/un.h>
32#include <ctype.h>
Kristian Høgsbergfe831a72008-12-21 21:50:23 -050033#include <assert.h>
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040034#include <sys/poll.h>
35
Kristian Høgsbergfe831a72008-12-21 21:50:23 -050036#include "wayland-protocol.h"
Kristian Høgsberg427524a2008-10-08 13:32:07 -040037#include "connection.h"
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050038#include "wayland-util.h"
Kristian Høgsberg427524a2008-10-08 13:32:07 -040039#include "wayland-client.h"
40
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040041static const char socket_name[] = "\0wayland";
42
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050043struct wl_global {
44 uint32_t id;
45 char *interface;
Kristian Høgsbergbf967b42008-12-21 20:25:16 -050046 uint32_t version;
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050047 struct wl_list link;
48};
49
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040050struct wl_proxy {
Kristian Høgsbergfe831a72008-12-21 21:50:23 -050051 const struct wl_interface *interface;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040052 uint32_t id;
Kristian Høgsbergfe831a72008-12-21 21:50:23 -050053 struct wl_display *display;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040054};
55
56struct wl_display {
57 struct wl_proxy proxy;
Kristian Høgsberg427524a2008-10-08 13:32:07 -040058 struct wl_connection *connection;
59 int fd;
Kristian Høgsberg97079ad2008-12-21 22:45:33 -050060 uint32_t id, id_count, next_range;
Kristian Høgsbergfb590842008-11-07 14:27:23 -050061 uint32_t mask;
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050062 struct wl_list global_list;
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -050063 struct wl_list visual_list;
Kristian Høgsbergfb590842008-11-07 14:27:23 -050064
65 wl_display_update_func_t update;
66 void *update_data;
Kristian Høgsberg5a27f3e2008-11-02 10:55:25 -050067
68 wl_display_event_func_t event_handler;
69 void *event_handler_data;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040070};
71
Kristian Høgsbergd2412e22008-12-15 20:35:24 -050072struct wl_compositor {
73 struct wl_proxy proxy;
74};
75
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040076struct wl_surface {
77 struct wl_proxy proxy;
78};
79
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -050080struct wl_visual {
81 struct wl_proxy proxy;
82 struct wl_list link;
83};
84
Kristian Høgsbergfb590842008-11-07 14:27:23 -050085static int
86connection_update(struct wl_connection *connection,
87 uint32_t mask, void *data)
88{
89 struct wl_display *display = data;
90
91 display->mask = mask;
92 if (display->update)
93 return display->update(display->mask,
94 display->update_data);
95
96 return 0;
97}
98
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -050099static void
100add_visual(struct wl_display *display, struct wl_global *global)
101{
102 struct wl_visual *visual;
103
104 visual = malloc(sizeof *visual);
105 if (visual == NULL)
106 return;
107
108 visual->proxy.display = display;
109 visual->proxy.id = global->id;
110 wl_list_insert(display->visual_list.prev, &visual->link);
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -0500111}
112
113WL_EXPORT struct wl_visual *
114wl_display_get_argb_visual(struct wl_display *display)
115{
116 return container_of(display->visual_list.next,
117 struct wl_visual, link);
118}
119
120WL_EXPORT struct wl_visual *
121wl_display_get_premultiplied_argb_visual(struct wl_display *display)
122{
123 return container_of(display->visual_list.next->next,
124 struct wl_visual, link);
125}
126
127WL_EXPORT struct wl_visual *
128wl_display_get_rgb_visual(struct wl_display *display)
129{
130 /* FIXME: Where's cddar when you need it... */
131
132 return container_of(display->visual_list.next->next->next,
133 struct wl_visual, link);
134}
135
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500136WL_EXPORT struct wl_display *
Kristian Høgsbergdc0f3552008-12-07 15:22:22 -0500137wl_display_create(const char *name, size_t name_size)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400138{
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400139 struct wl_display *display;
Kristian Høgsbergdc0f3552008-12-07 15:22:22 -0500140 struct sockaddr_un addr;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400141 socklen_t size;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400142
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400143 display = malloc(sizeof *display);
144 if (display == NULL)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400145 return NULL;
146
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400147 memset(display, 0, sizeof *display);
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400148 display->fd = socket(PF_LOCAL, SOCK_STREAM, 0);
149 if (display->fd < 0) {
150 free(display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400151 return NULL;
152 }
153
Kristian Høgsbergdc0f3552008-12-07 15:22:22 -0500154 addr.sun_family = AF_LOCAL;
155 memcpy(addr.sun_path, name, name_size);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400156
Kristian Høgsbergdc0f3552008-12-07 15:22:22 -0500157 size = offsetof (struct sockaddr_un, sun_path) + name_size;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400158
Kristian Høgsbergdc0f3552008-12-07 15:22:22 -0500159 if (connect(display->fd, (struct sockaddr *) &addr, size) < 0) {
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400160 close(display->fd);
161 free(display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400162 return NULL;
163 }
164
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500165 wl_list_init(&display->global_list);
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -0500166 wl_list_init(&display->visual_list);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400167
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500168 display->proxy.interface = &wl_display_interface;
Kristian Høgsberg8049cbb2008-12-21 22:50:32 -0500169 display->proxy.id = wl_display_get_object_id(display, "display", 1);
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500170 display->proxy.display = display;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400171
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400172 display->connection = wl_connection_create(display->fd,
Kristian Høgsbergfb590842008-11-07 14:27:23 -0500173 connection_update,
174 display);
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400175
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500176 /* Process connection events. */
177 wl_display_iterate(display, WL_CONNECTION_READABLE);
178
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400179 return display;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400180}
181
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500182WL_EXPORT void
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400183wl_display_destroy(struct wl_display *display)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400184{
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400185 wl_connection_destroy(display->connection);
186 close(display->fd);
187 free(display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400188}
189
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500190WL_EXPORT uint32_t
Kristian Høgsberg8049cbb2008-12-21 22:50:32 -0500191wl_display_get_object_id(struct wl_display *display,
192 const char *interface, uint32_t version)
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500193{
194 struct wl_global *global;
195
196 global = container_of(display->global_list.next,
197 struct wl_global, link);
198 while (&global->link != &display->global_list) {
Kristian Høgsberg8049cbb2008-12-21 22:50:32 -0500199 if (strcmp(global->interface, interface) == 0 &&
200 global->version >= version)
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500201 return global->id;
202
203 global = container_of(global->link.next,
204 struct wl_global, link);
205 }
206
207 return 0;
208}
209
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500210WL_EXPORT int
Kristian Høgsbergfb590842008-11-07 14:27:23 -0500211wl_display_get_fd(struct wl_display *display,
212 wl_display_update_func_t update, void *data)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400213{
Kristian Høgsbergfb590842008-11-07 14:27:23 -0500214 display->update = update;
215 display->update_data = data;
216
217 display->update(display->mask, display->update_data);
218
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400219 return display->fd;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400220}
221
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500222static void
Kristian Høgsberg97079ad2008-12-21 22:45:33 -0500223handle_display_event(struct wl_display *display,
224 uint32_t opcode, uint32_t *p, uint32_t size)
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500225{
226 struct wl_global *global;
227 uint32_t length;
228
Kristian Høgsberg97079ad2008-12-21 22:45:33 -0500229 switch (opcode) {
230 case WL_DISPLAY_INVALID_OBJECT:
231 fprintf(stderr, "sent request to invalid object\n");
232 break;
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500233
Kristian Høgsberg97079ad2008-12-21 22:45:33 -0500234 case WL_DISPLAY_INVALID_METHOD:
235 fprintf(stderr, "sent invalid request opcode\n");
236 break;
237
238 case WL_DISPLAY_NO_MEMORY:
239 fprintf(stderr, "server out of memory\n");
240 break;
241
242 case WL_DISPLAY_GLOBAL:
243 global = malloc(sizeof *global);
244 if (global == NULL)
245 return;
246
247 global->id = p[0];
248 length = p[1];
249 global->interface = malloc(length + 1);
250 if (global->interface == NULL) {
251 free(global);
252 return;
253 }
254 memcpy(global->interface, &p[2], length);
255 global->interface[length] = '\0';
256 global->version = p[2 + DIV_ROUNDUP(length, sizeof *p)];
257 wl_list_insert(display->global_list.prev, &global->link);
258
259 if (strcmp(global->interface, "visual") == 0)
260 add_visual(display, global);
261 break;
262
263 case WL_DISPLAY_RANGE:
264 display->next_range = p[0];
265 break;
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500266 }
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500267}
268
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400269static void
Kristian Høgsberg40979232008-11-25 22:40:39 -0500270handle_event(struct wl_display *display,
271 uint32_t object, uint32_t opcode, uint32_t size)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400272{
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500273 uint32_t p[32];
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400274
Kristian Høgsberg5a27f3e2008-11-02 10:55:25 -0500275 wl_connection_copy(display->connection, p, size);
Kristian Høgsberg97079ad2008-12-21 22:45:33 -0500276 if (object == 1) {
277 handle_display_event(display, opcode, p + 2, size);
Kristian Høgsbergbf967b42008-12-21 20:25:16 -0500278 } else if (display->event_handler != NULL)
Kristian Høgsberg40979232008-11-25 22:40:39 -0500279 display->event_handler(display, object, opcode, size, p + 2,
Kristian Høgsberg5a27f3e2008-11-02 10:55:25 -0500280 display->event_handler_data);
281 wl_connection_consume(display->connection, size);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400282}
283
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500284WL_EXPORT void
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400285wl_display_iterate(struct wl_display *display, uint32_t mask)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400286{
Kristian Høgsberg40979232008-11-25 22:40:39 -0500287 uint32_t p[2], object, opcode, size;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400288 int len;
289
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400290 len = wl_connection_data(display->connection, mask);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400291 while (len > 0) {
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400292 if (len < sizeof p)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400293 break;
294
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400295 wl_connection_copy(display->connection, p, sizeof p);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500296 object = p[0];
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400297 opcode = p[1] & 0xffff;
298 size = p[1] >> 16;
Kristian Høgsberg427524a2008-10-08 13:32:07 -0400299 if (len < size)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400300 break;
301
Kristian Høgsberg40979232008-11-25 22:40:39 -0500302 handle_event(display, object, opcode, size);
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500303 len -= size;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400304 }
305
306 if (len < 0) {
307 fprintf(stderr, "read error: %m\n");
308 exit(EXIT_FAILURE);
309 }
310}
311
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500312WL_EXPORT void
Kristian Høgsberg5a27f3e2008-11-02 10:55:25 -0500313wl_display_set_event_handler(struct wl_display *display,
314 wl_display_event_func_t handler,
315 void *data)
316{
317 /* FIXME: This needs something more generic... */
318 display->event_handler = handler;
319 display->event_handler_data = data;
320}
321
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500322WL_EXPORT uint32_t
323wl_display_allocate_id(struct wl_display *display)
324{
Kristian Høgsberg97079ad2008-12-21 22:45:33 -0500325 if (display->id_count == 0) {
326 display->id_count = 256;
327 display->id = display->next_range;
328 }
329
330 display->id_count--;
331
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500332 return display->id++;
333}
334
335WL_EXPORT void
336wl_display_write(struct wl_display *display, const void *data, size_t count)
337{
338 wl_connection_write(display->connection, data, count);
339}
340
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500341WL_EXPORT struct wl_compositor *
342wl_display_get_compositor(struct wl_display *display)
343{
344 struct wl_compositor *compositor;
345 uint32_t id;
346
Kristian Høgsberg8049cbb2008-12-21 22:50:32 -0500347 id = wl_display_get_object_id(display, "compositor", 1);
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500348 if (id == 0)
349 return NULL;
350
351 compositor = malloc(sizeof *compositor);
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500352 compositor->proxy.interface = &wl_compositor_interface;
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500353 compositor->proxy.id = id;
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500354 compositor->proxy.display = display;
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500355
356 return compositor;
357}
358
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500359static void
360wl_proxy_vmarshal(struct wl_proxy *target, uint32_t opcode, va_list ap)
361{
362 struct wl_proxy *proxy;
363 uint32_t args[32], length, *p, size;
364 const char *s, *signature;
365 int i, count;
366
367 signature = target->interface->methods[opcode].signature;
368 count = strlen(signature);
369 /* FIXME: Make sure we don't overwrite args array. */
370
371 p = &args[2];
372 for (i = 0; i < count; i++) {
373 switch (signature[i]) {
374 case 'u':
375 case 'i':
376 *p++ = va_arg(ap, uint32_t);
377 break;
378 case 's':
379 s = va_arg(ap, const char *);
380 length = strlen(s);
381 *p++ = length;
382 memcpy(p, s, length);
383 p += DIV_ROUNDUP(length, sizeof(*p));
384 break;
385 case 'n':
386 case 'o':
387 proxy = va_arg(ap, struct wl_proxy *);
388 *p++ = proxy->id;
389 break;
390 default:
391 assert(0);
392 break;
393 }
394 }
395
396 size = (p - args) * sizeof *p;
397 args[0] = target->id;
398 args[1] = opcode | (size << 16);
399 wl_connection_write(target->display->connection, args, size);
400}
401
402static void
403wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
404{
405 va_list ap;
406
407 va_start(ap, opcode);
408 wl_proxy_vmarshal(proxy, opcode, ap);
409 va_end(ap);
410}
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400411
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500412WL_EXPORT struct wl_surface *
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500413wl_compositor_create_surface(struct wl_compositor *compositor)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400414{
415 struct wl_surface *surface;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400416
417 surface = malloc(sizeof *surface);
418 if (surface == NULL)
419 return NULL;
420
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500421 surface->proxy.interface = &wl_surface_interface;
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500422 surface->proxy.id = wl_display_allocate_id(compositor->proxy.display);
423 surface->proxy.display = compositor->proxy.display;
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500424 wl_proxy_marshal(&compositor->proxy,
425 WL_COMPOSITOR_CREATE_SURFACE, surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400426
427 return surface;
428}
429
Kristian Høgsberg40979232008-11-25 22:40:39 -0500430WL_EXPORT void
Kristian Høgsbergd2412e22008-12-15 20:35:24 -0500431wl_compositor_commit(struct wl_compositor *compositor, uint32_t key)
Kristian Høgsberg40979232008-11-25 22:40:39 -0500432{
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500433 wl_proxy_marshal(&compositor->proxy, WL_COMPOSITOR_COMMIT, key);
Kristian Høgsberg40979232008-11-25 22:40:39 -0500434}
435
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500436WL_EXPORT void
437wl_surface_destroy(struct wl_surface *surface)
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400438{
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500439 wl_proxy_marshal(&surface->proxy, WL_SURFACE_DESTROY);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400440}
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400441
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500442WL_EXPORT void
443wl_surface_attach(struct wl_surface *surface, uint32_t name,
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -0500444 int32_t width, int32_t height, uint32_t stride,
445 struct wl_visual *visual)
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400446{
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500447 wl_proxy_marshal(&surface->proxy, WL_SURFACE_ATTACH,
448 name, width, height, stride, visual);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400449}
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400450
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500451WL_EXPORT void
452wl_surface_map(struct wl_surface *surface,
453 int32_t x, int32_t y, int32_t width, int32_t height)
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400454{
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500455 wl_proxy_marshal(&surface->proxy,
456 WL_SURFACE_MAP, x, y, width, height);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400457}
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500458
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500459WL_EXPORT void
460wl_surface_copy(struct wl_surface *surface, int32_t dst_x, int32_t dst_y,
461 uint32_t name, uint32_t stride,
462 int32_t x, int32_t y, int32_t width, int32_t height)
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500463{
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500464 wl_proxy_marshal(&surface->proxy, WL_SURFACE_COPY,
465 dst_x, dst_y, name, stride, x, y, width, height);
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500466}
467
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500468WL_EXPORT void
469wl_surface_damage(struct wl_surface *surface,
470 int32_t x, int32_t y, int32_t width, int32_t height)
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500471{
Kristian Høgsbergfe831a72008-12-21 21:50:23 -0500472 wl_proxy_marshal(&surface->proxy,
473 WL_SURFACE_DAMAGE, x, y, width, height);
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500474}