blob: c13e3be8a424b768ee65d7f3a2666cc02148c123 [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øgsberg97f1ebe2008-09-30 09:46:10 -040023#ifndef WAYLAND_H
24#define WAYLAND_H
25
26#include <stdint.h>
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050027#include "wayland-util.h"
Kristian Høgsbergb7a01922008-11-08 15:39:41 -050028
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040029enum {
30 WL_EVENT_READABLE = 0x01,
31 WL_EVENT_WRITEABLE = 0x02
32};
33
34struct wl_event_loop;
35struct wl_event_source;
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040036typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
Kristian Høgsberg4a298902008-11-28 18:35:25 -050037typedef void (*wl_event_loop_timer_func_t)(void *data);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040038typedef void (*wl_event_loop_idle_func_t)(void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040039
40struct wl_event_loop *wl_event_loop_create(void);
41void wl_event_loop_destroy(struct wl_event_loop *loop);
42struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
43 int fd, uint32_t mask,
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040044 wl_event_loop_fd_func_t func,
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040045 void *data);
Kristian Høgsberg4a298902008-11-28 18:35:25 -050046int wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask);
47struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *loop,
48 wl_event_loop_timer_func_t func,
49 void *data);
50int wl_event_source_timer_update(struct wl_event_source *source,
51 int ms_delay);
52int wl_event_source_remove(struct wl_event_source *source);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040053
Kristian Høgsberg4a298902008-11-28 18:35:25 -050054
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040055int wl_event_loop_wait(struct wl_event_loop *loop);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040056struct 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øgsberg97f1ebe2008-09-30 09:46:10 -040059
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040060struct wl_client;
61
62enum {
63 WL_ARGUMENT_UINT32,
64 WL_ARGUMENT_STRING,
65 WL_ARGUMENT_OBJECT,
66 WL_ARGUMENT_NEW_ID
67};
68
69struct wl_argument {
70 uint32_t type;
71 void *data;
72};
73
74struct wl_method {
75 const char *name;
76 void *func;
Kristian Høgsberg87e0a382008-12-05 10:38:42 -050077 const char *signature;
78 const void **types;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040079};
80
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040081struct wl_event {
82 const char *name;
Kristian Høgsberg87e0a382008-12-05 10:38:42 -050083 const char *signature;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040084};
85
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040086struct wl_interface {
87 const char *name;
88 int version;
89 int method_count;
90 const struct wl_method *methods;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040091 int event_count;
92 const struct wl_event *events;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040093};
94
95struct wl_object {
96 const struct wl_interface *interface;
97 uint32_t id;
98};
99
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400100struct wl_surface;
101struct wl_display;
102
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400103struct wl_map {
104 int32_t x, y, width, height;
105};
106
107void wl_surface_set_data(struct wl_surface *surface, void *data);
108void *wl_surface_get_data(struct wl_surface *surface);
109
Kristian Høgsbergf9212892008-10-11 18:40:23 -0400110struct wl_surface_iterator;
111struct wl_surface_iterator *
112wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
113int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
114 struct wl_surface **surface);
115void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
116
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500117struct wl_object *
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500118wl_input_device_create(struct wl_display *display, const char *path);
119
Kristian Høgsberg122912c2008-12-05 11:13:50 -0500120struct wl_display *wl_display_create(void);
121struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
Kristian Høgsbergdc0f3552008-12-07 15:22:22 -0500122int wl_display_add_socket(struct wl_display *display, const char *name, size_t name_size);
Kristian Høgsberg122912c2008-12-05 11:13:50 -0500123void wl_display_run(struct wl_display *display);
124
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500125void
126wl_display_add_object(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg14fcff72008-11-23 19:10:23 -0500127int
128wl_display_add_global(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500129
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500130void
131wl_display_post_relative_event(struct wl_display *display,
132 struct wl_object *source, int dx, int dy);
133void
134wl_display_post_absolute_event(struct wl_display *display,
135 struct wl_object *source, int x, int y);
136void
137wl_display_post_button_event(struct wl_display *display,
138 struct wl_object *source, int button, int state);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500139void
140wl_display_post_key_event(struct wl_display *display,
141 struct wl_object *source, int key, int state);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500142void
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500143wl_display_post_frame(struct wl_display *display,
144 uint32_t frame, uint32_t msecs);
Kristian Høgsbergeac149a2008-12-10 00:24:18 -0500145void
146wl_display_raise_surface(struct wl_display *display, struct wl_surface *surface);
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500147
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400148struct wl_compositor {
Kristian Høgsberg5503bf82008-11-06 10:38:17 -0500149 const struct wl_compositor_interface *interface;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400150};
151
152struct wl_compositor_interface {
153 void (*notify_surface_create)(struct wl_compositor *compositor,
154 struct wl_surface *surface);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400155 void (*notify_surface_destroy)(struct wl_compositor *compositor,
156 struct wl_surface *surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400157 void (*notify_surface_attach)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500158 struct wl_surface *surface,
159 uint32_t name,
160 uint32_t width, uint32_t height,
161 uint32_t stride);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400162 void (*notify_surface_map)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500163 struct wl_surface *surface,
164 struct wl_map *map);
165 void (*notify_surface_copy)(struct wl_compositor *compositor,
166 struct wl_surface *surface,
167 int32_t dst_x, int32_t dst_y,
168 uint32_t name, uint32_t stride,
169 int32_t x, int32_t y,
170 int32_t width, int32_t height);
171 void (*notify_surface_damage)(struct wl_compositor *compositor,
172 struct wl_surface *surface,
173 int32_t x, int32_t y,
174 int32_t width, int32_t height);
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500175 uint32_t (*notify_commit)(struct wl_compositor *compositor);
Kristian Høgsberg4c9f2c92008-11-21 19:25:44 -0500176 void (*notify_pointer_motion)(struct wl_compositor *compositor,
177 struct wl_object *source,
178 int32_t x, int32_t y);
Kristian Høgsbergeac149a2008-12-10 00:24:18 -0500179 void (*notify_pointer_button)(struct wl_compositor *compositor,
180 struct wl_object *source,
181 int32_t button, int32_t state);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500182 void (*notify_key)(struct wl_compositor *compositor,
183 struct wl_object *source,
184 uint32_t key, uint32_t state);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400185};
186
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400187void wl_display_set_compositor(struct wl_display *display,
188 struct wl_compositor *compositor);
189
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400190#endif