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); |
Ray Strode | fe57347 | 2008-12-19 00:22:18 -0500 | [diff] [blame] | 38 | typedef void (*wl_event_loop_signal_func_t)(int signal_number, void *data); |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 39 | typedef void (*wl_event_loop_idle_func_t)(void *data); |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 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, |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 45 | wl_event_loop_fd_func_t func, |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 46 | void *data); |
Kristian Høgsberg | 4a29890 | 2008-11-28 18:35:25 -0500 | [diff] [blame] | 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); |
Ray Strode | fe57347 | 2008-12-19 00:22:18 -0500 | [diff] [blame] | 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 | |
Kristian Høgsberg | 4a29890 | 2008-11-28 18:35:25 -0500 | [diff] [blame] | 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); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 60 | |
Kristian Høgsberg | 4a29890 | 2008-11-28 18:35:25 -0500 | [diff] [blame] | 61 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 62 | int wl_event_loop_wait(struct wl_event_loop *loop); |
Kristian Høgsberg | 5ebb317 | 2008-10-11 19:21:35 -0400 | [diff] [blame] | 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); |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 66 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 67 | struct wl_client; |
| 68 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 69 | struct wl_display; |
Kristian Høgsberg | 5ee1a60 | 2008-12-11 23:18:45 -0500 | [diff] [blame] | 70 | struct wl_input_device; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 71 | |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 72 | struct wl_map { |
| 73 | int32_t x, y, width, height; |
| 74 | }; |
| 75 | |
Kristian Høgsberg | 122912c | 2008-12-05 11:13:50 -0500 | [diff] [blame] | 76 | struct wl_display *wl_display_create(void); |
| 77 | 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] | 78 | 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] | 79 | void wl_display_run(struct wl_display *display); |
| 80 | |
Kristian Høgsberg | fe831a7 | 2008-12-21 21:50:23 -0500 | [diff] [blame] | 81 | void wl_display_add_object(struct wl_display *display, struct wl_object *object); |
Kristian Høgsberg | ee02ca6 | 2008-12-21 23:37:12 -0500 | [diff] [blame] | 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); |
Kristian Høgsberg | 5a75c90 | 2008-12-10 13:16:50 -0500 | [diff] [blame] | 86 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 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; |
Kristian Høgsberg | b559fcb | 2009-09-18 17:00:37 -0400 | [diff] [blame] | 94 | struct wl_list link; |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | struct wl_compositor_interface { |
| 98 | void (*create_surface)(struct wl_client *client, |
| 99 | struct wl_compositor *compositor, uint32_t id); |
| 100 | void (*commit)(struct wl_client *client, |
| 101 | struct wl_compositor *compositor, uint32_t key); |
| 102 | }; |
| 103 | |
| 104 | struct wl_surface_interface { |
| 105 | void (*destroy)(struct wl_client *client, |
| 106 | struct wl_surface *surface); |
| 107 | void (*attach)(struct wl_client *client, |
| 108 | struct wl_surface *surface, uint32_t name, |
Kristian Høgsberg | de31d5c | 2008-12-18 17:55:33 -0500 | [diff] [blame] | 109 | uint32_t width, uint32_t height, uint32_t stride, |
| 110 | struct wl_object *visual); |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 111 | void (*map)(struct wl_client *client, |
| 112 | struct wl_surface *surface, |
| 113 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 114 | void (*copy)(struct wl_client *client, struct wl_surface *surface, |
| 115 | int32_t dst_x, int32_t dst_y, uint32_t name, uint32_t stride, |
| 116 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 117 | void (*damage)(struct wl_client *client, struct wl_surface *surface, |
| 118 | int32_t x, int32_t y, int32_t width, int32_t height); |
| 119 | }; |
| 120 | |
Kristian Høgsberg | 715a081 | 2008-12-10 10:42:04 -0500 | [diff] [blame] | 121 | void |
Kristian Høgsberg | ee02ca6 | 2008-12-21 23:37:12 -0500 | [diff] [blame] | 122 | wl_client_post_event(struct wl_client *client, |
| 123 | struct wl_object *sender, |
| 124 | uint32_t event, ...); |
| 125 | |
| 126 | void |
Kristian Høgsberg | 5a75c90 | 2008-12-10 13:16:50 -0500 | [diff] [blame] | 127 | wl_surface_post_event(struct wl_surface *surface, |
| 128 | struct wl_object *sender, |
| 129 | uint32_t event, ...); |
Kristian Høgsberg | f9bc795 | 2008-11-02 10:12:29 -0500 | [diff] [blame] | 130 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 131 | int |
| 132 | wl_display_set_compositor(struct wl_display *display, |
| 133 | struct wl_compositor *compositor, |
| 134 | const struct wl_compositor_interface *implementation); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 135 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 136 | int |
| 137 | wl_client_add_surface(struct wl_client *client, |
| 138 | struct wl_surface *surface, |
| 139 | const struct wl_surface_interface *implementation, |
| 140 | uint32_t id); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 141 | |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 142 | void |
Kristian Høgsberg | b559fcb | 2009-09-18 17:00:37 -0400 | [diff] [blame] | 143 | wl_client_remove_surface(struct wl_client *client, |
| 144 | struct wl_surface *surface); |
| 145 | |
| 146 | void |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 147 | wl_client_send_acknowledge(struct wl_client *client, |
| 148 | struct wl_compositor *compositor, |
| 149 | uint32_t key, uint32_t frame); |
| 150 | |
| 151 | void |
| 152 | wl_display_post_frame(struct wl_display *display, |
| 153 | struct wl_compositor *compositor, |
| 154 | uint32_t frame, uint32_t msecs); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 155 | |
Kristian Høgsberg | 97f1ebe | 2008-09-30 09:46:10 -0400 | [diff] [blame] | 156 | #endif |