06476ccfc4edcea9575e7811b16abb7226b56136
[platform/upstream/weston.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
39 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
40
41 #define container_of(ptr, type, member) ({                              \
42         const __typeof__( ((type *)0)->member ) *__mptr = (ptr);        \
43         (type *)( (char *)__mptr - offsetof(type,member) );})
44
45 struct weston_transform {
46         struct weston_matrix matrix;
47         struct wl_list link;
48 };
49
50 struct weston_surface;
51 struct shell_surface;
52 struct weston_seat;
53 struct weston_output;
54 struct input_method;
55
56 enum weston_keyboard_modifier {
57         MODIFIER_CTRL = (1 << 0),
58         MODIFIER_ALT = (1 << 1),
59         MODIFIER_SUPER = (1 << 2),
60         MODIFIER_SHIFT = (1 << 3),
61 };
62
63 enum weston_led {
64         LED_NUM_LOCK = (1 << 0),
65         LED_CAPS_LOCK = (1 << 1),
66         LED_SCROLL_LOCK = (1 << 2),
67 };
68
69 struct weston_mode {
70         uint32_t flags;
71         int32_t width, height;
72         uint32_t refresh;
73         struct wl_list link;
74 };
75
76 struct weston_shell_client {
77         void (*send_configure)(struct weston_surface *surface,
78                                uint32_t edges, int32_t width, int32_t height);
79 };
80
81 struct weston_shell_interface {
82         void *shell;                    /* either desktop or tablet */
83
84         struct shell_surface *(*create_shell_surface)(void *shell,
85                                                       struct weston_surface *surface,
86                                                       const struct weston_shell_client *client);
87
88         void (*set_toplevel)(struct shell_surface *shsurf);
89
90         void (*set_transient)(struct shell_surface *shsurf,
91                               struct weston_surface *parent,
92                               int x, int y, uint32_t flags);
93         void (*set_fullscreen)(struct shell_surface *shsurf,
94                                uint32_t method,
95                                uint32_t framerate,
96                                struct weston_output *output);
97         int (*move)(struct shell_surface *shsurf, struct weston_seat *ws);
98         int (*resize)(struct shell_surface *shsurf,
99                       struct weston_seat *ws, uint32_t edges);
100
101 };
102
103 struct weston_border {
104         int32_t left, right, top, bottom;
105 };
106
107 struct weston_animation {
108         void (*frame)(struct weston_animation *animation,
109                       struct weston_output *output, uint32_t msecs);
110         int frame_counter;
111         struct wl_list link;
112 };
113
114 struct weston_spring {
115         double k;
116         double friction;
117         double current;
118         double target;
119         double previous;
120         uint32_t timestamp;
121 };
122
123 enum {
124         ZOOM_FOCUS_POINTER,
125         ZOOM_FOCUS_TEXT
126 };
127
128 struct weston_fixed_point {
129         wl_fixed_t x, y;
130 };
131
132 struct weston_output_zoom {
133         int active;
134         uint32_t type;
135         float increment;
136         float level;
137         float max_level;
138         float trans_x, trans_y;
139         struct weston_animation animation_z;
140         struct weston_spring spring_z;
141         struct weston_animation animation_xy;
142         struct weston_spring spring_xy;
143         struct weston_fixed_point from;
144         struct weston_fixed_point to;
145         struct weston_fixed_point current;
146         struct weston_fixed_point text_cursor;
147 };
148
149 /* bit compatible with drm definitions. */
150 enum dpms_enum {
151         WESTON_DPMS_ON,
152         WESTON_DPMS_STANDBY,
153         WESTON_DPMS_SUSPEND,
154         WESTON_DPMS_OFF
155 };
156
157 struct weston_output {
158         uint32_t id;
159         char *name;
160
161         void *renderer_state;
162
163         struct wl_list link;
164         struct wl_list resource_list;
165         struct wl_global *global;
166         struct weston_compositor *compositor;
167         struct weston_matrix matrix;
168         struct wl_list animation_list;
169         int32_t x, y, width, height;
170         int32_t mm_width, mm_height;
171         struct weston_border border;
172         pixman_region32_t region;
173         pixman_region32_t previous_damage;
174         int repaint_needed;
175         int repaint_scheduled;
176         struct weston_output_zoom zoom;
177         int dirty;
178         struct wl_signal frame_signal;
179         struct wl_signal destroy_signal;
180         uint32_t frame_time;
181         int disable_planes;
182
183         char *make, *model, *serial_number;
184         uint32_t subpixel;
185         uint32_t transform;
186         uint32_t scale;
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 enum weston_capability {
489         /* backend/renderer supports arbitrary rotation */
490         WESTON_CAP_ROTATION_ANY                 = 0x0001,
491
492         /* screencaptures need to be y-flipped */
493         WESTON_CAP_CAPTURE_YFLIP                = 0x0002,
494 };
495
496 struct weston_compositor {
497         struct wl_signal destroy_signal;
498
499         struct wl_display *wl_display;
500         struct weston_shell_interface shell_interface;
501
502         struct wl_signal activate_signal;
503         struct wl_signal kill_signal;
504         struct wl_signal idle_signal;
505         struct wl_signal wake_signal;
506
507         struct wl_signal show_input_panel_signal;
508         struct wl_signal hide_input_panel_signal;
509         struct wl_signal update_input_panel_signal;
510
511         struct wl_signal seat_created_signal;
512         struct wl_signal output_created_signal;
513
514         struct wl_event_loop *input_loop;
515         struct wl_event_source *input_loop_source;
516
517         struct weston_layer fade_layer;
518         struct weston_layer cursor_layer;
519
520         struct wl_list output_list;
521         struct wl_list seat_list;
522         struct wl_list layer_list;
523         struct wl_list surface_list;
524         struct wl_list plane_list;
525         struct wl_list key_binding_list;
526         struct wl_list button_binding_list;
527         struct wl_list axis_binding_list;
528         struct wl_list debug_binding_list;
529
530         uint32_t state;
531         struct wl_event_source *idle_source;
532         uint32_t idle_inhibit;
533         int idle_time;                  /* timeout, s */
534
535         /* Repaint state. */
536         struct weston_plane primary_plane;
537         uint32_t capabilities; /* combination of enum weston_capability */
538
539         uint32_t focus;
540
541         struct weston_renderer *renderer;
542
543         pixman_format_code_t read_format;
544
545         void (*destroy)(struct weston_compositor *ec);
546         void (*restore)(struct weston_compositor *ec);
547         int (*authenticate)(struct weston_compositor *c, uint32_t id);
548
549         void (*ping_handler)(struct weston_surface *surface, uint32_t serial);
550
551         int launcher_sock;
552
553         uint32_t output_id_pool;
554
555         struct xkb_rule_names xkb_names;
556         struct xkb_context *xkb_context;
557         struct weston_xkb_info xkb_info;
558
559         int config_fd;
560 };
561
562 struct weston_buffer_reference {
563         struct wl_buffer *buffer;
564         struct wl_listener destroy_listener;
565 };
566
567 struct weston_region {
568         struct wl_resource resource;
569         pixman_region32_t region;
570 };
571
572 struct weston_subsurface {
573         struct wl_resource *resource;
574
575         /* guaranteed to be valid and non-NULL */
576         struct weston_surface *surface;
577         struct wl_listener surface_destroy_listener;
578
579         /* can be NULL */
580         struct weston_surface *parent;
581         struct wl_listener parent_destroy_listener;
582         struct wl_list parent_link;
583         struct wl_list parent_link_pending;
584
585         struct {
586                 int32_t x;
587                 int32_t y;
588                 int set;
589         } position;
590
591         struct {
592                 int has_data;
593
594                 /* wl_surface.attach */
595                 int newly_attached;
596                 struct weston_buffer_reference buffer_ref;
597                 int32_t sx;
598                 int32_t sy;
599
600                 /* wl_surface.damage */
601                 pixman_region32_t damage;
602
603                 /* wl_surface.set_opaque_region */
604                 pixman_region32_t opaque;
605
606                 /* wl_surface.set_input_region */
607                 pixman_region32_t input;
608
609                 /* wl_surface.frame */
610                 struct wl_list frame_callback_list;
611
612                 /* wl_surface.set_buffer_transform */
613                 uint32_t buffer_transform;
614
615                 /* wl_surface.set_buffer_scale */
616                 uint32_t buffer_scale;
617         } cached;
618
619         int synchronized;
620 };
621
622 /* Using weston_surface transformations
623  *
624  * To add a transformation to a surface, create a struct weston_transform, and
625  * add it to the list surface->geometry.transformation_list. Whenever you
626  * change the list, anything under surface->geometry, or anything in the
627  * weston_transforms linked into the list, you must call
628  * weston_surface_geometry_dirty().
629  *
630  * The order in the list defines the order of transformations. Let the list
631  * contain the transformation matrices M1, ..., Mn as head to tail. The
632  * transformation is applied to surface-local coordinate vector p as
633  *    P = Mn * ... * M2 * M1 * p
634  * to produce the global coordinate vector P. The total transform
635  *    Mn * ... * M2 * M1
636  * is cached in surface->transform.matrix, and the inverse of it in
637  * surface->transform.inverse.
638  *
639  * The list always contains surface->transform.position transformation, which
640  * is the translation by surface->geometry.x and y.
641  *
642  * If you want to apply a transformation in local coordinates, add your
643  * weston_transform to the head of the list. If you want to apply a
644  * transformation in global coordinates, add it to the tail of the list.
645  *
646  * If surface->geometry.parent is set, the total transformation of this
647  * surface will be the parent's total transformation and this transformation
648  * combined:
649  *    Mparent * Mn * ... * M2 * M1
650  */
651
652 struct weston_surface {
653         struct wl_resource resource;
654         struct weston_compositor *compositor;
655         pixman_region32_t clip;
656         pixman_region32_t damage;
657         pixman_region32_t opaque;        /* part of geometry, see below */
658         pixman_region32_t input;
659         struct wl_list link;
660         struct wl_list layer_link;
661         float alpha;                     /* part of geometry, see below */
662         struct weston_plane *plane;
663
664         void *renderer_state;
665
666         /* Surface geometry state, mutable.
667          * If you change anything, call weston_surface_geometry_dirty().
668          * That includes the transformations referenced from the list.
669          */
670         struct {
671                 float x, y; /* surface translation on display */
672                 int32_t width, height;
673
674                 /* struct weston_transform */
675                 struct wl_list transformation_list;
676
677                 /* managed by weston_surface_set_transform_parent() */
678                 struct weston_surface *parent;
679                 struct wl_listener parent_destroy_listener;
680                 struct wl_list child_list; /* geometry.parent_link */
681                 struct wl_list parent_link;
682         } geometry;
683
684         /* State derived from geometry state, read-only.
685          * This is updated by weston_surface_update_transform().
686          */
687         struct {
688                 int dirty;
689
690                 pixman_region32_t boundingbox;
691                 pixman_region32_t opaque;
692
693                 /* matrix and inverse are used only if enabled = 1.
694                  * If enabled = 0, use x, y, width, height directly.
695                  */
696                 int enabled;
697                 struct weston_matrix matrix;
698                 struct weston_matrix inverse;
699
700                 struct weston_transform position; /* matrix from x, y */
701         } transform;
702
703         /*
704          * Which output to vsync this surface to.
705          * Used to determine, whether to send or queue frame events.
706          * Must be NULL, if 'link' is not in weston_compositor::surface_list.
707          */
708         struct weston_output *output;
709
710         /*
711          * A more complete representation of all outputs this surface is
712          * displayed on.
713          */
714         uint32_t output_mask;
715
716         struct wl_list frame_callback_list;
717
718         struct weston_buffer_reference buffer_ref;
719         uint32_t buffer_transform;
720         uint32_t buffer_scale;
721         int keep_buffer; /* bool for backends to prevent early release */
722
723         /* All the pending state, that wl_surface.commit will apply. */
724         struct {
725                 /* wl_surface.attach */
726                 int newly_attached;
727                 struct wl_buffer *buffer;
728                 struct wl_listener buffer_destroy_listener;
729                 int32_t sx;
730                 int32_t sy;
731
732                 /* wl_surface.damage */
733                 pixman_region32_t damage;
734
735                 /* wl_surface.set_opaque_region */
736                 pixman_region32_t opaque;
737
738                 /* wl_surface.set_input_region */
739                 pixman_region32_t input;
740
741                 /* wl_surface.frame */
742                 struct wl_list frame_callback_list;
743
744                 /* wl_surface.set_buffer_transform */
745                 uint32_t buffer_transform;
746
747                 /* wl_surface.set_scaling_factor */
748                 uint32_t buffer_scale;
749         } pending;
750
751         /*
752          * If non-NULL, this function will be called on surface::attach after
753          * a new buffer has been set up for this surface. The integer params
754          * are the sx and sy paramerters supplied to surface::attach .
755          */
756         void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height);
757         void *configure_private;
758
759         /* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
760          * Contains also the parent itself as a dummy weston_subsurface,
761          * if the list is not empty.
762          */
763         struct wl_list subsurface_list; /* weston_subsurface::parent_link */
764         struct wl_list subsurface_list_pending; /* ...::parent_link_pending */
765 };
766
767 enum weston_key_state_update {
768         STATE_UPDATE_AUTOMATIC,
769         STATE_UPDATE_NONE,
770 };
771
772 void
773 weston_version(int *major, int *minor, int *micro);
774
775 void
776 weston_surface_update_transform(struct weston_surface *surface);
777
778 void
779 weston_surface_geometry_dirty(struct weston_surface *surface);
780
781 void
782 weston_surface_to_global_fixed(struct weston_surface *surface,
783                                wl_fixed_t sx, wl_fixed_t sy,
784                                wl_fixed_t *x, wl_fixed_t *y);
785 void
786 weston_surface_to_global_float(struct weston_surface *surface,
787                                float sx, float sy, float *x, float *y);
788
789 void
790 weston_surface_from_global_float(struct weston_surface *surface,
791                                  float x, float y, float *sx, float *sy);
792 void
793 weston_surface_from_global(struct weston_surface *surface,
794                            int32_t x, int32_t y, int32_t *sx, int32_t *sy);
795 void
796 weston_surface_from_global_fixed(struct weston_surface *surface,
797                                  wl_fixed_t x, wl_fixed_t y,
798                                  wl_fixed_t *sx, wl_fixed_t *sy);
799 int32_t
800 weston_surface_buffer_width(struct weston_surface *surface);
801 int32_t
802 weston_surface_buffer_height(struct weston_surface *surface);
803
804 WL_EXPORT void
805 weston_surface_to_buffer_float(struct weston_surface *surface,
806                                float x, float y, float *bx, float *by);
807 WL_EXPORT void
808 weston_surface_to_buffer(struct weston_surface *surface,
809                          int sx, int sy, int *bx, int *by);
810
811 pixman_box32_t
812 weston_surface_to_buffer_rect(struct weston_surface *surface,
813                               pixman_box32_t rect);
814
815 void
816 weston_spring_init(struct weston_spring *spring,
817                    double k, double current, double target);
818 void
819 weston_spring_update(struct weston_spring *spring, uint32_t msec);
820 int
821 weston_spring_done(struct weston_spring *spring);
822
823 void
824 weston_surface_activate(struct weston_surface *surface,
825                         struct weston_seat *seat);
826 void
827 notify_motion(struct weston_seat *seat, uint32_t time,
828               wl_fixed_t dx, wl_fixed_t dy);
829 void
830 notify_motion_absolute(struct weston_seat *seat, uint32_t time,
831                        wl_fixed_t x, wl_fixed_t y);
832 void
833 notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
834               enum wl_pointer_button_state state);
835 void
836 notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis,
837             wl_fixed_t value);
838 void
839 notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
840            enum wl_keyboard_key_state state,
841            enum weston_key_state_update update_state);
842 void
843 notify_modifiers(struct weston_seat *seat, uint32_t serial);
844
845 void
846 notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
847                      wl_fixed_t x, wl_fixed_t y);
848
849 void
850 notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
851                          enum weston_key_state_update update_state);
852 void
853 notify_keyboard_focus_out(struct weston_seat *seat);
854
855 void
856 notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
857              wl_fixed_t x, wl_fixed_t y, int touch_type);
858
859 void
860 weston_layer_init(struct weston_layer *layer, struct wl_list *below);
861
862 void
863 weston_plane_init(struct weston_plane *plane, int32_t x, int32_t y);
864 void
865 weston_plane_release(struct weston_plane *plane);
866
867 void
868 weston_compositor_stack_plane(struct weston_compositor *ec,
869                               struct weston_plane *plane,
870                               struct weston_plane *above);
871
872 void
873 weston_output_finish_frame(struct weston_output *output, uint32_t msecs);
874 void
875 weston_output_schedule_repaint(struct weston_output *output);
876 void
877 weston_output_damage(struct weston_output *output);
878 void
879 weston_compositor_schedule_repaint(struct weston_compositor *compositor);
880 void
881 weston_compositor_fade(struct weston_compositor *compositor, float tint);
882 void
883 weston_compositor_damage_all(struct weston_compositor *compositor);
884 void
885 weston_compositor_unlock(struct weston_compositor *compositor);
886 void
887 weston_compositor_wake(struct weston_compositor *compositor);
888 void
889 weston_compositor_offscreen(struct weston_compositor *compositor);
890 void
891 weston_compositor_sleep(struct weston_compositor *compositor);
892 struct weston_surface *
893 weston_compositor_pick_surface(struct weston_compositor *compositor,
894                                wl_fixed_t x, wl_fixed_t y,
895                                wl_fixed_t *sx, wl_fixed_t *sy);
896
897
898 struct weston_binding;
899 typedef void (*weston_key_binding_handler_t)(struct weston_seat *seat,
900                                              uint32_t time, uint32_t key,
901                                              void *data);
902 struct weston_binding *
903 weston_compositor_add_key_binding(struct weston_compositor *compositor,
904                                   uint32_t key,
905                                   enum weston_keyboard_modifier modifier,
906                                   weston_key_binding_handler_t binding,
907                                   void *data);
908
909 typedef void (*weston_button_binding_handler_t)(struct weston_seat *seat,
910                                                 uint32_t time, uint32_t button,
911                                                 void *data);
912 struct weston_binding *
913 weston_compositor_add_button_binding(struct weston_compositor *compositor,
914                                      uint32_t button,
915                                      enum weston_keyboard_modifier modifier,
916                                      weston_button_binding_handler_t binding,
917                                      void *data);
918
919 typedef void (*weston_axis_binding_handler_t)(struct weston_seat *seat,
920                                               uint32_t time, uint32_t axis,
921                                               wl_fixed_t value, void *data);
922 struct weston_binding *
923 weston_compositor_add_axis_binding(struct weston_compositor *compositor,
924                                    uint32_t axis,
925                                    enum weston_keyboard_modifier modifier,
926                                    weston_axis_binding_handler_t binding,
927                                    void *data);
928 struct weston_binding *
929 weston_compositor_add_debug_binding(struct weston_compositor *compositor,
930                                     uint32_t key,
931                                     weston_key_binding_handler_t binding,
932                                     void *data);
933 void
934 weston_binding_destroy(struct weston_binding *binding);
935
936 void
937 weston_binding_list_destroy_all(struct wl_list *list);
938
939 void
940 weston_compositor_run_key_binding(struct weston_compositor *compositor,
941                                   struct weston_seat *seat, uint32_t time,
942                                   uint32_t key,
943                                   enum wl_keyboard_key_state state);
944 void
945 weston_compositor_run_button_binding(struct weston_compositor *compositor,
946                                      struct weston_seat *seat, uint32_t time,
947                                      uint32_t button,
948                                      enum wl_pointer_button_state value);
949 int
950 weston_compositor_run_axis_binding(struct weston_compositor *compositor,
951                                    struct weston_seat *seat, uint32_t time,
952                                    uint32_t axis, int32_t value);
953 int
954 weston_compositor_run_debug_binding(struct weston_compositor *compositor,
955                                     struct weston_seat *seat, uint32_t time,
956                                     uint32_t key,
957                                     enum wl_keyboard_key_state state);
958
959 int
960 weston_environment_get_fd(const char *env);
961
962 struct wl_list *
963 weston_compositor_top(struct weston_compositor *compositor);
964
965 struct weston_surface *
966 weston_surface_create(struct weston_compositor *compositor);
967
968 void
969 weston_surface_configure(struct weston_surface *surface,
970                          float x, float y, int width, int height);
971
972 void
973 weston_surface_restack(struct weston_surface *surface, struct wl_list *below);
974
975 void
976 weston_surface_set_position(struct weston_surface *surface,
977                             float x, float y);
978
979 void
980 weston_surface_set_transform_parent(struct weston_surface *surface,
981                                     struct weston_surface *parent);
982
983 int
984 weston_surface_is_mapped(struct weston_surface *surface);
985
986 void
987 weston_surface_schedule_repaint(struct weston_surface *surface);
988
989 void
990 weston_surface_damage(struct weston_surface *surface);
991
992 void
993 weston_surface_damage_below(struct weston_surface *surface);
994
995 void
996 weston_surface_move_to_plane(struct weston_surface *surface,
997                              struct weston_plane *plane);
998 void
999 weston_surface_unmap(struct weston_surface *surface);
1000
1001 struct weston_surface *
1002 weston_surface_get_main_surface(struct weston_surface *surface);
1003
1004 void
1005 weston_buffer_reference(struct weston_buffer_reference *ref,
1006                         struct wl_buffer *buffer);
1007
1008 uint32_t
1009 weston_compositor_get_time(void);
1010
1011 int
1012 weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
1013                        int *argc, char *argv[], int config_fd);
1014 void
1015 weston_compositor_shutdown(struct weston_compositor *ec);
1016 void
1017 weston_text_cursor_position_notify(struct weston_surface *surface,
1018                                                 wl_fixed_t x, wl_fixed_t y);
1019 void
1020 weston_output_init_zoom(struct weston_output *output);
1021 void
1022 weston_output_update_zoom(struct weston_output *output, uint32_t type);
1023 void
1024 weston_output_update_matrix(struct weston_output *output);
1025 void
1026 weston_output_move(struct weston_output *output, int x, int y);
1027 void
1028 weston_output_init(struct weston_output *output, struct weston_compositor *c,
1029                    int x, int y, int width, int height, uint32_t transform, uint32_t scale);
1030 void
1031 weston_output_destroy(struct weston_output *output);
1032
1033 void
1034 weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec);
1035 void
1036 weston_seat_init_pointer(struct weston_seat *seat);
1037 int
1038 weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
1039 void
1040 weston_seat_init_touch(struct weston_seat *seat);
1041 void
1042 weston_seat_repick(struct weston_seat *seat);
1043
1044 void
1045 weston_seat_release(struct weston_seat *seat);
1046 int
1047 weston_compositor_xkb_init(struct weston_compositor *ec,
1048                            struct xkb_rule_names *names);
1049 void
1050 weston_compositor_xkb_destroy(struct weston_compositor *ec);
1051
1052 /* String literal of spaces, the same width as the timestamp. */
1053 #define STAMP_SPACE "               "
1054
1055 void
1056 weston_log_file_open(const char *filename);
1057 void
1058 weston_log_file_close(void);
1059 int
1060 weston_log(const char *fmt, ...)
1061         __attribute__ ((format (printf, 1, 2)));
1062 int
1063 weston_log_continue(const char *fmt, ...)
1064         __attribute__ ((format (printf, 1, 2)));
1065
1066 enum {
1067         TTY_ENTER_VT,
1068         TTY_LEAVE_VT
1069 };
1070
1071 typedef void (*tty_vt_func_t)(struct weston_compositor *compositor, int event);
1072
1073 struct tty *
1074 tty_create(struct weston_compositor *compositor,
1075            tty_vt_func_t vt_func, int tty_nr);
1076
1077 void
1078 tty_destroy(struct tty *tty);
1079
1080 void
1081 tty_reset(struct tty *tty);
1082
1083 int
1084 tty_activate_vt(struct tty *tty, int vt);
1085
1086 void
1087 screenshooter_create(struct weston_compositor *ec);
1088
1089 struct clipboard *
1090 clipboard_create(struct weston_seat *seat);
1091
1092 void
1093 text_cursor_position_notifier_create(struct weston_compositor *ec);
1094
1095 int
1096 text_backend_init(struct weston_compositor *ec);
1097
1098 struct weston_process;
1099 typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,
1100                                             int status);
1101
1102 struct weston_process {
1103         pid_t pid;
1104         weston_process_cleanup_func_t cleanup;
1105         struct wl_list link;
1106 };
1107
1108 struct wl_client *
1109 weston_client_launch(struct weston_compositor *compositor,
1110                      struct weston_process *proc,
1111                      const char *path,
1112                      weston_process_cleanup_func_t cleanup);
1113
1114 void
1115 weston_watch_process(struct weston_process *process);
1116
1117 struct weston_surface_animation;
1118 typedef void (*weston_surface_animation_done_func_t)(struct weston_surface_animation *animation, void *data);
1119
1120 struct weston_surface_animation *
1121 weston_zoom_run(struct weston_surface *surface, float start, float stop,
1122                 weston_surface_animation_done_func_t done, void *data);
1123
1124 struct weston_surface_animation *
1125 weston_fade_run(struct weston_surface *surface,
1126                 float start, float end, float k,
1127                 weston_surface_animation_done_func_t done, void *data);
1128 void
1129 weston_fade_update(struct weston_surface_animation *fade,
1130                    float start, float end, float k);
1131
1132 struct weston_surface_animation *
1133 weston_slide_run(struct weston_surface *surface, float start, float stop,
1134                  weston_surface_animation_done_func_t done, void *data);
1135
1136 void
1137 weston_surface_set_color(struct weston_surface *surface,
1138                          float red, float green, float blue, float alpha);
1139
1140 void
1141 weston_surface_destroy(struct weston_surface *surface);
1142
1143 int
1144 weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode);
1145
1146 int
1147 noop_renderer_init(struct weston_compositor *ec);
1148
1149 struct weston_compositor *
1150 backend_init(struct wl_display *display, int *argc, char *argv[],
1151              int config_fd);
1152
1153 int
1154 module_init(struct weston_compositor *compositor,
1155             int *argc, char *argv[]);
1156
1157 void
1158 weston_transformed_coord(int width, int height,
1159                          enum wl_output_transform transform,
1160                          uint32_t scale,
1161                          float sx, float sy, float *bx, float *by);
1162 pixman_box32_t
1163 weston_transformed_rect(int width, int height,
1164                         enum wl_output_transform transform,
1165                         uint32_t scale,
1166                         pixman_box32_t rect);
1167
1168 #ifdef  __cplusplus
1169 }
1170 #endif
1171
1172 #endif