blob: 23a0c56f0969d5be59667fe21701c120cf288389 [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);
Kristian Høgsberg4a298902008-11-28 18:35:25 -050015typedef void (*wl_event_loop_timer_func_t)(void *data);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040016typedef void (*wl_event_loop_idle_func_t)(void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040017
18struct wl_event_loop *wl_event_loop_create(void);
19void wl_event_loop_destroy(struct wl_event_loop *loop);
20struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *loop,
21 int fd, uint32_t mask,
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040022 wl_event_loop_fd_func_t func,
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040023 void *data);
Kristian Høgsberg4a298902008-11-28 18:35:25 -050024int wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask);
25struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *loop,
26 wl_event_loop_timer_func_t func,
27 void *data);
28int wl_event_source_timer_update(struct wl_event_source *source,
29 int ms_delay);
30int wl_event_source_remove(struct wl_event_source *source);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040031
Kristian Høgsberg4a298902008-11-28 18:35:25 -050032
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040033int wl_event_loop_wait(struct wl_event_loop *loop);
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040034struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
35 wl_event_loop_idle_func_t func,
36 void *data);
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040037
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040038struct wl_client;
39
40enum {
41 WL_ARGUMENT_UINT32,
42 WL_ARGUMENT_STRING,
43 WL_ARGUMENT_OBJECT,
44 WL_ARGUMENT_NEW_ID
45};
46
47struct wl_argument {
48 uint32_t type;
49 void *data;
50};
51
52struct wl_method {
53 const char *name;
54 void *func;
55 int argument_count;
56 const struct wl_argument *arguments;
57};
58
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040059struct wl_event {
60 const char *name;
61};
62
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040063struct wl_interface {
64 const char *name;
65 int version;
66 int method_count;
67 const struct wl_method *methods;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040068 int event_count;
69 const struct wl_event *events;
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -040070};
71
72struct wl_object {
73 const struct wl_interface *interface;
74 uint32_t id;
75};
76
Kristian Høgsberga67a71a2008-10-07 10:10:36 -040077struct wl_surface;
78struct wl_display;
79
Kristian Høgsberg05eff512008-10-07 10:10:36 -040080struct wl_map {
81 int32_t x, y, width, height;
82};
83
Kristian Høgsberg5ebb3172008-10-11 19:21:35 -040084struct wl_event_loop *wl_display_get_event_loop(struct wl_display *display);
85
Kristian Høgsberg05eff512008-10-07 10:10:36 -040086void wl_surface_set_data(struct wl_surface *surface, void *data);
87void *wl_surface_get_data(struct wl_surface *surface);
88
Kristian Høgsbergf9212892008-10-11 18:40:23 -040089struct wl_surface_iterator;
90struct wl_surface_iterator *
91wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
92int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
93 struct wl_surface **surface);
94void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
95
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -050096struct wl_object *
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -050097wl_input_device_create(struct wl_display *display, const char *path);
98
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -050099void
100wl_display_add_object(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg14fcff72008-11-23 19:10:23 -0500101int
102wl_display_add_global(struct wl_display *display, struct wl_object *object);
Kristian Høgsberg1e4b86a2008-11-23 23:41:08 -0500103
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500104void
105wl_display_post_relative_event(struct wl_display *display,
106 struct wl_object *source, int dx, int dy);
107void
108wl_display_post_absolute_event(struct wl_display *display,
109 struct wl_object *source, int x, int y);
110void
111wl_display_post_button_event(struct wl_display *display,
112 struct wl_object *source, int button, int state);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500113void
114wl_display_post_key_event(struct wl_display *display,
115 struct wl_object *source, int key, int state);
Kristian Høgsberg44f36e32008-11-26 12:57:31 -0500116void
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500117wl_display_post_frame(struct wl_display *display,
118 uint32_t frame, uint32_t msecs);
Kristian Høgsbergf9bc7952008-11-02 10:12:29 -0500119
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400120struct wl_compositor {
Kristian Høgsberg5503bf82008-11-06 10:38:17 -0500121 const struct wl_compositor_interface *interface;
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400122};
123
124struct wl_compositor_interface {
125 void (*notify_surface_create)(struct wl_compositor *compositor,
126 struct wl_surface *surface);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400127 void (*notify_surface_destroy)(struct wl_compositor *compositor,
128 struct wl_surface *surface);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400129 void (*notify_surface_attach)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500130 struct wl_surface *surface,
131 uint32_t name,
132 uint32_t width, uint32_t height,
133 uint32_t stride);
Kristian Høgsberg05eff512008-10-07 10:10:36 -0400134 void (*notify_surface_map)(struct wl_compositor *compositor,
Kristian Høgsberg7f77bd82008-11-07 08:39:37 -0500135 struct wl_surface *surface,
136 struct wl_map *map);
137 void (*notify_surface_copy)(struct wl_compositor *compositor,
138 struct wl_surface *surface,
139 int32_t dst_x, int32_t dst_y,
140 uint32_t name, uint32_t stride,
141 int32_t x, int32_t y,
142 int32_t width, int32_t height);
143 void (*notify_surface_damage)(struct wl_compositor *compositor,
144 struct wl_surface *surface,
145 int32_t x, int32_t y,
146 int32_t width, int32_t height);
Kristian Høgsbergfbdbbdc2008-11-28 17:06:06 -0500147 uint32_t (*notify_commit)(struct wl_compositor *compositor);
Kristian Høgsberg4c9f2c92008-11-21 19:25:44 -0500148 void (*notify_pointer_motion)(struct wl_compositor *compositor,
149 struct wl_object *source,
150 int32_t x, int32_t y);
Kristian Høgsbergcddc0ad2008-11-24 00:31:49 -0500151 void (*notify_key)(struct wl_compositor *compositor,
152 struct wl_object *source,
153 uint32_t key, uint32_t state);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400154};
155
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400156void wl_display_set_compositor(struct wl_display *display,
157 struct wl_compositor *compositor);
158
Kristian Høgsbergb7a01922008-11-08 15:39:41 -0500159struct wl_compositor *
160wl_compositor_create(struct wl_display *display);
Kristian Høgsberga67a71a2008-10-07 10:10:36 -0400161
Kristian Høgsberg97f1ebe2008-09-30 09:46:10 -0400162#endif