Kristian Høgsberg | ffd710e | 2008-12-02 15:15:01 -0500 | [diff] [blame] | 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 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 23 | #ifndef WAYLAND_H |
| 24 | #define WAYLAND_H |
| 25 | |
| 26 | #include <stdint.h> |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 27 | #include "wayland-util.h" |
Kristian Høgsberg | b7a0192 | 2008-11-08 15:39:41 -0500 | [diff] [blame] | 28 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 29 | enum { |
| 30 | WL_EVENT_READABLE = 0x01, |
| 31 | WL_EVENT_WRITEABLE = 0x02 |
| 32 | }; |
| 33 | |
| 34 | struct wl_event_loop; |
| 35 | struct wl_event_source; |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 36 | typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data); |
Kristian Høgsberg | 4a29890 | 2008-11-28 18:35:25 -0500 | [diff] [blame] | 37 | typedef void (*wl_event_loop_timer_func_t)(void *data); |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 38 | typedef void (*wl_event_loop_idle_func_t)(void *data); |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 39 | |
| 40 | struct wl_event_loop *wl_event_loop_create(void); |
| 41 | void wl_event_loop_destroy(struct wl_event_loop *loop); |
| 42 | struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop, |
| 43 | int fd, uint32_t mask, |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 44 | wl_event_loop_fd_func_t func, |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 45 | void *data); |
Kristian Høgsberg | 4a29890 | 2008-11-28 18:35:25 -0500 | [diff] [blame] | 46 | int wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask); |
| 47 | struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *loop, |
| 48 | wl_event_loop_timer_func_t func, |
| 49 | void *data); |
| 50 | int wl_event_source_timer_update(struct wl_event_source *source, |
| 51 | int ms_delay); |
| 52 | int wl_event_source_remove(struct wl_event_source *source); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 53 | |
Kristian Høgsberg | 4a29890 | 2008-11-28 18:35:25 -0500 | [diff] [blame] | 54 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 55 | int wl_event_loop_wait(struct wl_event_loop *loop); |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 56 | struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop, |
| 57 | wl_event_loop_idle_func_t func, |
| 58 | void *data); |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 59 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 60 | struct wl_client; |
| 61 | |
| 62 | enum { |
| 63 | WL_ARGUMENT_UINT32, |
| 64 | WL_ARGUMENT_STRING, |
| 65 | WL_ARGUMENT_OBJECT, |
| 66 | WL_ARGUMENT_NEW_ID |
| 67 | }; |
| 68 | |
| 69 | struct wl_argument { |
| 70 | uint32_t type; |
| 71 | void *data; |
| 72 | }; |
| 73 | |
| 74 | struct wl_method { |
| 75 | const char *name; |
Kristian Høgsberg | 87e0a38 | 2008-12-05 10:38:42 -0500 | [diff] [blame] | 76 | const char *signature; |
| 77 | const void **types; |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 78 | }; |
| 79 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 80 | struct wl_event { |
| 81 | const char *name; |
Kristian Høgsberg | 87e0a38 | 2008-12-05 10:38:42 -0500 | [diff] [blame] | 82 | const char *signature; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 83 | }; |
| 84 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 85 | struct wl_interface { |
| 86 | const char *name; |
| 87 | int version; |
| 88 | int method_count; |
| 89 | const struct wl_method *methods; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 90 | int event_count; |
| 91 | const struct wl_event *events; |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | struct wl_object { |
| 95 | const struct wl_interface *interface; |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 96 | void (**implementation)(void); |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 97 | uint32_t id; |
| 98 | }; |
| 99 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 100 | struct wl_display; |
Kristian Høgsberg | 5ee1a60 | 2008-12-11 23:18:45 -0500 | [diff] [blame] | 101 | struct wl_input_device; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 102 | |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 103 | struct wl_map { |
| 104 | int32_t x, y, width, height; |
| 105 | }; |
| 106 | |
Kristian Høgsberg | 122912c | 2008-12-05 11:13:50 -0500 | [diff] [blame] | 107 | struct wl_display *wl_display_create(void); |
| 108 | struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display); |
Kristian Høgsberg | dc0f355 | 2008-12-07 15:22:22 -0500 | [diff] [blame] | 109 | int wl_display_add_socket(struct wl_display *display, const char *name, size_t name_size); |
Kristian Høgsberg | 122912c | 2008-12-05 11:13:50 -0500 | [diff] [blame] | 110 | void wl_display_run(struct wl_display *display); |
| 111 | |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 112 | void |
| 113 | wl_display_add_object(struct wl_display *display, struct wl_object *object); |
Kristian Høgsberg | 14fcff7 | 2008-11-23 19:10:23 -0500 | [diff] [blame] | 114 | int |
| 115 | wl_display_add_global(struct wl_display *display, struct wl_object *object); |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 116 | |
Kristian Høgsberg | 5ee1a60 | 2008-12-11 23:18:45 -0500 | [diff] [blame] | 117 | const struct wl_interface * |
| 118 | wl_input_device_get_interface(void); |
| 119 | |
Kristian Høgsberg | 5a75c90 | 2008-12-10 13:16:50 -0500 | [diff] [blame] | 120 | #define WL_INPUT_MOTION 0 |
| 121 | #define WL_INPUT_BUTTON 1 |
| 122 | #define WL_INPUT_KEY 2 |
| 123 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 124 | struct wl_compositor { |
| 125 | struct wl_object base; |
| 126 | }; |
| 127 | |
| 128 | struct wl_surface { |
| 129 | struct wl_object base; |
| 130 | struct wl_client *client; |
| 131 | }; |
| 132 | |
| 133 | struct wl_compositor_interface { |
| 134 | void (*create_surface)(struct wl_client *client, |
| 135 | struct wl_compositor *compositor, uint32_t id); |
| 136 | void (*commit)(struct wl_client *client, |
| 137 | struct wl_compositor *compositor, uint32_t key); |
| 138 | }; |
| 139 | |
| 140 | struct wl_surface_interface { |
| 141 | void (*destroy)(struct wl_client *client, |
| 142 | struct wl_surface *surface); |
| 143 | void (*attach)(struct wl_client *client, |
| 144 | struct wl_surface *surface, uint32_t name, |
Kristian Høgsberg | de31d5c | 2008-12-18 17:55:33 -0500 | [diff] [blame^] | 145 | uint32_t width, uint32_t height, uint32_t stride, |
| 146 | struct wl_object *visual); |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 147 | void (*map)(struct wl_client *client, |
| 148 | struct wl_surface *surface, |
| 149 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 150 | void (*copy)(struct wl_client *client, struct wl_surface *surface, |
| 151 | int32_t dst_x, int32_t dst_y, uint32_t name, uint32_t stride, |
| 152 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 153 | void (*damage)(struct wl_client *client, struct wl_surface *surface, |
| 154 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 155 | }; |
| 156 | |
Kristian Høgsberg | 715a081 | 2008-12-10 10:42:04 -0500 | [diff] [blame] | 157 | void |
Kristian Høgsberg | 5a75c90 | 2008-12-10 13:16:50 -0500 | [diff] [blame] | 158 | wl_surface_post_event(struct wl_surface *surface, |
| 159 | struct wl_object *sender, |
| 160 | uint32_t event, ...); |
Kristian Høgsberg | f9bc795 | 2008-11-02 10:12:29 -0500 | [diff] [blame] | 161 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 162 | int |
| 163 | wl_display_set_compositor(struct wl_display *display, |
| 164 | struct wl_compositor *compositor, |
| 165 | const struct wl_compositor_interface *implementation); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 166 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 167 | int |
| 168 | wl_client_add_surface(struct wl_client *client, |
| 169 | struct wl_surface *surface, |
| 170 | const struct wl_surface_interface *implementation, |
| 171 | uint32_t id); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 172 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 173 | void |
| 174 | wl_client_send_acknowledge(struct wl_client *client, |
| 175 | struct wl_compositor *compositor, |
| 176 | uint32_t key, uint32_t frame); |
| 177 | |
| 178 | void |
| 179 | wl_display_post_frame(struct wl_display *display, |
| 180 | struct wl_compositor *compositor, |
| 181 | uint32_t frame, uint32_t msecs); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 182 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 183 | #endif |