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; |
| 76 | void *func; |
Kristian Høgsberg | 87e0a38 | 2008-12-05 10:38:42 -0500 | [diff] [blame] | 77 | const char *signature; |
| 78 | const void **types; |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 79 | }; |
| 80 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 81 | struct wl_event { |
| 82 | const char *name; |
Kristian Høgsberg | 87e0a38 | 2008-12-05 10:38:42 -0500 | [diff] [blame] | 83 | const char *signature; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 84 | }; |
| 85 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 86 | struct wl_interface { |
| 87 | const char *name; |
| 88 | int version; |
| 89 | int method_count; |
| 90 | const struct wl_method *methods; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 91 | int event_count; |
| 92 | const struct wl_event *events; |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | struct wl_object { |
| 96 | const struct wl_interface *interface; |
| 97 | uint32_t id; |
| 98 | }; |
| 99 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 100 | struct wl_surface; |
| 101 | struct wl_display; |
| 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 | |
| 107 | void wl_surface_set_data(struct wl_surface *surface, void *data); |
| 108 | void *wl_surface_get_data(struct wl_surface *surface); |
| 109 | |
Kristian Høgsberg | f921289 | 2008-10-11 18:40:23 -0400 | [diff] [blame] | 110 | struct wl_surface_iterator; |
| 111 | struct wl_surface_iterator * |
| 112 | wl_surface_iterator_create(struct wl_display *display, uint32_t mask); |
| 113 | int wl_surface_iterator_next(struct wl_surface_iterator *iterator, |
| 114 | struct wl_surface **surface); |
| 115 | void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator); |
| 116 | |
Kristian Høgsberg | f9bc795 | 2008-11-02 10:12:29 -0500 | [diff] [blame] | 117 | struct wl_object * |
Kristian Høgsberg | cddc0ad | 2008-11-24 00:31:49 -0500 | [diff] [blame] | 118 | wl_input_device_create(struct wl_display *display, const char *path); |
| 119 | |
Kristian Høgsberg | 122912c | 2008-12-05 11:13:50 -0500 | [diff] [blame] | 120 | struct wl_display *wl_display_create(void); |
| 121 | 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^] | 122 | 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] | 123 | void wl_display_run(struct wl_display *display); |
| 124 | |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 125 | void |
| 126 | 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] | 127 | int |
| 128 | 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] | 129 | |
Kristian Høgsberg | f9bc795 | 2008-11-02 10:12:29 -0500 | [diff] [blame] | 130 | void |
| 131 | wl_display_post_relative_event(struct wl_display *display, |
| 132 | struct wl_object *source, int dx, int dy); |
| 133 | void |
| 134 | wl_display_post_absolute_event(struct wl_display *display, |
| 135 | struct wl_object *source, int x, int y); |
| 136 | void |
| 137 | wl_display_post_button_event(struct wl_display *display, |
| 138 | struct wl_object *source, int button, int state); |
Kristian Høgsberg | cddc0ad | 2008-11-24 00:31:49 -0500 | [diff] [blame] | 139 | void |
| 140 | wl_display_post_key_event(struct wl_display *display, |
| 141 | struct wl_object *source, int key, int state); |
Kristian Høgsberg | 44f36e3 | 2008-11-26 12:57:31 -0500 | [diff] [blame] | 142 | void |
Kristian Høgsberg | fbdbbdc | 2008-11-28 17:06:06 -0500 | [diff] [blame] | 143 | wl_display_post_frame(struct wl_display *display, |
| 144 | uint32_t frame, uint32_t msecs); |
Kristian Høgsberg | f9bc795 | 2008-11-02 10:12:29 -0500 | [diff] [blame] | 145 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 146 | struct wl_compositor { |
Kristian Høgsberg | 5503bf8 | 2008-11-06 10:38:17 -0500 | [diff] [blame] | 147 | const struct wl_compositor_interface *interface; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | struct wl_compositor_interface { |
| 151 | void (*notify_surface_create)(struct wl_compositor *compositor, |
| 152 | struct wl_surface *surface); |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 153 | void (*notify_surface_destroy)(struct wl_compositor *compositor, |
| 154 | struct wl_surface *surface); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 155 | void (*notify_surface_attach)(struct wl_compositor *compositor, |
Kristian Høgsberg | 7f77bd8 | 2008-11-07 08:39:37 -0500 | [diff] [blame] | 156 | struct wl_surface *surface, |
| 157 | uint32_t name, |
| 158 | uint32_t width, uint32_t height, |
| 159 | uint32_t stride); |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 160 | void (*notify_surface_map)(struct wl_compositor *compositor, |
Kristian Høgsberg | 7f77bd8 | 2008-11-07 08:39:37 -0500 | [diff] [blame] | 161 | struct wl_surface *surface, |
| 162 | struct wl_map *map); |
| 163 | void (*notify_surface_copy)(struct wl_compositor *compositor, |
| 164 | struct wl_surface *surface, |
| 165 | int32_t dst_x, int32_t dst_y, |
| 166 | uint32_t name, uint32_t stride, |
| 167 | int32_t x, int32_t y, |
| 168 | int32_t width, int32_t height); |
| 169 | void (*notify_surface_damage)(struct wl_compositor *compositor, |
| 170 | struct wl_surface *surface, |
| 171 | int32_t x, int32_t y, |
| 172 | int32_t width, int32_t height); |
Kristian Høgsberg | fbdbbdc | 2008-11-28 17:06:06 -0500 | [diff] [blame] | 173 | uint32_t (*notify_commit)(struct wl_compositor *compositor); |
Kristian Høgsberg | 4c9f2c9 | 2008-11-21 19:25:44 -0500 | [diff] [blame] | 174 | void (*notify_pointer_motion)(struct wl_compositor *compositor, |
| 175 | struct wl_object *source, |
| 176 | int32_t x, int32_t y); |
Kristian Høgsberg | cddc0ad | 2008-11-24 00:31:49 -0500 | [diff] [blame] | 177 | void (*notify_key)(struct wl_compositor *compositor, |
| 178 | struct wl_object *source, |
| 179 | uint32_t key, uint32_t state); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 180 | }; |
| 181 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 182 | void wl_display_set_compositor(struct wl_display *display, |
| 183 | struct wl_compositor *compositor); |
| 184 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 185 | #endif |