blob: d15229f6f13f1c3d31e18322310c5e8f586d7b58 [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 *
93wl_input_device_create(struct wl_display *display,
94 const char *path, uint32_t id);
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);
109
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400110struct wl_compositor {
Kristian Høgsberg5503bf82008-11-06 10:38:17 -0500111 const struct wl_compositor_interface *interface;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400112};
113
114struct wl_compositor_interface {
115 void (*notify_surface_create)(struct wl_compositor *compositor,
116 struct wl_surface *surface);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400117 void (*notify_surface_destroy)(struct wl_compositor *compositor,
118 struct wl_surface *surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400119 void (*notify_surface_attach)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500120 struct wl_surface *surface,
121 uint32_t name,
122 uint32_t width, uint32_t height,
123 uint32_t stride);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400124 void (*notify_surface_map)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500125 struct wl_surface *surface,
126 struct wl_map *map);
127 void (*notify_surface_copy)(struct wl_compositor *compositor,
128 struct wl_surface *surface,
129 int32_t dst_x, int32_t dst_y,
130 uint32_t name, uint32_t stride,
131 int32_t x, int32_t y,
132 int32_t width, int32_t height);
133 void (*notify_surface_damage)(struct wl_compositor *compositor,
134 struct wl_surface *surface,
135 int32_t x, int32_t y,
136 int32_t width, int32_t height);
Kristian Høgsberg4c9f2c92008-11-21 19:25:44 -0500137 void (*notify_pointer_motion)(struct wl_compositor *compositor,
138 struct wl_object *source,
139 int32_t x, int32_t y);
140
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400141};
142
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400143void wl_display_set_compositor(struct wl_display *display,
144 struct wl_compositor *compositor);
145
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500146struct wl_compositor *
147wl_compositor_create(struct wl_display *display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400148
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400149#endif