Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 1 | #ifndef WAYLAND_H |
| 2 | #define WAYLAND_H |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Kristian Høgsberg | f9bc795 | 2008-11-02 10:12:29 -0500 | [diff] [blame] | 6 | #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) |
| 7 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 8 | enum { |
| 9 | WL_EVENT_READABLE = 0x01, |
| 10 | WL_EVENT_WRITEABLE = 0x02 |
| 11 | }; |
| 12 | |
| 13 | struct wl_event_loop; |
| 14 | struct wl_event_source; |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 15 | typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data); |
| 16 | typedef void (*wl_event_loop_idle_func_t)(void *data); |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 17 | |
| 18 | struct wl_event_loop *wl_event_loop_create(void); |
| 19 | void wl_event_loop_destroy(struct wl_event_loop *loop); |
| 20 | struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop, |
| 21 | int fd, uint32_t mask, |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 22 | wl_event_loop_fd_func_t func, |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 23 | void *data); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 24 | int wl_event_loop_update_source(struct wl_event_loop *loop, |
| 25 | struct wl_event_source *source, |
| 26 | uint32_t mask); |
| 27 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 28 | int wl_event_loop_remove_source(struct wl_event_loop *loop, |
| 29 | struct wl_event_source *source); |
| 30 | int wl_event_loop_wait(struct wl_event_loop *loop); |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 31 | struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop, |
| 32 | wl_event_loop_idle_func_t func, |
| 33 | void *data); |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 34 | |
| 35 | struct wl_hash { |
| 36 | struct wl_object **objects; |
| 37 | uint32_t count, alloc, id; |
| 38 | }; |
| 39 | |
| 40 | int wl_hash_insert(struct wl_hash *hash, struct wl_object *object); |
| 41 | struct wl_object *wl_hash_lookup(struct wl_hash *hash, uint32_t id); |
| 42 | void wl_hash_delete(struct wl_hash *hash, struct wl_object *object); |
| 43 | |
| 44 | struct wl_client; |
| 45 | |
| 46 | enum { |
| 47 | WL_ARGUMENT_UINT32, |
| 48 | WL_ARGUMENT_STRING, |
| 49 | WL_ARGUMENT_OBJECT, |
| 50 | WL_ARGUMENT_NEW_ID |
| 51 | }; |
| 52 | |
| 53 | struct wl_argument { |
| 54 | uint32_t type; |
| 55 | void *data; |
| 56 | }; |
| 57 | |
| 58 | struct wl_method { |
| 59 | const char *name; |
| 60 | void *func; |
| 61 | int argument_count; |
| 62 | const struct wl_argument *arguments; |
| 63 | }; |
| 64 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 65 | struct wl_event { |
| 66 | const char *name; |
| 67 | }; |
| 68 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 69 | struct wl_interface { |
| 70 | const char *name; |
| 71 | int version; |
| 72 | int method_count; |
| 73 | const struct wl_method *methods; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 74 | int event_count; |
| 75 | const struct wl_event *events; |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | struct wl_object { |
| 79 | const struct wl_interface *interface; |
| 80 | uint32_t id; |
| 81 | }; |
| 82 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 83 | struct wl_surface; |
| 84 | struct wl_display; |
| 85 | |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 86 | struct wl_map { |
| 87 | int32_t x, y, width, height; |
| 88 | }; |
| 89 | |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 90 | struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display); |
| 91 | |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 92 | void wl_surface_set_data(struct wl_surface *surface, void *data); |
| 93 | void *wl_surface_get_data(struct wl_surface *surface); |
| 94 | |
Kristian Høgsberg | f921289 | 2008-10-11 18:40:23 -0400 | [diff] [blame] | 95 | struct wl_surface_iterator; |
| 96 | struct wl_surface_iterator * |
| 97 | wl_surface_iterator_create(struct wl_display *display, uint32_t mask); |
| 98 | int wl_surface_iterator_next(struct wl_surface_iterator *iterator, |
| 99 | struct wl_surface **surface); |
| 100 | void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator); |
| 101 | |
Kristian Høgsberg | f9bc795 | 2008-11-02 10:12:29 -0500 | [diff] [blame] | 102 | struct wl_object * |
| 103 | wl_input_device_create(struct wl_display *display, |
| 104 | const char *path, uint32_t id); |
| 105 | void |
| 106 | wl_display_post_relative_event(struct wl_display *display, |
| 107 | struct wl_object *source, int dx, int dy); |
| 108 | void |
| 109 | wl_display_post_absolute_event(struct wl_display *display, |
| 110 | struct wl_object *source, int x, int y); |
| 111 | void |
| 112 | wl_display_post_button_event(struct wl_display *display, |
| 113 | struct wl_object *source, int button, int state); |
| 114 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 115 | struct wl_compositor { |
Kristian Høgsberg | 5503bf8 | 2008-11-06 10:38:17 -0500 | [diff] [blame^] | 116 | const struct wl_compositor_interface *interface; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | struct wl_compositor_interface { |
| 120 | void (*notify_surface_create)(struct wl_compositor *compositor, |
| 121 | struct wl_surface *surface); |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 122 | void (*notify_surface_destroy)(struct wl_compositor *compositor, |
| 123 | struct wl_surface *surface); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 124 | void (*notify_surface_attach)(struct wl_compositor *compositor, |
| 125 | struct wl_surface *surface, uint32_t name, |
| 126 | uint32_t width, uint32_t height, uint32_t stride); |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 127 | void (*notify_surface_map)(struct wl_compositor *compositor, |
| 128 | struct wl_surface *surface, struct wl_map *map); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 129 | }; |
| 130 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 131 | void wl_display_set_compositor(struct wl_display *display, |
| 132 | struct wl_compositor *compositor); |
| 133 | |
| 134 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 135 | #endif |