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 | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 23 | #ifndef _WAYLAND_CLIENT_H |
| 24 | #define _WAYLAND_CLIENT_H |
| 25 | |
Kristian Høgsberg | b56cb00 | 2010-07-29 15:43:46 -0400 | [diff] [blame^] | 26 | #include "wayland-util.h" |
Kristian Høgsberg | 2d6b7c1 | 2010-06-25 16:51:57 -0400 | [diff] [blame] | 27 | |
Kristian Høgsberg | da6c6b1 | 2010-06-10 13:48:44 -0400 | [diff] [blame] | 28 | #ifdef __cplusplus |
| 29 | extern "C" { |
| 30 | #endif |
| 31 | |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 32 | struct wl_object; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 33 | struct wl_display; |
| 34 | struct wl_surface; |
Kristian Høgsberg | de31d5c | 2008-12-18 17:55:33 -0500 | [diff] [blame] | 35 | struct wl_visual; |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 36 | |
Kristian Høgsberg | fb59084 | 2008-11-07 14:27:23 -0500 | [diff] [blame] | 37 | #define WL_DISPLAY_READABLE 0x01 |
| 38 | #define WL_DISPLAY_WRITABLE 0x02 |
| 39 | |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 40 | int |
| 41 | wl_object_implements(struct wl_object *object, |
| 42 | const char *interface, int version); |
| 43 | |
Kristian Høgsberg | fb59084 | 2008-11-07 14:27:23 -0500 | [diff] [blame] | 44 | typedef int (*wl_display_update_func_t)(uint32_t mask, void *data); |
| 45 | |
Kristian Høgsberg | dc0f355 | 2008-12-07 15:22:22 -0500 | [diff] [blame] | 46 | struct wl_display *wl_display_create(const char *name, size_t name_size); |
Kristian Høgsberg | 427524a | 2008-10-08 13:32:07 -0400 | [diff] [blame] | 47 | void wl_display_destroy(struct wl_display *display); |
Kristian Høgsberg | fb59084 | 2008-11-07 14:27:23 -0500 | [diff] [blame] | 48 | int wl_display_get_fd(struct wl_display *display, |
| 49 | wl_display_update_func_t update, void *data); |
| 50 | |
Kristian Høgsberg | 427524a | 2008-10-08 13:32:07 -0400 | [diff] [blame] | 51 | void wl_display_iterate(struct wl_display *display, uint32_t mask); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 52 | |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 53 | struct wl_global_listener; |
| 54 | typedef void (*wl_display_global_func_t)(struct wl_display *display, |
| 55 | struct wl_object *object, |
| 56 | void *data); |
Kristian Høgsberg | ee02ca6 | 2008-12-21 23:37:12 -0500 | [diff] [blame] | 57 | void |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 58 | wl_display_remove_global_listener(struct wl_display *display, |
| 59 | struct wl_global_listener *listener); |
| 60 | |
| 61 | struct wl_global_listener * |
| 62 | wl_display_add_global_listener(struct wl_display *display, |
| 63 | wl_display_global_func_t handler, void *data); |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 64 | struct wl_compositor * |
| 65 | wl_display_get_compositor(struct wl_display *display); |
Kristian Høgsberg | de31d5c | 2008-12-18 17:55:33 -0500 | [diff] [blame] | 66 | struct wl_visual * |
| 67 | wl_display_get_argb_visual(struct wl_display *display); |
| 68 | struct wl_visual * |
| 69 | wl_display_get_premultiplied_argb_visual(struct wl_display *display); |
| 70 | struct wl_visual * |
| 71 | wl_display_get_rgb_visual(struct wl_display *display); |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 72 | |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 73 | struct wl_compositor_listener { |
Kristian Høgsberg | 478d926 | 2010-06-08 20:34:11 -0400 | [diff] [blame] | 74 | void (*device)(void *data, |
| 75 | struct wl_compositor *compositor, |
| 76 | const char *device); |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 77 | void (*acknowledge)(void *data, |
| 78 | struct wl_compositor *compositor, |
| 79 | uint32_t key, uint32_t frame); |
| 80 | void (*frame)(void *data, |
| 81 | struct wl_compositor *compositor, |
| 82 | uint32_t frame, uint32_t timestamp); |
| 83 | }; |
| 84 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 85 | struct wl_surface * |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 86 | wl_compositor_create_surface(struct wl_compositor *compositor); |
Kristian Høgsberg | 4097923 | 2008-11-25 22:40:39 -0500 | [diff] [blame] | 87 | void |
Kristian Høgsberg | d2412e2 | 2008-12-15 20:35:24 -0500 | [diff] [blame] | 88 | wl_compositor_commit(struct wl_compositor *compositor, uint32_t key); |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 89 | int |
| 90 | wl_compositor_add_listener(struct wl_compositor *compostior, |
| 91 | const struct wl_compositor_listener *listener, |
| 92 | void *data); |
| 93 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 94 | |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 95 | void wl_surface_destroy(struct wl_surface *surface); |
Kristian Høgsberg | de31d5c | 2008-12-18 17:55:33 -0500 | [diff] [blame] | 96 | void wl_surface_attach(struct wl_surface *surface, uint32_t name, |
| 97 | int32_t width, int32_t height, uint32_t stride, |
| 98 | struct wl_visual *visual); |
Kristian Høgsberg | 05eff51 | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 99 | void wl_surface_map(struct wl_surface *surface, |
| 100 | int32_t x, int32_t y, int32_t width, int32_t height); |
Kristian Høgsberg | 7f77bd8 | 2008-11-07 08:39:37 -0500 | [diff] [blame] | 101 | void wl_surface_damage(struct wl_surface *surface, |
| 102 | int32_t x, int32_t y, int32_t width, int32_t height); |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 103 | |
Kristian Høgsberg | ecf65fe | 2009-09-18 09:49:21 -0400 | [diff] [blame] | 104 | void wl_surface_set_user_data(struct wl_surface *surface, void *user_data); |
| 105 | void *wl_surface_get_user_data(struct wl_surface *surface); |
| 106 | |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 107 | struct wl_output; |
| 108 | struct wl_output_listener { |
| 109 | void (*geometry)(void *data, |
| 110 | struct wl_output *output, |
| 111 | int32_t width, int32_t height); |
| 112 | }; |
| 113 | |
| 114 | int |
| 115 | wl_output_add_listener(struct wl_output *output, |
| 116 | const struct wl_output_listener *listener, |
| 117 | void *data); |
| 118 | |
| 119 | struct wl_input_device; |
| 120 | struct wl_input_device_listener { |
| 121 | void (*motion)(void *data, |
| 122 | struct wl_input_device *input_device, |
Kristian Høgsberg | 808fd41 | 2010-07-20 17:06:19 -0400 | [diff] [blame] | 123 | uint32_t time, |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 124 | int32_t x, int32_t y, int32_t sx, int32_t sy); |
| 125 | void (*button)(void *data, |
| 126 | struct wl_input_device *input_device, |
Kristian Høgsberg | 808fd41 | 2010-07-20 17:06:19 -0400 | [diff] [blame] | 127 | uint32_t time, |
| 128 | uint32_t button, uint32_t state); |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 129 | void (*key)(void *data, |
| 130 | struct wl_input_device *input_device, |
Kristian Høgsberg | 808fd41 | 2010-07-20 17:06:19 -0400 | [diff] [blame] | 131 | uint32_t time, |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 132 | uint32_t button, uint32_t state); |
Kristian Høgsberg | db6c2f3 | 2009-02-22 21:51:24 -0500 | [diff] [blame] | 133 | void (*pointer_focus)(void *data, |
| 134 | struct wl_input_device *input_device, |
Kristian Høgsberg | 808fd41 | 2010-07-20 17:06:19 -0400 | [diff] [blame] | 135 | uint32_t time, |
Kristian Høgsberg | db6c2f3 | 2009-02-22 21:51:24 -0500 | [diff] [blame] | 136 | struct wl_surface *surface); |
| 137 | void (*keyboard_focus)(void *data, |
| 138 | struct wl_input_device *input_device, |
Kristian Høgsberg | 808fd41 | 2010-07-20 17:06:19 -0400 | [diff] [blame] | 139 | uint32_t time, |
Kristian Høgsberg | 3c38fa0 | 2009-02-23 22:30:29 -0500 | [diff] [blame] | 140 | struct wl_surface *surface, |
| 141 | struct wl_array *keys); |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | int |
| 145 | wl_input_device_add_listener(struct wl_input_device *input_device, |
| 146 | const struct wl_input_device_listener *listener, |
| 147 | void *data); |
| 148 | |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 149 | |
| 150 | /* These entry points are for client side implementation of custom |
| 151 | * objects. */ |
| 152 | |
| 153 | uint32_t wl_display_get_object_id(struct wl_display *display, |
Kristian Høgsberg | 8049cbb | 2008-12-21 22:50:32 -0500 | [diff] [blame] | 154 | const char *interface, uint32_t version); |
Kristian Høgsberg | 1e4b86a | 2008-11-23 23:41:08 -0500 | [diff] [blame] | 155 | uint32_t wl_display_allocate_id(struct wl_display *display); |
| 156 | void wl_display_write(struct wl_display *display, |
| 157 | const void *data, |
| 158 | size_t count); |
Kristian Høgsberg | 94448c0 | 2008-12-30 11:03:33 -0500 | [diff] [blame] | 159 | void wl_display_advertise_global(struct wl_display *display, |
| 160 | struct wl_object *object); |
Kristian Høgsberg | da6c6b1 | 2010-06-10 13:48:44 -0400 | [diff] [blame] | 161 | |
| 162 | #ifdef __cplusplus |
| 163 | } |
| 164 | #endif |
| 165 | |
Kristian Høgsberg | a67a71a | 2008-10-07 10:10:36 -0400 | [diff] [blame] | 166 | #endif |