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