blob: 061f4b2c5ce455474b24104f8d8bd1f54075bd29 [file] [log] [blame]
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -04001#ifndef WAYLAND_H
2#define WAYLAND_H
3
4#include <stdint.h>
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -05005#include "wayland-util.h"
Kristian Høgsbergb7a01922008-11-08 15:39:41 -05006
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -04007enum {
8 WL_EVENT_READABLE = 0x01,
9 WL_EVENT_WRITEABLE = 0x02
10};
11
12struct wl_event_loop;
13struct wl_event_source;
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040014typedef void (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
15typedef void (*wl_event_loop_idle_func_t)(void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040016
17struct wl_event_loop *wl_event_loop_create(void);
18void wl_event_loop_destroy(struct wl_event_loop *loop);
19struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
20 int fd, uint32_t mask,
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040021 wl_event_loop_fd_func_t func,
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040022 void *data);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040023int wl_event_loop_update_source(struct wl_event_loop *loop,
24 struct wl_event_source *source,
25 uint32_t mask);
26
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040027int wl_event_loop_remove_source(struct wl_event_loop *loop,
28 struct wl_event_source *source);
29int wl_event_loop_wait(struct wl_event_loop *loop);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040030struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
31 wl_event_loop_idle_func_t func,
32 void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040033
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040034struct wl_client;
35
36enum {
37 WL_ARGUMENT_UINT32,
38 WL_ARGUMENT_STRING,
39 WL_ARGUMENT_OBJECT,
40 WL_ARGUMENT_NEW_ID
41};
42
43struct wl_argument {
44 uint32_t type;
45 void *data;
46};
47
48struct wl_method {
49 const char *name;
50 void *func;
51 int argument_count;
52 const struct wl_argument *arguments;
53};
54
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040055struct wl_event {
56 const char *name;
57};
58
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040059struct wl_interface {
60 const char *name;
61 int version;
62 int method_count;
63 const struct wl_method *methods;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040064 int event_count;
65 const struct wl_event *events;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040066};
67
68struct wl_object {
69 const struct wl_interface *interface;
70 uint32_t id;
71};
72
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040073struct wl_surface;
74struct wl_display;
75
Kristian Høgsberg05eff512008-10-07 10:10:36 -040076struct wl_map {
77 int32_t x, y, width, height;
78};
79
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040080struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
81
Kristian Høgsberg05eff512008-10-07 10:10:36 -040082void wl_surface_set_data(struct wl_surface *surface, void *data);
83void *wl_surface_get_data(struct wl_surface *surface);
84
Kristian Høgsbergf9212892008-10-11 18:40:23 -040085struct wl_surface_iterator;
86struct wl_surface_iterator *
87wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
88int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
89 struct wl_surface **surface);
90void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
91
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -050092struct wl_object *
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -050093wl_input_device_create(struct wl_display *display, const char *path);
94
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050095void
96wl_display_add_object(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg14fcff72008-11-23 19:10:23 -050097int
98wl_display_add_global(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050099
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500100void
101wl_display_post_relative_event(struct wl_display *display,
102 struct wl_object *source, int dx, int dy);
103void
104wl_display_post_absolute_event(struct wl_display *display,
105 struct wl_object *source, int x, int y);
106void
107wl_display_post_button_event(struct wl_display *display,
108 struct wl_object *source, int button, int state);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500109void
110wl_display_post_key_event(struct wl_display *display,
111 struct wl_object *source, int key, int state);
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500112
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400113struct wl_compositor {
Kristian Høgsberg5503bf82008-11-06 10:38:17 -0500114 const struct wl_compositor_interface *interface;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400115};
116
117struct wl_compositor_interface {
118 void (*notify_surface_create)(struct wl_compositor *compositor,
119 struct wl_surface *surface);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400120 void (*notify_surface_destroy)(struct wl_compositor *compositor,
121 struct wl_surface *surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400122 void (*notify_surface_attach)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500123 struct wl_surface *surface,
124 uint32_t name,
125 uint32_t width, uint32_t height,
126 uint32_t stride);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400127 void (*notify_surface_map)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500128 struct wl_surface *surface,
129 struct wl_map *map);
130 void (*notify_surface_copy)(struct wl_compositor *compositor,
131 struct wl_surface *surface,
132 int32_t dst_x, int32_t dst_y,
133 uint32_t name, uint32_t stride,
134 int32_t x, int32_t y,
135 int32_t width, int32_t height);
136 void (*notify_surface_damage)(struct wl_compositor *compositor,
137 struct wl_surface *surface,
138 int32_t x, int32_t y,
139 int32_t width, int32_t height);
Kristian Høgsberg4c9f2c92008-11-21 19:25:44 -0500140 void (*notify_pointer_motion)(struct wl_compositor *compositor,
141 struct wl_object *source,
142 int32_t x, int32_t y);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500143 void (*notify_key)(struct wl_compositor *compositor,
144 struct wl_object *source,
145 uint32_t key, uint32_t state);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400146};
147
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400148void wl_display_set_compositor(struct wl_display *display,
149 struct wl_compositor *compositor);
150
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500151struct wl_compositor *
152wl_compositor_create(struct wl_display *display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400153
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400154#endif