Waltham  0.1.0
waltham-server.h
1 /*
2  * Copyright © 2013-2014 Collabora, Ltd.
3  * Copyright © 2016 DENSO CORPORATION
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #include <stdint.h>
26 
27 #include <waltham-object.h>
28 #include <waltham-util.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 struct wth_display;
35 struct wthp_blob_factory;
36 struct wthp_buffer;
37 struct wthp_callback;
38 struct wthp_compositor;
39 struct wthp_farstream;
40 struct wthp_farstream_remote;
41 struct wthp_keyboard;
42 struct wthp_output;
43 struct wthp_pointer;
44 struct wthp_region;
45 struct wthp_registry;
46 struct wthp_resource;
47 struct wthp_seat;
48 struct wthp_surface;
49 struct wthp_touch;
50 
51 #ifndef WALTHAM_SERVER_H
52 #define WALTHAM_SERVER_H
53 
55  void (*client_version) (struct wth_display * wth_display, uint32_t client_version);
56  void (*sync) (struct wth_display * wth_display, struct wthp_callback * callback);
57  void (*get_registry) (struct wth_display * wth_display, struct wthp_registry * registry);
58 };
59 
60 static inline void
61 wth_display_set_interface(struct wth_display *self, const struct wth_display_interface *funcs, void *user_data)
62 {
63  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
64 }
65 
67  void (*destroy) (struct wthp_registry * wthp_registry);
68  void (*bind) (struct wthp_registry * wthp_registry, uint32_t name, struct wth_object * id, const char * interface, uint32_t version);
69 };
70 
71 static inline void
72 wthp_registry_set_interface(struct wthp_registry *self, const struct wthp_registry_interface *funcs, void *user_data)
73 {
74  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
75 }
76 
78  void (*create_surface) (struct wthp_compositor * wthp_compositor, struct wthp_surface * id);
79  void (*create_region) (struct wthp_compositor * wthp_compositor, struct wthp_region * id);
80 };
81 
82 static inline void
83 wthp_compositor_set_interface(struct wthp_compositor *self, const struct wthp_compositor_interface *funcs, void *user_data)
84 {
85  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
86 }
87 
89  void (*create_buffer) (struct wthp_blob_factory * wthp_blob_factory, struct wthp_buffer * buffer, uint32_t data_sz, void * data, int32_t width, int32_t height, int32_t stride, uint32_t format);
90 };
91 
92 static inline void
93 wthp_blob_factory_set_interface(struct wthp_blob_factory *self, const struct wthp_blob_factory_interface *funcs, void *user_data)
94 {
95  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
96 }
97 
99  void (*destroy) (struct wthp_buffer * wthp_buffer);
100 };
101 
102 static inline void
103 wthp_buffer_set_interface(struct wthp_buffer *self, const struct wthp_buffer_interface *funcs, void *user_data)
104 {
105  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
106 }
107 
109  void (*destroy) (struct wthp_surface * wthp_surface);
110  void (*attach) (struct wthp_surface * wthp_surface, struct wthp_buffer * buffer, int32_t x, int32_t y);
111  void (*damage) (struct wthp_surface * wthp_surface, int32_t x, int32_t y, int32_t width, int32_t height);
112  void (*frame) (struct wthp_surface * wthp_surface, struct wthp_callback * callback);
113  void (*set_opaque_region) (struct wthp_surface * wthp_surface, struct wthp_region * region);
114  void (*set_input_region) (struct wthp_surface * wthp_surface, struct wthp_region * region);
115  void (*commit) (struct wthp_surface * wthp_surface);
116  void (*set_buffer_transform) (struct wthp_surface * wthp_surface, int32_t transform);
117  void (*set_buffer_scale) (struct wthp_surface * wthp_surface, int32_t scale);
118  void (*damage_buffer) (struct wthp_surface * wthp_surface, int32_t x, int32_t y, int32_t width, int32_t height);
119 };
120 
121 static inline void
122 wthp_surface_set_interface(struct wthp_surface *self, const struct wthp_surface_interface *funcs, void *user_data)
123 {
124  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
125 }
126 
128  void (*get_pointer) (struct wthp_seat * wthp_seat, struct wthp_pointer * id);
129  void (*get_keyboard) (struct wthp_seat * wthp_seat, struct wthp_keyboard * id);
130  void (*get_touch) (struct wthp_seat * wthp_seat, struct wthp_touch * id);
131  void (*release) (struct wthp_seat * wthp_seat);
132 };
133 
134 static inline void
135 wthp_seat_set_interface(struct wthp_seat *self, const struct wthp_seat_interface *funcs, void *user_data)
136 {
137  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
138 }
139 
141  void (*set_cursor) (struct wthp_pointer * wthp_pointer, uint32_t serial, struct wthp_surface * surface, int32_t hotspot_x, int32_t hotspot_y);
142  void (*release) (struct wthp_pointer * wthp_pointer);
143 };
144 
145 static inline void
146 wthp_pointer_set_interface(struct wthp_pointer *self, const struct wthp_pointer_interface *funcs, void *user_data)
147 {
148  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
149 }
150 
152  void (*release) (struct wthp_keyboard * wthp_keyboard);
153 };
154 
155 static inline void
156 wthp_keyboard_set_interface(struct wthp_keyboard *self, const struct wthp_keyboard_interface *funcs, void *user_data)
157 {
158  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
159 }
160 
162  void (*release) (struct wthp_touch * wthp_touch);
163 };
164 
165 static inline void
166 wthp_touch_set_interface(struct wthp_touch *self, const struct wthp_touch_interface *funcs, void *user_data)
167 {
168  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
169 }
170 
172  void (*destroy) (struct wthp_region * wthp_region);
173  void (*add) (struct wthp_region * wthp_region, int32_t x, int32_t y, int32_t width, int32_t height);
174  void (*subtract) (struct wthp_region * wthp_region, int32_t x, int32_t y, int32_t width, int32_t height);
175 };
176 
177 static inline void
178 wthp_region_set_interface(struct wthp_region *self, const struct wthp_region_interface *funcs, void *user_data)
179 {
180  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
181 }
182 
184  void (*destroy) (struct wthp_farstream * wthp_farstream);
185  void (*connect) (struct wthp_farstream * wthp_farstream, uint32_t port, struct wthp_farstream_remote * remote);
186 };
187 
188 static inline void
189 wthp_farstream_set_interface(struct wthp_farstream *self, const struct wthp_farstream_interface *funcs, void *user_data)
190 {
191  wth_object_set_listener((struct wth_object *)self, (void (**)(void)) funcs, user_data);
192 }
193 
195  void (*destroy) (struct wthp_farstream_remote * wthp_farstream_remote);
196  void (*codec_offer) (struct wthp_farstream_remote * wthp_farstream_remote, const char * list);
197  void (*create_buffer) (struct wthp_farstream_remote * wthp_farstream_remote, uint32_t frame_id, struct wthp_buffer * id);
198 };
199 
200 static inline void
201 wth_display_free(struct wth_display *self)
202 {
203  wth_object_delete((struct wth_object *)self);
204 }
205 
206 void
207 wth_display_send_error (struct wth_display * wth_display, struct wth_object * object_id, uint32_t code, const char * message);
208 
209 void
210 wth_display_send_delete_id (struct wth_display * wth_display, uint32_t id);
211 
212 void
213 wth_display_send_server_version (struct wth_display * wth_display, uint32_t server_version);
214 
215 static inline void
216 wthp_registry_free(struct wthp_registry *self)
217 {
218  wth_object_delete((struct wth_object *)self);
219 }
220 
221 void
222 wthp_registry_send_global (struct wthp_registry * wthp_registry, uint32_t name, const char * interface, uint32_t version);
223 
224 void
225 wthp_registry_send_global_remove (struct wthp_registry * wthp_registry, uint32_t name);
226 
227 static inline void
228 wthp_callback_free(struct wthp_callback *self)
229 {
230  wth_object_delete((struct wth_object *)self);
231 }
232 
233 void
234 wthp_callback_send_done (struct wthp_callback * wthp_callback, uint32_t callback_data);
235 
236 static inline void
237 wthp_compositor_free(struct wthp_compositor *self)
238 {
239  wth_object_delete((struct wth_object *)self);
240 }
241 
242 static inline void
243 wthp_blob_factory_free(struct wthp_blob_factory *self)
244 {
245  wth_object_delete((struct wth_object *)self);
246 }
247 
248 void
249 wthp_blob_factory_send_format (struct wthp_blob_factory * wthp_blob_factory, uint32_t format);
250 
251 static inline void
252 wthp_buffer_free(struct wthp_buffer *self)
253 {
254  wth_object_delete((struct wth_object *)self);
255 }
256 
257 void
258 wthp_buffer_send_complete (struct wthp_buffer * wthp_buffer, uint32_t serial);
259 
260 static inline void
261 wthp_surface_free(struct wthp_surface *self)
262 {
263  wth_object_delete((struct wth_object *)self);
264 }
265 
266 void
267 wthp_surface_send_enter (struct wthp_surface * wthp_surface, struct wthp_output * output);
268 
269 void
270 wthp_surface_send_leave (struct wthp_surface * wthp_surface, struct wthp_output * output);
271 
272 static inline void
273 wthp_seat_free(struct wthp_seat *self)
274 {
275  wth_object_delete((struct wth_object *)self);
276 }
277 
278 void
279 wthp_seat_send_capabilities (struct wthp_seat * wthp_seat, uint32_t capabilities);
280 
281 void
282 wthp_seat_send_name (struct wthp_seat * wthp_seat, const char * name);
283 
284 static inline void
285 wthp_pointer_free(struct wthp_pointer *self)
286 {
287  wth_object_delete((struct wth_object *)self);
288 }
289 
290 void
291 wthp_pointer_send_enter (struct wthp_pointer * wthp_pointer, uint32_t serial, struct wthp_surface * surface, wth_fixed_t surface_x, wth_fixed_t surface_y);
292 
293 void
294 wthp_pointer_send_leave (struct wthp_pointer * wthp_pointer, uint32_t serial, struct wthp_surface * surface);
295 
296 void
297 wthp_pointer_send_motion (struct wthp_pointer * wthp_pointer, uint32_t time, wth_fixed_t surface_x, wth_fixed_t surface_y);
298 
299 void
300 wthp_pointer_send_button (struct wthp_pointer * wthp_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state);
301 
302 void
303 wthp_pointer_send_axis (struct wthp_pointer * wthp_pointer, uint32_t time, uint32_t axis, wth_fixed_t value);
304 
305 void
306 wthp_pointer_send_frame (struct wthp_pointer * wthp_pointer);
307 
308 void
309 wthp_pointer_send_axis_source (struct wthp_pointer * wthp_pointer, uint32_t axis_source);
310 
311 void
312 wthp_pointer_send_axis_stop (struct wthp_pointer * wthp_pointer, uint32_t time, uint32_t axis);
313 
314 void
315 wthp_pointer_send_axis_discrete (struct wthp_pointer * wthp_pointer, uint32_t axis, int32_t discrete);
316 
317 static inline void
318 wthp_keyboard_free(struct wthp_keyboard *self)
319 {
320  wth_object_delete((struct wth_object *)self);
321 }
322 
323 void
324 wthp_keyboard_send_keymap (struct wthp_keyboard * wthp_keyboard, uint32_t format, uint32_t keymap_sz, void * keymap);
325 
326 void
327 wthp_keyboard_send_enter (struct wthp_keyboard * wthp_keyboard, uint32_t serial, struct wthp_surface * surface, struct wth_array * keys);
328 
329 void
330 wthp_keyboard_send_leave (struct wthp_keyboard * wthp_keyboard, uint32_t serial, struct wthp_surface * surface);
331 
332 void
333 wthp_keyboard_send_key (struct wthp_keyboard * wthp_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
334 
335 void
336 wthp_keyboard_send_modifiers (struct wthp_keyboard * wthp_keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group);
337 
338 void
339 wthp_keyboard_send_repeat_info (struct wthp_keyboard * wthp_keyboard, int32_t rate, int32_t delay);
340 
341 static inline void
342 wthp_touch_free(struct wthp_touch *self)
343 {
344  wth_object_delete((struct wth_object *)self);
345 }
346 
347 void
348 wthp_touch_send_down (struct wthp_touch * wthp_touch, uint32_t serial, uint32_t time, struct wthp_surface * surface, int32_t id, wth_fixed_t x, wth_fixed_t y);
349 
350 void
351 wthp_touch_send_up (struct wthp_touch * wthp_touch, uint32_t serial, uint32_t time, int32_t id);
352 
353 void
354 wthp_touch_send_motion (struct wthp_touch * wthp_touch, uint32_t time, int32_t id, wth_fixed_t x, wth_fixed_t y);
355 
356 void
357 wthp_touch_send_frame (struct wthp_touch * wthp_touch);
358 
359 void
360 wthp_touch_send_cancel (struct wthp_touch * wthp_touch);
361 
362 static inline void
363 wthp_output_free(struct wthp_output *self)
364 {
365  wth_object_delete((struct wth_object *)self);
366 }
367 
368 void
369 wthp_output_send_geometry (struct wthp_output * wthp_output, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const char * make, const char * model, int32_t transform);
370 
371 void
372 wthp_output_send_mode (struct wthp_output * wthp_output, uint32_t flags, int32_t width, int32_t height, int32_t refresh);
373 
374 void
375 wthp_output_send_done (struct wthp_output * wthp_output);
376 
377 void
378 wthp_output_send_scale (struct wthp_output * wthp_output, int32_t factor);
379 
380 static inline void
381 wthp_region_free(struct wthp_region *self)
382 {
383  wth_object_delete((struct wth_object *)self);
384 }
385 
386 static inline void
387 wthp_farstream_free(struct wthp_farstream *self)
388 {
389  wth_object_delete((struct wth_object *)self);
390 }
391 
392 static inline void
393 wthp_farstream_remote_free(struct wthp_farstream_remote *self)
394 {
395  wth_object_delete((struct wth_object *)self);
396 }
397 
398 void
399 wthp_farstream_remote_send_port (struct wthp_farstream_remote * wthp_farstream_remote, uint32_t port);
400 
401 void
402 wthp_farstream_remote_send_codec_answer (struct wthp_farstream_remote * wthp_farstream_remote, const char * list);
403 
404 void
405 wthp_farstream_remote_send_error (struct wthp_farstream_remote * wthp_farstream_remote, uint32_t code, const char * message);
406 
407 #ifdef __cplusplus
408 }
409 #endif
410 
411 #endif
Definition: waltham-server.h:77
Definition: waltham-server.h:183
Definition: waltham-server.h:88
Definition: waltham-server.h:161
Definition: waltham-server.h:171
Definition: waltham-server.h:194
Definition: waltham-server.h:98
Definition: waltham-server.h:151
void wth_object_set_listener(struct wth_object *obj, void(**listener)(void), void *user_data)
Set incoming message handlers for a protocol object.
Definition: waltham-server.h:54
Definition: waltham-server.h:66
Definition: waltham-server.h:127
A generic Waltham protocol object representation (a proxy)
Definition: waltham-server.h:108
Definition: waltham-util.h:64
Definition: waltham-server.h:140
Waltham generic protocol object interface.
Utility classes, functions, and macros.