482e32ddc99469480725e2ae08d52d51aa41ed5b
[platform/upstream/weston.git] / wayland-client.h
1 /*
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
23 #ifndef _WAYLAND_CLIENT_H
24 #define _WAYLAND_CLIENT_H
25
26 #include "wayland-util.h"
27 #include "wayland-client-protocol.h"
28
29 #ifdef  __cplusplus
30 extern "C" {
31 #endif
32
33 #define WL_DISPLAY_READABLE 0x01
34 #define WL_DISPLAY_WRITABLE 0x02
35
36 int
37 wl_object_implements(struct wl_object *object,
38                      const char *interface, int version);
39
40 typedef int (*wl_display_update_func_t)(uint32_t mask, void *data);
41
42 struct wl_display *wl_display_create(const char *name, size_t name_size);
43 void wl_display_destroy(struct wl_display *display);
44 int wl_display_get_fd(struct wl_display *display,
45                       wl_display_update_func_t update, void *data);
46
47 void wl_display_iterate(struct wl_display *display, uint32_t mask);
48
49 struct wl_global_listener;
50 typedef void (*wl_display_global_func_t)(struct wl_display *display,
51                                          struct wl_object *object,
52                                          void *data);
53 void
54 wl_display_remove_global_listener(struct wl_display *display,
55                                   struct wl_global_listener *listener);
56
57 struct wl_global_listener *
58 wl_display_add_global_listener(struct wl_display *display,
59                                wl_display_global_func_t handler, void *data);
60 struct wl_compositor *
61 wl_display_get_compositor(struct wl_display *display);
62 struct wl_visual *
63 wl_display_get_argb_visual(struct wl_display *display);
64 struct wl_visual *
65 wl_display_get_premultiplied_argb_visual(struct wl_display *display);
66 struct wl_visual *
67 wl_display_get_rgb_visual(struct wl_display *display);
68
69 struct wl_surface *
70 wl_compositor_create_surface(struct wl_compositor *compositor);
71 void
72 wl_compositor_commit(struct wl_compositor *compositor, uint32_t key);
73 int
74 wl_compositor_add_listener(struct wl_compositor *compostior,
75                            const struct wl_compositor_listener *listener,
76                            void *data);
77
78
79 void wl_surface_destroy(struct wl_surface *surface);
80 void wl_surface_attach(struct wl_surface *surface, uint32_t name,
81                        int32_t width, int32_t height, uint32_t stride,
82                        struct wl_visual *visual);
83 void wl_surface_map(struct wl_surface *surface,
84                     int32_t x, int32_t y, int32_t width, int32_t height);
85 void wl_surface_damage(struct wl_surface *surface,
86                        int32_t x, int32_t y, int32_t width, int32_t height);
87
88 void wl_surface_set_user_data(struct wl_surface *surface, void *user_data);
89 void *wl_surface_get_user_data(struct wl_surface *surface);
90
91 int
92 wl_output_add_listener(struct wl_output *output,
93                        const struct wl_output_listener *listener,
94                        void *data);
95
96 int
97 wl_input_device_add_listener(struct wl_input_device *input_device,
98                              const struct wl_input_device_listener *listener,
99                              void *data);
100
101
102 /* These entry points are for client side implementation of custom
103  * objects. */
104
105 uint32_t wl_display_get_object_id(struct wl_display *display,
106                                   const char *interface, uint32_t version);
107 uint32_t wl_display_allocate_id(struct wl_display *display);
108 void wl_display_write(struct wl_display *display,
109                       const void *data,
110                       size_t count);
111 void wl_display_advertise_global(struct wl_display *display,
112                                  struct wl_object *object);
113
114 #ifdef  __cplusplus
115 }
116 #endif
117
118 #endif