blob: dbe89703bb4a799d8731edcfa5b40e97e6ee005d [file] [log] [blame]
Kristian Høgsbergffd710e2008-12-02 15:15:01 -05001/*
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øgsberga67a71a2008-10-07 10:10:36 -040023#ifndef _WAYLAND_CLIENT_H
24#define _WAYLAND_CLIENT_H
25
Kristian Høgsbergda6c6b12010-06-10 13:48:44 -040026#ifdef __cplusplus
27extern "C" {
28#endif
29
Kristian Høgsberg94448c02008-12-30 11:03:33 -050030struct wl_object;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040031struct wl_display;
32struct wl_surface;
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -050033struct wl_visual;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040034
Kristian Høgsbergfb590842008-11-07 14:27:23 -050035#define WL_DISPLAY_READABLE 0x01
36#define WL_DISPLAY_WRITABLE 0x02
37
Kristian Høgsberg94448c02008-12-30 11:03:33 -050038int
39wl_object_implements(struct wl_object *object,
40 const char *interface, int version);
41
Kristian Høgsbergfb590842008-11-07 14:27:23 -050042typedef int (*wl_display_update_func_t)(uint32_t mask, void *data);
43
Kristian Høgsbergdc0f3552008-12-07 15:22:22 -050044struct wl_display *wl_display_create(const char *name, size_t name_size);
Kristian Høgsberg427524a2008-10-08 13:32:07 -040045void wl_display_destroy(struct wl_display *display);
Kristian Høgsbergfb590842008-11-07 14:27:23 -050046int wl_display_get_fd(struct wl_display *display,
47 wl_display_update_func_t update, void *data);
48
Kristian Høgsberg427524a2008-10-08 13:32:07 -040049void wl_display_iterate(struct wl_display *display, uint32_t mask);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040050
Kristian Høgsberg94448c02008-12-30 11:03:33 -050051struct wl_global_listener;
52typedef void (*wl_display_global_func_t)(struct wl_display *display,
53 struct wl_object *object,
54 void *data);
Kristian Høgsbergee02ca62008-12-21 23:37:12 -050055void
Kristian Høgsberg94448c02008-12-30 11:03:33 -050056wl_display_remove_global_listener(struct wl_display *display,
57 struct wl_global_listener *listener);
58
59struct wl_global_listener *
60wl_display_add_global_listener(struct wl_display *display,
61 wl_display_global_func_t handler, void *data);
Kristian Høgsbergd2412e22008-12-15 20:35:24 -050062struct wl_compositor *
63wl_display_get_compositor(struct wl_display *display);
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -050064struct wl_visual *
65wl_display_get_argb_visual(struct wl_display *display);
66struct wl_visual *
67wl_display_get_premultiplied_argb_visual(struct wl_display *display);
68struct wl_visual *
69wl_display_get_rgb_visual(struct wl_display *display);
Kristian Høgsbergd2412e22008-12-15 20:35:24 -050070
Kristian Høgsberg94448c02008-12-30 11:03:33 -050071struct wl_compositor_listener {
Kristian Høgsberg478d9262010-06-08 20:34:11 -040072 void (*device)(void *data,
73 struct wl_compositor *compositor,
74 const char *device);
Kristian Høgsberg94448c02008-12-30 11:03:33 -050075 void (*acknowledge)(void *data,
76 struct wl_compositor *compositor,
77 uint32_t key, uint32_t frame);
78 void (*frame)(void *data,
79 struct wl_compositor *compositor,
80 uint32_t frame, uint32_t timestamp);
81};
82
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040083struct wl_surface *
Kristian Høgsbergd2412e22008-12-15 20:35:24 -050084wl_compositor_create_surface(struct wl_compositor *compositor);
Kristian Høgsberg40979232008-11-25 22:40:39 -050085void
Kristian Høgsbergd2412e22008-12-15 20:35:24 -050086wl_compositor_commit(struct wl_compositor *compositor, uint32_t key);
Kristian Høgsberg94448c02008-12-30 11:03:33 -050087int
88wl_compositor_add_listener(struct wl_compositor *compostior,
89 const struct wl_compositor_listener *listener,
90 void *data);
91
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040092
Kristian Høgsberg05eff512008-10-07 10:10:36 -040093void wl_surface_destroy(struct wl_surface *surface);
Kristian Høgsbergde31d5c2008-12-18 17:55:33 -050094void wl_surface_attach(struct wl_surface *surface, uint32_t name,
95 int32_t width, int32_t height, uint32_t stride,
96 struct wl_visual *visual);
Kristian Høgsberg05eff512008-10-07 10:10:36 -040097void wl_surface_map(struct wl_surface *surface,
98 int32_t x, int32_t y, int32_t width, int32_t height);
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -050099void wl_surface_damage(struct wl_surface *surface,
100 int32_t x, int32_t y, int32_t width, int32_t height);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400101
Kristian Høgsbergecf65fe2009-09-18 09:49:21 -0400102void wl_surface_set_user_data(struct wl_surface *surface, void *user_data);
103void *wl_surface_get_user_data(struct wl_surface *surface);
104
Kristian Høgsberg94448c02008-12-30 11:03:33 -0500105struct wl_output;
106struct wl_output_listener {
107 void (*geometry)(void *data,
108 struct wl_output *output,
109 int32_t width, int32_t height);
110};
111
112int
113wl_output_add_listener(struct wl_output *output,
114 const struct wl_output_listener *listener,
115 void *data);
116
117struct wl_input_device;
118struct wl_input_device_listener {
119 void (*motion)(void *data,
120 struct wl_input_device *input_device,
121 int32_t x, int32_t y, int32_t sx, int32_t sy);
122 void (*button)(void *data,
123 struct wl_input_device *input_device,
124 uint32_t button, uint32_t state,
125 int32_t x, int32_t y, int32_t sx, int32_t sy);
126 void (*key)(void *data,
127 struct wl_input_device *input_device,
128 uint32_t button, uint32_t state);
Kristian Høgsbergdb6c2f32009-02-22 21:51:24 -0500129 void (*pointer_focus)(void *data,
130 struct wl_input_device *input_device,
131 struct wl_surface *surface);
132 void (*keyboard_focus)(void *data,
133 struct wl_input_device *input_device,
Kristian Høgsberg3c38fa02009-02-23 22:30:29 -0500134 struct wl_surface *surface,
135 struct wl_array *keys);
Kristian Høgsberg94448c02008-12-30 11:03:33 -0500136};
137
138int
139wl_input_device_add_listener(struct wl_input_device *input_device,
140 const struct wl_input_device_listener *listener,
141 void *data);
142
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500143
144/* These entry points are for client side implementation of custom
145 * objects. */
146
147uint32_t wl_display_get_object_id(struct wl_display *display,
Kristian Høgsberg8049cbb2008-12-21 22:50:32 -0500148 const char *interface, uint32_t version);
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500149uint32_t wl_display_allocate_id(struct wl_display *display);
150void wl_display_write(struct wl_display *display,
151 const void *data,
152 size_t count);
Kristian Høgsberg94448c02008-12-30 11:03:33 -0500153void wl_display_advertise_global(struct wl_display *display,
154 struct wl_object *object);
Kristian Høgsbergda6c6b12010-06-10 13:48:44 -0400155
156#ifdef __cplusplus
157}
158#endif
159
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400160#endif