Drop libdrm CFLAGS where no longer necessary.
[profile/ivi/wayland.git] / wayland.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_H
24 #define WAYLAND_H
25
26 #include <stdint.h>
27 #include "wayland-util.h"
28
29 enum {
30         WL_EVENT_READABLE = 0x01,
31         WL_EVENT_WRITEABLE = 0x02
32 };
33
34 struct wl_event_loop;
35 struct wl_event_source;
36 typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
37 typedef void (*wl_event_loop_timer_func_t)(void *data);
38 typedef void (*wl_event_loop_signal_func_t)(int signal_number, void *data);
39 typedef void (*wl_event_loop_idle_func_t)(void *data);
40
41 struct wl_event_loop *wl_event_loop_create(void);
42 void wl_event_loop_destroy(struct wl_event_loop *loop);
43 struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
44                                              int fd, uint32_t mask,
45                                              wl_event_loop_fd_func_t func,
46                                              void *data);
47 int wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask);
48 struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *loop,
49                                                 wl_event_loop_timer_func_t func,
50                                                 void *data);
51 struct wl_event_source *
52 wl_event_loop_add_signal(struct wl_event_loop *loop,
53                         int signal_number,
54                         wl_event_loop_signal_func_t func,
55                         void *data);
56
57 int wl_event_source_timer_update(struct wl_event_source *source,
58                                  int ms_delay);
59 int wl_event_source_remove(struct wl_event_source *source);
60
61
62 int wl_event_loop_wait(struct wl_event_loop *loop);
63 struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
64                                                wl_event_loop_idle_func_t func,
65                                                void *data);
66
67 struct wl_client;
68
69 struct wl_display;
70 struct wl_input_device;
71
72 struct wl_map {
73         int32_t x, y, width, height;
74 };
75
76 struct wl_display *wl_display_create(void);
77 struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
78 int wl_display_add_socket(struct wl_display *display, const char *name, size_t name_size);
79 void wl_display_run(struct wl_display *display);
80
81 void wl_display_add_object(struct wl_display *display, struct wl_object *object);
82
83 typedef void (*wl_client_connect_func_t)(struct wl_client *client, struct wl_object *global);
84
85 int wl_display_add_global(struct wl_display *display, struct wl_object *object, wl_client_connect_func_t func);
86
87 struct wl_compositor {
88         struct wl_object base;
89 };
90
91 struct wl_surface {
92         struct wl_object base;
93         struct wl_client *client;
94 };
95
96 struct wl_compositor_interface {
97         void (*create_surface)(struct wl_client *client,
98                                struct wl_compositor *compositor, uint32_t id);
99         void (*commit)(struct wl_client *client,
100                        struct wl_compositor *compositor, uint32_t key);
101 };
102
103 struct wl_surface_interface {
104         void (*destroy)(struct wl_client *client,
105                         struct wl_surface *surface);
106         void (*attach)(struct wl_client *client,
107                        struct wl_surface *surface, uint32_t name, 
108                        uint32_t width, uint32_t height, uint32_t stride,
109                        struct wl_object *visual);
110         void (*map)(struct wl_client *client,
111                     struct wl_surface *surface,
112                     int32_t x, int32_t y, int32_t width, int32_t height);
113         void (*copy)(struct wl_client *client, struct wl_surface *surface,
114                      int32_t dst_x, int32_t dst_y, uint32_t name, uint32_t stride,
115                      int32_t x, int32_t y, int32_t width, int32_t height);
116         void (*damage)(struct wl_client *client, struct wl_surface *surface,
117                        int32_t x, int32_t y, int32_t width, int32_t height);
118 };
119
120 void
121 wl_client_post_event(struct wl_client *client,
122                       struct wl_object *sender,
123                       uint32_t event, ...);
124
125 void
126 wl_surface_post_event(struct wl_surface *surface,
127                       struct wl_object *sender,
128                       uint32_t event, ...);
129
130 int
131 wl_display_set_compositor(struct wl_display *display,
132                           struct wl_compositor *compositor,
133                           const struct wl_compositor_interface *implementation);
134
135 int
136 wl_client_add_surface(struct wl_client *client,
137                       struct wl_surface *surface,
138                       const struct wl_surface_interface *implementation, 
139                       uint32_t id);
140
141 void
142 wl_client_send_acknowledge(struct wl_client *client,
143                            struct wl_compositor *compositor,
144                            uint32_t key, uint32_t frame);
145
146 void
147 wl_display_post_frame(struct wl_display *display,
148                       struct wl_compositor *compositor,
149                       uint32_t frame, uint32_t msecs);
150
151 #endif