protocol: add sub-surfaces
[profile/ivi/weston-ivi-shell.git] / src / compositor.h
1 /*
2  * Copyright © 2008-2011 Kristian Høgsberg
3  * Copyright © 2012 Collabora, Ltd.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of the copyright holders not be used in
10  * advertising or publicity pertaining to distribution of the software
11  * without specific, written prior permission.  The copyright holders make
12  * no representations about the suitability of this software for any
13  * purpose.  It is provided "as is" without express or implied warranty.
14  *
15  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  */
23
24 #ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
25 #define _WAYLAND_SYSTEM_COMPOSITOR_H_
26
27 #ifdef  __cplusplus
28 extern "C" {
29 #endif
30
31 #include <pixman.h>
32 #include <xkbcommon/xkbcommon.h>
33 #include <wayland-server.h>
34
35 #include "version.h"
36 #include "matrix.h"
37 #include "config-parser.h"
38 #include "subsurface-server-protocol.h"
39
40 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
41
42 #define container_of(ptr, type, member) ({                              \
43         const __typeof__( ((type *)0)->member ) *__mptr = (ptr);        \
44         (type *)( (char *)__mptr - offsetof(type,member) );})
45
46 struct weston_transform {
47         struct weston_matrix matrix;
48         struct wl_list link;
49 };
50
51 struct weston_surface;
52 struct shell_surface;
53 struct weston_seat;
54 struct weston_output;
55 struct input_method;
56
57 enum weston_keyboard_modifier {
58         MODIFIER_CTRL = (1 << 0),
59         MODIFIER_ALT = (1 << 1),
60         MODIFIER_SUPER = (1 << 2),
61         MODIFIER_SHIFT = (1 << 3),
62 };
63
64 enum weston_led {
65         LED_NUM_LOCK = (1 << 0),
66         LED_CAPS_LOCK = (1 << 1),
67         LED_SCROLL_LOCK = (1 << 2),
68 };
69
70 struct weston_mode {
71         uint32_t flags;
72         int32_t width, height;
73         uint32_t refresh;
74         struct wl_list link;
75 };
76
77 struct weston_shell_client {
78         void (*send_configure)(struct weston_surface *surface,
79                                uint32_t edges, int32_t width, int32_t height);
80 };
81
82 struct weston_shell_interface {
83         void *shell;                    /* either desktop or tablet */
84
85         struct shell_surface *(*create_shell_surface)(void *shell,
86                                                       struct weston_surface *surface,
87                                                       const struct weston_shell_client *client);
88
89         void (*set_toplevel)(struct shell_surface *shsurf);
90
91         void (*set_transient)(struct shell_surface *shsurf,
92                               struct weston_surface *parent,
93                               int x, int y, uint32_t flags);
94         void (*set_fullscreen)(struct shell_surface *shsurf,
95                                uint32_t method,
96                                uint32_t framerate,
97                                struct weston_output *output);
98         int (*move)(struct shell_surface *shsurf, struct weston_seat *ws);
99         int (*resize)(struct shell_surface *shsurf,
100                       struct weston_seat *ws, uint32_t edges);
101
102 };
103
104 struct weston_border {
105         int32_t left, right, top, bottom;
106 };
107
108 struct weston_animation {
109         void (*frame)(struct weston_animation *animation,
110                       struct weston_output *output, uint32_t msecs);
111         int frame_counter;
112         struct wl_list link;
113 };
114
115 struct weston_spring {
116         double k;
117         double friction;
118         double current;
119         double target;
120         double previous;
121         uint32_t timestamp;
122 };
123
124 enum {
125         ZOOM_FOCUS_POINTER,
126         ZOOM_FOCUS_TEXT
127 };
128
129 struct weston_fixed_point {
130         wl_fixed_t x, y;
131 };
132
133 struct weston_output_zoom {
134         int active;
135         uint32_t type;
136         float increment;
137         float level;
138         float max_level;
139         float trans_x, trans_y;
140         struct weston_animation animation_z;
141         struct weston_spring spring_z;
142         struct weston_animation animation_xy;
143         struct weston_spring spring_xy;
144         struct weston_fixed_point from;
145         struct weston_fixed_point to;
146         struct weston_fixed_point current;
147         struct weston_fixed_point text_cursor;
148 };
149
150 /* bit compatible with drm definitions. */
151 enum dpms_enum {
152         WESTON_DPMS_ON,
153         WESTON_DPMS_STANDBY,
154         WESTON_DPMS_SUSPEND,
155         WESTON_DPMS_OFF
156 };
157
158 struct weston_output {
159         uint32_t id;
160         char *name;
161
162         void *renderer_state;
163
164         struct wl_list link;
165         struct wl_list resource_list;
166         struct wl_global *global;
167         struct weston_compositor *compositor;
168         struct weston_matrix matrix;
169         struct wl_list animation_list;
170         int32_t x, y, width, height;
171         int32_t mm_width, mm_height;
172         struct weston_border border;
173         pixman_region32_t region;
174         pixman_region32_t previous_damage;
175         int repaint_needed;
176         int repaint_scheduled;
177         struct weston_output_zoom zoom;
178         int dirty;
179         struct wl_signal frame_signal;
180         struct wl_signal destroy_signal;
181         uint32_t frame_time;
182         int disable_planes;
183
184         char *make, *model, *serial_number;
185         uint32_t subpixel;
186         uint32_t transform;
187         
188         struct weston_mode *current;
189         struct weston_mode *origin;
190         struct wl_list mode_list;
191
192         void (*start_repaint_loop)(struct weston_output *output);
193         void (*repaint)(struct weston_output *output,
194                         pixman_region32_t *damage);
195         void (*destroy)(struct weston_output *output);
196         void (*assign_planes)(struct weston_output *output);
197         int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
198
199         /* backlight values are on 0-255 range, where higher is brighter */
200         uint32_t backlight_current;
201         void (*set_backlight)(struct weston_output *output, uint32_t value);
202         void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
203
204         int connection_internal;
205         uint16_t gamma_size;
206         void (*set_gamma)(struct weston_output *output,
207                           uint16_t size,
208                           uint16_t *r,
209                           uint16_t *g,
210                           uint16_t *b);
211 };
212
213 struct weston_pointer_grab;
214 struct weston_pointer_grab_interface {
215         void (*focus)(struct weston_pointer_grab *grab);
216         void (*motion)(struct weston_pointer_grab *grab, uint32_t time);
217         void (*button)(struct weston_pointer_grab *grab,
218                        uint32_t time, uint32_t button, uint32_t state);
219 };
220
221 struct weston_pointer_grab {
222         const struct weston_pointer_grab_interface *interface;
223         struct weston_pointer *pointer;
224 };
225
226 struct weston_keyboard_grab;
227 struct weston_keyboard_grab_interface {
228         void (*key)(struct weston_keyboard_grab *grab, uint32_t time,
229                     uint32_t key, uint32_t state);
230         void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
231                           uint32_t mods_depressed, uint32_t mods_latched,
232                           uint32_t mods_locked, uint32_t group);
233 };
234
235 struct weston_keyboard_grab {
236         const struct weston_keyboard_grab_interface *interface;
237         struct weston_keyboard *keyboard;
238 };
239
240 struct weston_touch_grab;
241 struct weston_touch_grab_interface {
242         void (*down)(struct weston_touch_grab *grab,
243                         uint32_t time,
244                         int touch_id,
245                         wl_fixed_t sx,
246                         wl_fixed_t sy);
247         void (*up)(struct weston_touch_grab *grab,
248                         uint32_t time,
249                         int touch_id);
250         void (*motion)(struct weston_touch_grab *grab,
251                         uint32_t time,
252                         int touch_id,
253                         wl_fixed_t sx,
254                         wl_fixed_t sy);
255 };
256
257 struct weston_touch_grab {
258         const struct weston_touch_grab_interface *interface;
259         struct weston_touch *touch;
260 };
261
262 struct wl_data_offer {
263         struct wl_resource resource;
264         struct wl_data_source *source;
265         struct wl_listener source_destroy_listener;
266 };
267
268 struct wl_data_source {
269         struct wl_resource resource;
270         struct wl_array mime_types;
271
272         void (*accept)(struct wl_data_source *source,
273                        uint32_t serial, const char *mime_type);
274         void (*send)(struct wl_data_source *source,
275                      const char *mime_type, int32_t fd);
276         void (*cancel)(struct wl_data_source *source);
277 };
278
279 struct weston_pointer {
280         struct weston_seat *seat;
281
282         struct wl_list resource_list;
283         struct weston_surface *focus;
284         struct wl_resource *focus_resource;
285         struct wl_listener focus_listener;
286         uint32_t focus_serial;
287         struct wl_signal focus_signal;
288
289         struct weston_surface *sprite;
290         struct wl_listener sprite_destroy_listener;
291         int32_t hotspot_x, hotspot_y;
292
293         struct weston_pointer_grab *grab;
294         struct weston_pointer_grab default_grab;
295         wl_fixed_t grab_x, grab_y;
296         uint32_t grab_button;
297         uint32_t grab_serial;
298         uint32_t grab_time;
299
300         wl_fixed_t x, y;
301         uint32_t button_count;
302 };
303
304
305 struct weston_touch {
306         struct weston_seat *seat;
307
308         struct wl_list resource_list;
309         struct weston_surface *focus;
310         struct wl_resource *focus_resource;
311         struct wl_listener focus_listener;
312         uint32_t focus_serial;
313         struct wl_signal focus_signal;
314
315         struct weston_touch_grab *grab;
316         struct weston_touch_grab default_grab;
317         wl_fixed_t grab_x, grab_y;
318         uint32_t grab_serial;
319         uint32_t grab_time;
320 };
321
322 struct weston_pointer *
323 weston_pointer_create(void);
324 void
325 weston_pointer_destroy(struct weston_pointer *pointer);
326 void
327 weston_pointer_set_focus(struct weston_pointer *pointer,
328                          struct weston_surface *surface,
329                          wl_fixed_t sx, wl_fixed_t sy);
330 void
331 weston_pointer_start_grab(struct weston_pointer *pointer,
332                           struct weston_pointer_grab *grab);
333 void
334 weston_pointer_end_grab(struct weston_pointer *pointer);
335
336 struct weston_keyboard *
337 weston_keyboard_create(void);
338 void
339 weston_keyboard_destroy(struct weston_keyboard *keyboard);
340 void
341 weston_keyboard_set_focus(struct weston_keyboard *keyboard,
342                           struct weston_surface *surface);
343 void
344 weston_keyboard_start_grab(struct weston_keyboard *device,
345                            struct weston_keyboard_grab *grab);
346 void
347 weston_keyboard_end_grab(struct weston_keyboard *keyboard);
348
349 struct weston_touch *
350 weston_touch_create(void);
351 void
352 weston_touch_destroy(struct weston_touch *touch);
353 void
354 weston_touch_start_grab(struct weston_touch *device,
355                         struct weston_touch_grab *grab);
356 void
357 weston_touch_end_grab(struct weston_touch *touch);
358
359 void
360 wl_data_device_set_keyboard_focus(struct weston_seat *seat);
361
362 int
363 wl_data_device_manager_init(struct wl_display *display);
364
365
366 void
367 weston_seat_set_selection(struct weston_seat *seat,
368                           struct wl_data_source *source, uint32_t serial);
369
370 struct weston_xkb_info {
371         struct xkb_keymap *keymap;
372         int keymap_fd;
373         size_t keymap_size;
374         char *keymap_area;
375         xkb_mod_index_t shift_mod;
376         xkb_mod_index_t caps_mod;
377         xkb_mod_index_t ctrl_mod;
378         xkb_mod_index_t alt_mod;
379         xkb_mod_index_t mod2_mod;
380         xkb_mod_index_t mod3_mod;
381         xkb_mod_index_t super_mod;
382         xkb_mod_index_t mod5_mod;
383         xkb_led_index_t num_led;
384         xkb_led_index_t caps_led;
385         xkb_led_index_t scroll_led;
386 };
387
388 struct weston_keyboard {
389         struct weston_seat *seat;
390
391         struct wl_list resource_list;
392         struct weston_surface *focus;
393         struct wl_resource *focus_resource;
394         struct wl_listener focus_listener;
395         uint32_t focus_serial;
396         struct wl_signal focus_signal;
397
398         struct weston_keyboard_grab *grab;
399         struct weston_keyboard_grab default_grab;
400         uint32_t grab_key;
401         uint32_t grab_serial;
402         uint32_t grab_time;
403
404         struct wl_array keys;
405
406         struct {
407                 uint32_t mods_depressed;
408                 uint32_t mods_latched;
409                 uint32_t mods_locked;
410                 uint32_t group;
411         } modifiers;
412
413         struct weston_keyboard_grab input_method_grab;
414         struct wl_resource *input_method_resource;
415 };
416
417 struct weston_seat {
418         struct wl_list base_resource_list;
419
420         struct weston_pointer *pointer;
421         struct weston_keyboard *keyboard;
422         struct weston_touch *touch;
423
424         struct wl_signal destroy_signal;
425
426         struct weston_compositor *compositor;
427         struct wl_list link;
428         enum weston_keyboard_modifier modifier_state;
429         struct weston_surface *saved_kbd_focus;
430         struct wl_listener saved_kbd_focus_listener;
431         struct wl_list drag_resource_list;
432
433         uint32_t selection_serial;
434         struct wl_data_source *selection_data_source;
435         struct wl_listener selection_data_source_listener;
436         struct wl_signal selection_signal;
437
438         uint32_t num_tp;
439
440         void (*led_update)(struct weston_seat *ws, enum weston_led leds);
441
442         struct weston_xkb_info xkb_info;
443         struct {
444                 struct xkb_state *state;
445                 enum weston_led leds;
446         } xkb_state;
447
448         struct input_method *input_method;
449 };
450
451 enum {
452         WESTON_COMPOSITOR_ACTIVE,
453         WESTON_COMPOSITOR_IDLE,         /* shell->unlock called on activity */
454         WESTON_COMPOSITOR_OFFSCREEN,    /* no rendering, no frame events */
455         WESTON_COMPOSITOR_SLEEPING      /* same as offscreen, but also set dmps
456                                          * to off */
457 };
458
459 struct weston_layer {
460         struct wl_list surface_list;
461         struct wl_list link;
462 };
463
464 struct weston_plane {
465         pixman_region32_t damage;
466         pixman_region32_t clip;
467         int32_t x, y;
468         struct wl_list link;
469 };
470
471 struct weston_renderer {
472         int (*read_pixels)(struct weston_output *output,
473                                pixman_format_code_t format, void *pixels,
474                                uint32_t x, uint32_t y,
475                                uint32_t width, uint32_t height);
476         void (*repaint_output)(struct weston_output *output,
477                                pixman_region32_t *output_damage);
478         void (*flush_damage)(struct weston_surface *surface);
479         void (*attach)(struct weston_surface *es, struct wl_buffer *buffer);
480         int (*create_surface)(struct weston_surface *surface);
481         void (*surface_set_color)(struct weston_surface *surface,
482                                float red, float green,
483                                float blue, float alpha);
484         void (*destroy_surface)(struct weston_surface *surface);
485         void (*destroy)(struct weston_compositor *ec);
486 };
487
488 struct weston_compositor {
489         struct wl_signal destroy_signal;
490
491         struct wl_display *wl_display;
492         struct weston_shell_interface shell_interface;
493
494         struct wl_signal activate_signal;
495         struct wl_signal kill_signal;
496         struct wl_signal idle_signal;
497         struct wl_signal wake_signal;
498
499         struct wl_signal show_input_panel_signal;
500         struct wl_signal hide_input_panel_signal;
501         struct wl_signal update_input_panel_signal;
502
503         struct wl_signal seat_created_signal;
504         struct wl_signal output_created_signal;
505
506         struct wl_event_loop *input_loop;
507         struct wl_event_source *input_loop_source;
508
509         struct weston_layer fade_layer;
510         struct weston_layer cursor_layer;
511
512         struct wl_list output_list;
513         struct wl_list seat_list;
514         struct wl_list layer_list;
515         struct wl_list surface_list;
516         struct wl_list plane_list;
517         struct wl_list key_binding_list;
518         struct wl_list button_binding_list;
519         struct wl_list axis_binding_list;
520         struct wl_list debug_binding_list;
521
522         uint32_t state;
523         struct wl_event_source *idle_source;
524         uint32_t idle_inhibit;
525         int idle_time;                  /* timeout, s */
526
527         /* Repaint state. */
528         struct weston_plane primary_plane;
529
530         uint32_t focus;
531
532         struct weston_renderer *renderer;
533
534         pixman_format_code_t read_format;
535
536         void (*destroy)(struct weston_compositor *ec);
537         void (*restore)(struct weston_compositor *ec);
538         int (*authenticate)(struct weston_compositor *c, uint32_t id);
539
540         void (*ping_handler)(struct weston_surface *surface, uint32_t serial);
541
542         int launcher_sock;
543
544         uint32_t output_id_pool;
545
546         struct xkb_rule_names xkb_names;
547         struct xkb_context *xkb_context;
548         struct weston_xkb_info xkb_info;
549 };
550
551 struct weston_buffer_reference {
552         struct wl_buffer *buffer;
553         struct wl_listener destroy_listener;
554 };
555
556 struct weston_region {
557         struct wl_resource resource;
558         pixman_region32_t region;
559 };
560
561 /* Using weston_surface transformations
562  *
563  * To add a transformation to a surface, create a struct weston_transform, and
564  * add it to the list surface->geometry.transformation_list. Whenever you
565  * change the list, anything under surface->geometry, or anything in the
566  * weston_transforms linked into the list, you must call
567  * weston_surface_geometry_dirty().
568  *
569  * The order in the list defines the order of transformations. Let the list
570  * contain the transformation matrices M1, ..., Mn as head to tail. The
571  * transformation is applied to surface-local coordinate vector p as
572  *    P = Mn * ... * M2 * M1 * p
573  * to produce the global coordinate vector P. The total transform
574  *    Mn * ... * M2 * M1
575  * is cached in surface->transform.matrix, and the inverse of it in
576  * surface->transform.inverse.
577  *
578  * The list always contains surface->transform.position transformation, which
579  * is the translation by surface->geometry.x and y.
580  *
581  * If you want to apply a transformation in local coordinates, add your
582  * weston_transform to the head of the list. If you want to apply a
583  * transformation in global coordinates, add it to the tail of the list.
584  *
585  * If surface->geometry.parent is set, the total transformation of this
586  * surface will be the parent's total transformation and this transformation
587  * combined:
588  *    Mparent * Mn * ... * M2 * M1
589  */
590
591 struct weston_surface {
592         struct wl_resource resource;
593         struct weston_compositor *compositor;
594         pixman_region32_t clip;
595         pixman_region32_t damage;
596         pixman_region32_t opaque;        /* part of geometry, see below */
597         pixman_region32_t input;
598         struct wl_list link;
599         struct wl_list layer_link;
600         float alpha;                     /* part of geometry, see below */
601         struct weston_plane *plane;
602
603         void *renderer_state;
604
605         /* Surface geometry state, mutable.
606          * If you change anything, call weston_surface_geometry_dirty().
607          * That includes the transformations referenced from the list.
608          */
609         struct {
610                 float x, y; /* surface translation on display */
611                 int32_t width, height;
612
613                 /* struct weston_transform */
614                 struct wl_list transformation_list;
615
616                 /* managed by weston_surface_set_transform_parent() */
617                 struct weston_surface *parent;
618                 struct wl_listener parent_destroy_listener;
619                 struct wl_list child_list; /* geometry.parent_link */
620                 struct wl_list parent_link;
621         } geometry;
622
623         /* State derived from geometry state, read-only.
624          * This is updated by weston_surface_update_transform().
625          */
626         struct {
627                 int dirty;
628
629                 pixman_region32_t boundingbox;
630                 pixman_region32_t opaque;
631
632                 /* matrix and inverse are used only if enabled = 1.
633                  * If enabled = 0, use x, y, width, height directly.
634                  */
635                 int enabled;
636                 struct weston_matrix matrix;
637                 struct weston_matrix inverse;
638
639                 struct weston_transform position; /* matrix from x, y */
640         } transform;
641
642         /*
643          * Which output to vsync this surface to.
644          * Used to determine, whether to send or queue frame events.
645          * Must be NULL, if 'link' is not in weston_compositor::surface_list.
646          */
647         struct weston_output *output;
648
649         /*
650          * A more complete representation of all outputs this surface is
651          * displayed on.
652          */
653         uint32_t output_mask;
654
655         struct wl_list frame_callback_list;
656
657         struct weston_buffer_reference buffer_ref;
658         uint32_t buffer_transform;
659         int keep_buffer; /* bool for backends to prevent early release */
660
661         /* All the pending state, that wl_surface.commit will apply. */
662         struct {
663                 /* wl_surface.attach */
664                 int newly_attached;
665                 struct wl_buffer *buffer;
666                 struct wl_listener buffer_destroy_listener;
667                 int32_t sx;
668                 int32_t sy;
669
670                 /* wl_surface.damage */
671                 pixman_region32_t damage;
672
673                 /* wl_surface.set_opaque_region */
674                 pixman_region32_t opaque;
675
676                 /* wl_surface.set_input_region */
677                 pixman_region32_t input;
678
679                 /* wl_surface.frame */
680                 struct wl_list frame_callback_list;
681
682                 /* wl_surface.set_buffer_transform */
683                 uint32_t buffer_transform;
684         } pending;
685
686         /*
687          * If non-NULL, this function will be called on surface::attach after
688          * a new buffer has been set up for this surface. The integer params
689          * are the sx and sy paramerters supplied to surface::attach .
690          */
691         void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height);
692         void *configure_private;
693 };
694
695 enum weston_key_state_update {
696         STATE_UPDATE_AUTOMATIC,
697         STATE_UPDATE_NONE,
698 };
699
700 void
701 weston_version(int *major, int *minor, int *micro);
702
703 void
704 weston_surface_update_transform(struct weston_surface *surface);
705
706 void
707 weston_surface_geometry_dirty(struct weston_surface *surface);
708
709 void
710 weston_surface_to_global_fixed(struct weston_surface *surface,
711                                wl_fixed_t sx, wl_fixed_t sy,
712                                wl_fixed_t *x, wl_fixed_t *y);
713 void
714 weston_surface_to_global_float(struct weston_surface *surface,
715                                float sx, float sy, float *x, float *y);
716
717 void
718 weston_surface_from_global_float(struct weston_surface *surface,
719                                  float x, float y, float *sx, float *sy);
720 void
721 weston_surface_from_global(struct weston_surface *surface,
722                            int32_t x, int32_t y, int32_t *sx, int32_t *sy);
723 void
724 weston_surface_from_global_fixed(struct weston_surface *surface,
725                                  wl_fixed_t x, wl_fixed_t y,
726                                  wl_fixed_t *sx, wl_fixed_t *sy);
727 int32_t
728 weston_surface_buffer_width(struct weston_surface *surface);
729 int32_t
730 weston_surface_buffer_height(struct weston_surface *surface);
731
732 WL_EXPORT void
733 weston_surface_to_buffer_float(struct weston_surface *surface,
734                                float x, float y, float *bx, float *by);
735 pixman_box32_t
736 weston_surface_to_buffer_rect(struct weston_surface *surface,
737                               pixman_box32_t rect);
738
739 void
740 weston_spring_init(struct weston_spring *spring,
741                    double k, double current, double target);
742 void
743 weston_spring_update(struct weston_spring *spring, uint32_t msec);
744 int
745 weston_spring_done(struct weston_spring *spring);
746
747 void
748 weston_surface_activate(struct weston_surface *surface,
749                         struct weston_seat *seat);
750 void
751 notify_motion(struct weston_seat *seat, uint32_t time,
752               wl_fixed_t dx, wl_fixed_t dy);
753 void
754 notify_motion_absolute(struct weston_seat *seat, uint32_t time,
755                        wl_fixed_t x, wl_fixed_t y);
756 void
757 notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
758               enum wl_pointer_button_state state);
759 void
760 notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
761             wl_fixed_t value);
762 void
763 notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
764            enum wl_keyboard_key_state state,
765            enum weston_key_state_update update_state);
766 void
767 notify_modifiers(struct weston_seat *seat, uint32_t serial);
768
769 void
770 notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
771                      wl_fixed_t x, wl_fixed_t y);
772
773 void
774 notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
775                          enum weston_key_state_update update_state);
776 void
777 notify_keyboard_focus_out(struct weston_seat *seat);
778
779 void
780 notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
781              wl_fixed_t x, wl_fixed_t y, int touch_type);
782
783 void
784 weston_layer_init(struct weston_layer *layer, struct wl_list *below);
785
786 void
787 weston_plane_init(struct weston_plane *plane, int32_t x, int32_t y);
788 void
789 weston_plane_release(struct weston_plane *plane);
790
791 void
792 weston_compositor_stack_plane(struct weston_compositor *ec,
793                               struct weston_plane *plane,
794                               struct weston_plane *above);
795
796 void
797 weston_output_finish_frame(struct weston_output *output, uint32_t msecs);
798 void
799 weston_output_schedule_repaint(struct weston_output *output);
800 void
801 weston_output_damage(struct weston_output *output);
802 void
803 weston_compositor_schedule_repaint(struct weston_compositor *compositor);
804 void
805 weston_compositor_fade(struct weston_compositor *compositor, float tint);
806 void
807 weston_compositor_damage_all(struct weston_compositor *compositor);
808 void
809 weston_compositor_unlock(struct weston_compositor *compositor);
810 void
811 weston_compositor_wake(struct weston_compositor *compositor);
812 void
813 weston_compositor_offscreen(struct weston_compositor *compositor);
814 void
815 weston_compositor_sleep(struct weston_compositor *compositor);
816 struct weston_surface *
817 weston_compositor_pick_surface(struct weston_compositor *compositor,
818                                wl_fixed_t x, wl_fixed_t y,
819                                wl_fixed_t *sx, wl_fixed_t *sy);
820
821
822 struct weston_binding;
823 typedef void (*weston_key_binding_handler_t)(struct weston_seat *seat,
824                                              uint32_t time, uint32_t key,
825                                              void *data);
826 struct weston_binding *
827 weston_compositor_add_key_binding(struct weston_compositor *compositor,
828                                   uint32_t key,
829                                   enum weston_keyboard_modifier modifier,
830                                   weston_key_binding_handler_t binding,
831                                   void *data);
832
833 typedef void (*weston_button_binding_handler_t)(struct weston_seat *seat,
834                                                 uint32_t time, uint32_t button,
835                                                 void *data);
836 struct weston_binding *
837 weston_compositor_add_button_binding(struct weston_compositor *compositor,
838                                      uint32_t button,
839                                      enum weston_keyboard_modifier modifier,
840                                      weston_button_binding_handler_t binding,
841                                      void *data);
842
843 typedef void (*weston_axis_binding_handler_t)(struct weston_seat *seat,
844                                               uint32_t time, uint32_t axis,
845                                               wl_fixed_t value, void *data);
846 struct weston_binding *
847 weston_compositor_add_axis_binding(struct weston_compositor *compositor,
848                                    uint32_t axis,
849                                    enum weston_keyboard_modifier modifier,
850                                    weston_axis_binding_handler_t binding,
851                                    void *data);
852 struct weston_binding *
853 weston_compositor_add_debug_binding(struct weston_compositor *compositor,
854                                     uint32_t key,
855                                     weston_key_binding_handler_t binding,
856                                     void *data);
857 void
858 weston_binding_destroy(struct weston_binding *binding);
859
860 void
861 weston_binding_list_destroy_all(struct wl_list *list);
862
863 void
864 weston_compositor_run_key_binding(struct weston_compositor *compositor,
865                                   struct weston_seat *seat, uint32_t time,
866                                   uint32_t key,
867                                   enum wl_keyboard_key_state state);
868 void
869 weston_compositor_run_button_binding(struct weston_compositor *compositor,
870                                      struct weston_seat *seat, uint32_t time,
871                                      uint32_t button,
872                                      enum wl_pointer_button_state value);
873 int
874 weston_compositor_run_axis_binding(struct weston_compositor *compositor,
875                                    struct weston_seat *seat, uint32_t time,
876                                    uint32_t axis, int32_t value);
877 int
878 weston_compositor_run_debug_binding(struct weston_compositor *compositor,
879                                     struct weston_seat *seat, uint32_t time,
880                                     uint32_t key,
881                                     enum wl_keyboard_key_state state);
882
883 int
884 weston_environment_get_fd(const char *env);
885
886 struct wl_list *
887 weston_compositor_top(struct weston_compositor *compositor);
888
889 struct weston_surface *
890 weston_surface_create(struct weston_compositor *compositor);
891
892 void
893 weston_surface_configure(struct weston_surface *surface,
894                          float x, float y, int width, int height);
895
896 void
897 weston_surface_restack(struct weston_surface *surface, struct wl_list *below);
898
899 void
900 weston_surface_set_position(struct weston_surface *surface,
901                             float x, float y);
902
903 void
904 weston_surface_set_transform_parent(struct weston_surface *surface,
905                                     struct weston_surface *parent);
906
907 int
908 weston_surface_is_mapped(struct weston_surface *surface);
909
910 void
911 weston_surface_schedule_repaint(struct weston_surface *surface);
912
913 void
914 weston_surface_damage(struct weston_surface *surface);
915
916 void
917 weston_surface_damage_below(struct weston_surface *surface);
918
919 void
920 weston_surface_move_to_plane(struct weston_surface *surface,
921                              struct weston_plane *plane);
922 void
923 weston_surface_unmap(struct weston_surface *surface);
924
925 void
926 weston_buffer_reference(struct weston_buffer_reference *ref,
927                         struct wl_buffer *buffer);
928
929 uint32_t
930 weston_compositor_get_time(void);
931
932 int
933 weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
934                        int *argc, char *argv[], const char *config_file);
935 void
936 weston_compositor_shutdown(struct weston_compositor *ec);
937 void
938 weston_text_cursor_position_notify(struct weston_surface *surface,
939                                                 wl_fixed_t x, wl_fixed_t y);
940 void
941 weston_output_init_zoom(struct weston_output *output);
942 void
943 weston_output_update_zoom(struct weston_output *output, uint32_t type);
944 void
945 weston_output_update_matrix(struct weston_output *output);
946 void
947 weston_output_move(struct weston_output *output, int x, int y);
948 void
949 weston_output_init(struct weston_output *output, struct weston_compositor *c,
950                    int x, int y, int width, int height, uint32_t transform);
951 void
952 weston_output_destroy(struct weston_output *output);
953
954 void
955 weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec);
956 void
957 weston_seat_init_pointer(struct weston_seat *seat);
958 int
959 weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
960 void
961 weston_seat_init_touch(struct weston_seat *seat);
962 void
963 weston_seat_repick(struct weston_seat *seat);
964
965 void
966 weston_seat_release(struct weston_seat *seat);
967 int
968 weston_compositor_xkb_init(struct weston_compositor *ec,
969                            struct xkb_rule_names *names);
970 void
971 weston_compositor_xkb_destroy(struct weston_compositor *ec);
972
973 /* String literal of spaces, the same width as the timestamp. */
974 #define STAMP_SPACE "               "
975
976 void
977 weston_log_file_open(const char *filename);
978 void
979 weston_log_file_close(void);
980 int
981 weston_log(const char *fmt, ...)
982         __attribute__ ((format (printf, 1, 2)));
983 int
984 weston_log_continue(const char *fmt, ...)
985         __attribute__ ((format (printf, 1, 2)));
986
987 enum {
988         TTY_ENTER_VT,
989         TTY_LEAVE_VT
990 };
991
992 typedef void (*tty_vt_func_t)(struct weston_compositor *compositor, int event);
993
994 struct tty *
995 tty_create(struct weston_compositor *compositor,
996            tty_vt_func_t vt_func, int tty_nr);
997
998 void
999 tty_destroy(struct tty *tty);
1000
1001 void
1002 tty_reset(struct tty *tty);
1003
1004 int
1005 tty_activate_vt(struct tty *tty, int vt);
1006
1007 void
1008 screenshooter_create(struct weston_compositor *ec);
1009
1010 struct clipboard *
1011 clipboard_create(struct weston_seat *seat);
1012
1013 void
1014 text_cursor_position_notifier_create(struct weston_compositor *ec);
1015
1016 int
1017 text_backend_init(struct weston_compositor *ec);
1018
1019 struct weston_process;
1020 typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,
1021                                             int status);
1022
1023 struct weston_process {
1024         pid_t pid;
1025         weston_process_cleanup_func_t cleanup;
1026         struct wl_list link;
1027 };
1028
1029 struct wl_client *
1030 weston_client_launch(struct weston_compositor *compositor,
1031                      struct weston_process *proc,
1032                      const char *path,
1033                      weston_process_cleanup_func_t cleanup);
1034
1035 void
1036 weston_watch_process(struct weston_process *process);
1037
1038 struct weston_surface_animation;
1039 typedef void (*weston_surface_animation_done_func_t)(struct weston_surface_animation *animation, void *data);
1040
1041 struct weston_surface_animation *
1042 weston_zoom_run(struct weston_surface *surface, float start, float stop,
1043                 weston_surface_animation_done_func_t done, void *data);
1044
1045 struct weston_surface_animation *
1046 weston_fade_run(struct weston_surface *surface,
1047                 float start, float end, float k,
1048                 weston_surface_animation_done_func_t done, void *data);
1049 void
1050 weston_fade_update(struct weston_surface_animation *fade,
1051                    float start, float end, float k);
1052
1053 struct weston_surface_animation *
1054 weston_slide_run(struct weston_surface *surface, float start, float stop,
1055                  weston_surface_animation_done_func_t done, void *data);
1056
1057 void
1058 weston_surface_set_color(struct weston_surface *surface,
1059                          float red, float green, float blue, float alpha);
1060
1061 void
1062 weston_surface_destroy(struct weston_surface *surface);
1063
1064 int
1065 weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode);
1066
1067 int
1068 noop_renderer_init(struct weston_compositor *ec);
1069
1070 struct weston_compositor *
1071 backend_init(struct wl_display *display, int *argc, char *argv[],
1072              const char *config_file);
1073
1074 int
1075 module_init(struct weston_compositor *compositor,
1076             int *argc, char *argv[], const char *config_file);
1077
1078 void
1079 weston_transformed_coord(int width, int height,
1080                          enum wl_output_transform transform,
1081                          float sx, float sy, float *bx, float *by);
1082 pixman_box32_t
1083 weston_transformed_rect(int width, int height,
1084                         enum wl_output_transform transform,
1085                         pixman_box32_t rect);
1086
1087 #ifdef  __cplusplus
1088 }
1089 #endif
1090
1091 #endif