libweston: Rename weston_surface::configure to ::committed
[platform/upstream/weston.git] / libweston / compositor.h
1 /*
2  * Copyright © 2008-2011 Kristian Høgsberg
3  * Copyright © 2012 Collabora, Ltd.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial
15  * portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24  * SOFTWARE.
25  */
26
27 #ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
28 #define _WAYLAND_SYSTEM_COMPOSITOR_H_
29
30 #ifdef  __cplusplus
31 extern "C" {
32 #endif
33
34 #include <stdbool.h>
35 #include <stdint.h>
36 #include <time.h>
37 #include <pixman.h>
38 #include <xkbcommon/xkbcommon.h>
39
40 #define WL_HIDE_DEPRECATED
41 #include <wayland-server.h>
42
43 #include "version.h"
44 #include "matrix.h"
45 #include "config-parser.h"
46 #include "zalloc.h"
47 #include "timeline-object.h"
48
49 struct weston_transform {
50         struct weston_matrix matrix;
51         struct wl_list link;
52 };
53
54 struct weston_surface;
55 struct weston_buffer;
56 struct shell_surface;
57 struct weston_seat;
58 struct weston_output;
59 struct input_method;
60 struct weston_pointer;
61 struct linux_dmabuf_buffer;
62 struct weston_recorder;
63 struct weston_pointer_constraint;
64
65 enum weston_keyboard_modifier {
66         MODIFIER_CTRL = (1 << 0),
67         MODIFIER_ALT = (1 << 1),
68         MODIFIER_SUPER = (1 << 2),
69         MODIFIER_SHIFT = (1 << 3),
70 };
71
72 enum weston_keyboard_locks {
73         WESTON_NUM_LOCK = (1 << 0),
74         WESTON_CAPS_LOCK = (1 << 1),
75 };
76
77 enum weston_led {
78         LED_NUM_LOCK = (1 << 0),
79         LED_CAPS_LOCK = (1 << 1),
80         LED_SCROLL_LOCK = (1 << 2),
81 };
82
83 struct weston_mode {
84         uint32_t flags;
85         int32_t width, height;
86         uint32_t refresh;
87         struct wl_list link;
88 };
89
90 struct weston_shell_client {
91         void (*send_configure)(struct weston_surface *surface, int32_t width, int32_t height);
92         void (*send_position)(struct weston_surface *surface, int32_t x, int32_t y);
93 };
94
95 struct weston_shell_interface {
96         void *shell;                    /* either desktop or tablet */
97
98         struct shell_surface *(*create_shell_surface)(void *shell,
99                                                       struct weston_surface *surface,
100                                                       const struct weston_shell_client *client);
101         void (*set_toplevel)(struct shell_surface *shsurf);
102
103         void (*set_transient)(struct shell_surface *shsurf,
104                               struct weston_surface *parent,
105                               int x, int y, uint32_t flags);
106         void (*set_fullscreen)(struct shell_surface *shsurf,
107                                uint32_t method,
108                                uint32_t framerate,
109                                struct weston_output *output);
110         void (*set_xwayland)(struct shell_surface *shsurf,
111                                int x, int y, uint32_t flags);
112         int (*move)(struct shell_surface *shsurf, struct weston_pointer *pointer);
113         int (*resize)(struct shell_surface *shsurf,
114                       struct weston_pointer *pointer, uint32_t edges);
115         void (*set_title)(struct shell_surface *shsurf,
116                           const char *title);
117         void (*set_window_geometry)(struct shell_surface *shsurf,
118                                     int32_t x, int32_t y,
119                                     int32_t width, int32_t height);
120         void (*set_maximized)(struct shell_surface *shsurf);
121         void (*set_pid)(struct shell_surface *shsurf, pid_t pid);
122         void (*get_output_work_area)(void *shell, struct weston_output *output, pixman_rectangle32_t *area);
123 };
124
125 struct weston_animation {
126         void (*frame)(struct weston_animation *animation,
127                       struct weston_output *output, uint32_t msecs);
128         int frame_counter;
129         struct wl_list link;
130 };
131
132 enum {
133         WESTON_SPRING_OVERSHOOT,
134         WESTON_SPRING_CLAMP,
135         WESTON_SPRING_BOUNCE
136 };
137
138 struct weston_spring {
139         double k;
140         double friction;
141         double current;
142         double target;
143         double previous;
144         double min, max;
145         uint32_t timestamp;
146         uint32_t clip;
147 };
148
149 struct weston_output_zoom {
150         bool active;
151         float increment;
152         float level;
153         float max_level;
154         float trans_x, trans_y;
155         struct {
156                 double x, y;
157         } current;
158         struct weston_seat *seat;
159         struct weston_animation animation_z;
160         struct weston_spring spring_z;
161         struct wl_listener motion_listener;
162 };
163
164 /* bit compatible with drm definitions. */
165 enum dpms_enum {
166         WESTON_DPMS_ON,
167         WESTON_DPMS_STANDBY,
168         WESTON_DPMS_SUSPEND,
169         WESTON_DPMS_OFF
170 };
171
172 struct weston_output {
173         uint32_t id;
174         char *name;
175
176         void *renderer_state;
177
178         struct wl_list link;
179         struct wl_list resource_list;
180         struct wl_global *global;
181         struct weston_compositor *compositor;
182
183         /** From global to output buffer coordinates. */
184         struct weston_matrix matrix;
185         /** From output buffer to global coordinates. */
186         struct weston_matrix inverse_matrix;
187
188         struct wl_list animation_list;
189         int32_t x, y, width, height;
190         int32_t mm_width, mm_height;
191
192         /** Output area in global coordinates, simple rect */
193         pixman_region32_t region;
194
195         pixman_region32_t previous_damage;
196         int repaint_needed;
197         int repaint_scheduled;
198         struct wl_event_source *repaint_timer;
199         struct weston_output_zoom zoom;
200         int dirty;
201         struct wl_signal frame_signal;
202         struct wl_signal destroy_signal;
203         int move_x, move_y;
204         uint32_t frame_time; /* presentation timestamp in milliseconds */
205         uint64_t msc;        /* media stream counter */
206         int disable_planes;
207         int destroying;
208         struct wl_list feedback_list;
209
210         char *make, *model, *serial_number;
211         uint32_t subpixel;
212         uint32_t transform;
213         int32_t native_scale;
214         int32_t current_scale;
215         int32_t original_scale;
216
217         struct weston_mode *native_mode;
218         struct weston_mode *current_mode;
219         struct weston_mode *original_mode;
220         struct wl_list mode_list;
221
222         void (*start_repaint_loop)(struct weston_output *output);
223         int (*repaint)(struct weston_output *output,
224                         pixman_region32_t *damage);
225         void (*destroy)(struct weston_output *output);
226         void (*assign_planes)(struct weston_output *output);
227         int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
228
229         /* backlight values are on 0-255 range, where higher is brighter */
230         int32_t backlight_current;
231         void (*set_backlight)(struct weston_output *output, uint32_t value);
232         void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
233
234         int connection_internal;
235         uint16_t gamma_size;
236         void (*set_gamma)(struct weston_output *output,
237                           uint16_t size,
238                           uint16_t *r,
239                           uint16_t *g,
240                           uint16_t *b);
241
242         struct weston_timeline_object timeline;
243 };
244
245 enum weston_pointer_motion_mask {
246         WESTON_POINTER_MOTION_ABS = 1 << 0,
247         WESTON_POINTER_MOTION_REL = 1 << 1,
248         WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2,
249 };
250
251 struct weston_pointer_motion_event {
252         uint32_t mask;
253         uint64_t time_usec;
254         double x;
255         double y;
256         double dx;
257         double dy;
258         double dx_unaccel;
259         double dy_unaccel;
260 };
261
262 struct weston_pointer_axis_event {
263         uint32_t axis;
264         double value;
265         bool has_discrete;
266         int32_t discrete;
267 };
268
269 struct weston_pointer_grab;
270 struct weston_pointer_grab_interface {
271         void (*focus)(struct weston_pointer_grab *grab);
272         void (*motion)(struct weston_pointer_grab *grab, uint32_t time,
273                        struct weston_pointer_motion_event *event);
274         void (*button)(struct weston_pointer_grab *grab,
275                        uint32_t time, uint32_t button, uint32_t state);
276         void (*axis)(struct weston_pointer_grab *grab,
277                      uint32_t time,
278                      struct weston_pointer_axis_event *event);
279         void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source);
280         void (*frame)(struct weston_pointer_grab *grab);
281         void (*cancel)(struct weston_pointer_grab *grab);
282 };
283
284 struct weston_pointer_grab {
285         const struct weston_pointer_grab_interface *interface;
286         struct weston_pointer *pointer;
287 };
288
289 struct weston_keyboard_grab;
290 struct weston_keyboard_grab_interface {
291         void (*key)(struct weston_keyboard_grab *grab, uint32_t time,
292                     uint32_t key, uint32_t state);
293         void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
294                           uint32_t mods_depressed, uint32_t mods_latched,
295                           uint32_t mods_locked, uint32_t group);
296         void (*cancel)(struct weston_keyboard_grab *grab);
297 };
298
299 struct weston_keyboard_grab {
300         const struct weston_keyboard_grab_interface *interface;
301         struct weston_keyboard *keyboard;
302 };
303
304 struct weston_touch_grab;
305 struct weston_touch_grab_interface {
306         void (*down)(struct weston_touch_grab *grab,
307                         uint32_t time,
308                         int touch_id,
309                         wl_fixed_t sx,
310                         wl_fixed_t sy);
311         void (*up)(struct weston_touch_grab *grab,
312                         uint32_t time,
313                         int touch_id);
314         void (*motion)(struct weston_touch_grab *grab,
315                         uint32_t time,
316                         int touch_id,
317                         wl_fixed_t sx,
318                         wl_fixed_t sy);
319         void (*frame)(struct weston_touch_grab *grab);
320         void (*cancel)(struct weston_touch_grab *grab);
321 };
322
323 struct weston_touch_grab {
324         const struct weston_touch_grab_interface *interface;
325         struct weston_touch *touch;
326 };
327
328 struct weston_data_offer {
329         struct wl_resource *resource;
330         struct weston_data_source *source;
331         struct wl_listener source_destroy_listener;
332         uint32_t dnd_actions;
333         enum wl_data_device_manager_dnd_action preferred_dnd_action;
334         bool in_ask;
335 };
336
337 struct weston_data_source {
338         struct wl_resource *resource;
339         struct wl_signal destroy_signal;
340         struct wl_array mime_types;
341         struct weston_data_offer *offer;
342         struct weston_seat *seat;
343         bool accepted;
344         bool actions_set;
345         uint32_t dnd_actions;
346         enum wl_data_device_manager_dnd_action current_dnd_action;
347         enum wl_data_device_manager_dnd_action compositor_action;
348
349         void (*accept)(struct weston_data_source *source,
350                        uint32_t serial, const char *mime_type);
351         void (*send)(struct weston_data_source *source,
352                      const char *mime_type, int32_t fd);
353         void (*cancel)(struct weston_data_source *source);
354 };
355
356 struct weston_pointer_client {
357         struct wl_list link;
358         struct wl_client *client;
359         struct wl_list pointer_resources;
360         struct wl_list relative_pointer_resources;
361 };
362
363 struct weston_pointer {
364         struct weston_seat *seat;
365
366         struct wl_list pointer_clients;
367
368         struct weston_view *focus;
369         struct weston_pointer_client *focus_client;
370         uint32_t focus_serial;
371         struct wl_listener focus_view_listener;
372         struct wl_listener focus_resource_listener;
373         struct wl_signal focus_signal;
374         struct wl_signal motion_signal;
375         struct wl_signal destroy_signal;
376
377         struct weston_view *sprite;
378         struct wl_listener sprite_destroy_listener;
379         int32_t hotspot_x, hotspot_y;
380
381         struct weston_pointer_grab *grab;
382         struct weston_pointer_grab default_grab;
383         wl_fixed_t grab_x, grab_y;
384         uint32_t grab_button;
385         uint32_t grab_serial;
386         uint32_t grab_time;
387
388         wl_fixed_t x, y;
389         wl_fixed_t sx, sy;
390         uint32_t button_count;
391
392         struct wl_listener output_destroy_listener;
393 };
394
395
396 struct weston_touch {
397         struct weston_seat *seat;
398
399         struct wl_list resource_list;
400         struct wl_list focus_resource_list;
401         struct weston_view *focus;
402         struct wl_listener focus_view_listener;
403         struct wl_listener focus_resource_listener;
404         uint32_t focus_serial;
405         struct wl_signal focus_signal;
406
407         uint32_t num_tp;
408
409         struct weston_touch_grab *grab;
410         struct weston_touch_grab default_grab;
411         int grab_touch_id;
412         wl_fixed_t grab_x, grab_y;
413         uint32_t grab_serial;
414         uint32_t grab_time;
415 };
416
417 void
418 weston_pointer_motion_to_abs(struct weston_pointer *pointer,
419                              struct weston_pointer_motion_event *event,
420                              wl_fixed_t *x, wl_fixed_t *y);
421
422 struct weston_pointer *
423 weston_pointer_create(struct weston_seat *seat);
424 void
425 weston_pointer_destroy(struct weston_pointer *pointer);
426 void
427 weston_pointer_send_motion(struct weston_pointer *pointer, uint32_t time,
428                            struct weston_pointer_motion_event *event);
429 bool
430 weston_pointer_has_focus_resource(struct weston_pointer *pointer);
431 void
432 weston_pointer_send_button(struct weston_pointer *pointer,
433                            uint32_t time, uint32_t button, uint32_t state_w);
434 void
435 weston_pointer_send_axis(struct weston_pointer *pointer,
436                          uint32_t time,
437                          struct weston_pointer_axis_event *event);
438 void
439 weston_pointer_send_axis_source(struct weston_pointer *pointer,
440                                 uint32_t source);
441 void
442 weston_pointer_send_frame(struct weston_pointer *pointer);
443
444 void
445 weston_pointer_set_focus(struct weston_pointer *pointer,
446                          struct weston_view *view,
447                          wl_fixed_t sx, wl_fixed_t sy);
448 void
449 weston_pointer_clear_focus(struct weston_pointer *pointer);
450 void
451 weston_pointer_start_grab(struct weston_pointer *pointer,
452                           struct weston_pointer_grab *grab);
453 void
454 weston_pointer_end_grab(struct weston_pointer *pointer);
455 void
456 weston_pointer_clamp(struct weston_pointer *pointer,
457                             wl_fixed_t *fx, wl_fixed_t *fy);
458 void
459 weston_pointer_move(struct weston_pointer *pointer,
460                     struct weston_pointer_motion_event *event);
461 void
462 weston_pointer_set_default_grab(struct weston_pointer *pointer,
463                 const struct weston_pointer_grab_interface *interface);
464
465 void
466 weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint);
467
468 struct weston_keyboard *
469 weston_keyboard_create(void);
470 void
471 weston_keyboard_destroy(struct weston_keyboard *keyboard);
472 void
473 weston_keyboard_set_focus(struct weston_keyboard *keyboard,
474                           struct weston_surface *surface);
475 void
476 weston_keyboard_start_grab(struct weston_keyboard *device,
477                            struct weston_keyboard_grab *grab);
478 void
479 weston_keyboard_end_grab(struct weston_keyboard *keyboard);
480 int
481 /*
482  * 'mask' and 'value' should be a bitwise mask of one or more
483  * valued of the weston_keyboard_locks enum.
484  */
485 weston_keyboard_set_locks(struct weston_keyboard *keyboard,
486                           uint32_t mask, uint32_t value);
487
488 bool
489 weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
490 void
491 weston_keyboard_send_key(struct weston_keyboard *keyboard,
492                          uint32_t time, uint32_t key,
493                          enum wl_keyboard_key_state state);
494 void
495 weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
496                                uint32_t serial, uint32_t mods_depressed,
497                                uint32_t mods_latched,
498                                uint32_t mods_locked, uint32_t group);
499
500 struct weston_touch *
501 weston_touch_create(void);
502 void
503 weston_touch_destroy(struct weston_touch *touch);
504 void
505 weston_touch_set_focus(struct weston_touch *touch,
506                        struct weston_view *view);
507 void
508 weston_touch_start_grab(struct weston_touch *device,
509                         struct weston_touch_grab *grab);
510 void
511 weston_touch_end_grab(struct weston_touch *touch);
512
513 bool
514 weston_touch_has_focus_resource(struct weston_touch *touch);
515 void
516 weston_touch_send_down(struct weston_touch *touch, uint32_t time,
517                        int touch_id, wl_fixed_t x, wl_fixed_t y);
518 void
519 weston_touch_send_up(struct weston_touch *touch, uint32_t time, int touch_id);
520 void
521 weston_touch_send_motion(struct weston_touch *touch, uint32_t time,
522                          int touch_id, wl_fixed_t x, wl_fixed_t y);
523 void
524 weston_touch_send_frame(struct weston_touch *touch);
525
526 void
527 wl_data_device_set_keyboard_focus(struct weston_seat *seat);
528
529 int
530 wl_data_device_manager_init(struct wl_display *display);
531
532
533 void
534 weston_seat_set_selection(struct weston_seat *seat,
535                           struct weston_data_source *source, uint32_t serial);
536 void
537 weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
538
539 int
540 weston_pointer_start_drag(struct weston_pointer *pointer,
541                        struct weston_data_source *source,
542                        struct weston_surface *icon,
543                        struct wl_client *client);
544 int
545 weston_touch_start_drag(struct weston_touch *touch,
546                         struct weston_data_source *source,
547                         struct weston_surface *icon,
548                         struct wl_client *client);
549
550 struct weston_xkb_info {
551         struct xkb_keymap *keymap;
552         int keymap_fd;
553         size_t keymap_size;
554         char *keymap_area;
555         int32_t ref_count;
556         xkb_mod_index_t shift_mod;
557         xkb_mod_index_t caps_mod;
558         xkb_mod_index_t ctrl_mod;
559         xkb_mod_index_t alt_mod;
560         xkb_mod_index_t mod2_mod;
561         xkb_mod_index_t mod3_mod;
562         xkb_mod_index_t super_mod;
563         xkb_mod_index_t mod5_mod;
564         xkb_led_index_t num_led;
565         xkb_led_index_t caps_led;
566         xkb_led_index_t scroll_led;
567 };
568
569 struct weston_keyboard {
570         struct weston_seat *seat;
571
572         struct wl_list resource_list;
573         struct wl_list focus_resource_list;
574         struct weston_surface *focus;
575         struct wl_listener focus_resource_listener;
576         uint32_t focus_serial;
577         struct wl_signal focus_signal;
578
579         struct weston_keyboard_grab *grab;
580         struct weston_keyboard_grab default_grab;
581         uint32_t grab_key;
582         uint32_t grab_serial;
583         uint32_t grab_time;
584
585         struct wl_array keys;
586
587         struct {
588                 uint32_t mods_depressed;
589                 uint32_t mods_latched;
590                 uint32_t mods_locked;
591                 uint32_t group;
592         } modifiers;
593
594         struct weston_keyboard_grab input_method_grab;
595         struct wl_resource *input_method_resource;
596
597         struct weston_xkb_info *xkb_info;
598         struct {
599                 struct xkb_state *state;
600                 enum weston_led leds;
601         } xkb_state;
602         struct xkb_keymap *pending_keymap;
603 };
604
605 struct weston_seat {
606         struct wl_list base_resource_list;
607
608         struct wl_global *global;
609         struct weston_pointer *pointer_state;
610         struct weston_keyboard *keyboard_state;
611         struct weston_touch *touch_state;
612         int pointer_device_count;
613         int keyboard_device_count;
614         int touch_device_count;
615
616         struct weston_output *output; /* constraint */
617
618         struct wl_signal destroy_signal;
619         struct wl_signal updated_caps_signal;
620
621         struct weston_compositor *compositor;
622         struct wl_list link;
623         enum weston_keyboard_modifier modifier_state;
624         struct weston_surface *saved_kbd_focus;
625         struct wl_listener saved_kbd_focus_listener;
626         struct wl_list drag_resource_list;
627
628         uint32_t selection_serial;
629         struct weston_data_source *selection_data_source;
630         struct wl_listener selection_data_source_listener;
631         struct wl_signal selection_signal;
632
633         void (*led_update)(struct weston_seat *ws, enum weston_led leds);
634
635         struct input_method *input_method;
636         char *seat_name;
637 };
638
639 enum {
640         WESTON_COMPOSITOR_ACTIVE,       /* normal rendering and events */
641         WESTON_COMPOSITOR_IDLE,         /* shell->unlock called on activity */
642         WESTON_COMPOSITOR_OFFSCREEN,    /* no rendering, no frame events */
643         WESTON_COMPOSITOR_SLEEPING      /* same as offscreen, but also set dpms
644                                          * to off */
645 };
646
647 struct weston_layer_entry {
648         struct wl_list link;
649         struct weston_layer *layer;
650 };
651
652 struct weston_layer {
653         struct weston_layer_entry view_list;
654         struct wl_list link;
655         pixman_box32_t mask;
656 };
657
658 struct weston_plane {
659         struct weston_compositor *compositor;
660         pixman_region32_t damage; /**< in global coords */
661         pixman_region32_t clip;
662         int32_t x, y;
663         struct wl_list link;
664 };
665
666 struct weston_renderer {
667         int (*read_pixels)(struct weston_output *output,
668                                pixman_format_code_t format, void *pixels,
669                                uint32_t x, uint32_t y,
670                                uint32_t width, uint32_t height);
671         void (*repaint_output)(struct weston_output *output,
672                                pixman_region32_t *output_damage);
673         void (*flush_damage)(struct weston_surface *surface);
674         void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
675         void (*surface_set_color)(struct weston_surface *surface,
676                                float red, float green,
677                                float blue, float alpha);
678         void (*destroy)(struct weston_compositor *ec);
679
680
681         /** See weston_surface_get_content_size() */
682         void (*surface_get_content_size)(struct weston_surface *surface,
683                                          int *width, int *height);
684
685         /** See weston_surface_copy_content() */
686         int (*surface_copy_content)(struct weston_surface *surface,
687                                     void *target, size_t size,
688                                     int src_x, int src_y,
689                                     int width, int height);
690
691         /** See weston_compositor_import_dmabuf() */
692         bool (*import_dmabuf)(struct weston_compositor *ec,
693                               struct linux_dmabuf_buffer *buffer);
694 };
695
696 enum weston_capability {
697         /* backend/renderer supports arbitrary rotation */
698         WESTON_CAP_ROTATION_ANY                 = 0x0001,
699
700         /* screencaptures need to be y-flipped */
701         WESTON_CAP_CAPTURE_YFLIP                = 0x0002,
702
703         /* backend/renderer has a separate cursor plane */
704         WESTON_CAP_CURSOR_PLANE                 = 0x0004,
705
706         /* backend supports setting arbitrary resolutions */
707         WESTON_CAP_ARBITRARY_MODES              = 0x0008,
708
709         /* renderer supports weston_view_set_mask() clipping */
710         WESTON_CAP_VIEW_CLIP_MASK               = 0x0010,
711 };
712
713 /* Configuration struct for an output.
714  *
715  * This struct is used to pass the configuration for an output
716  * to the compositor backend when creating a new output.
717  * The backend can subclass this struct to handle backend
718  * specific data.
719  */
720 struct weston_backend_output_config {
721         uint32_t transform;
722         uint32_t width;
723         uint32_t height;
724         uint32_t scale;
725 };
726
727 /* Configuration struct for a backend.
728  *
729  * This struct carries the configuration for a backend, and it's
730  * passed to the backend's init entry point. The backend will
731  * likely want to subclass this in order to handle backend specific
732  * data.
733  *
734  * NOTE: Alternate designs were proposed (Feb 2016) for using opaque
735  * structures[1] and for section+key/value getter/setters[2].  The rationale
736  * for selecting the transparent structure design is based on several
737  * assumptions[3] which may require re-evaluating the design choice if they
738  * fail to hold.
739  *
740  * 1: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026989.html
741  * 2: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026929.html
742  * 3: https://lists.freedesktop.org/archives/wayland-devel/2016-February/027228.html
743  */
744 struct weston_backend_config {
745    /** Major version for the backend-specific config struct
746     *
747     * This version must match exactly what the backend expects, otherwise
748     * the struct is incompatible.
749     */
750    uint32_t struct_version;
751
752    /** Minor version of the backend-specific config struct
753     *
754     * This must be set to sizeof(struct backend-specific config).
755     * If the value here is smaller than what the backend expects, the
756     * extra config members will assume their default values.
757     *
758     * A value greater than what the backend expects is incompatible.
759     */
760    size_t struct_size;
761 };
762
763 struct weston_backend {
764         void (*destroy)(struct weston_compositor *compositor);
765         void (*restore)(struct weston_compositor *compositor);
766 };
767
768 struct weston_compositor {
769         struct wl_signal destroy_signal;
770
771         struct wl_display *wl_display;
772         struct weston_shell_interface shell_interface;
773
774         /* surface signals */
775         struct wl_signal create_surface_signal;
776         struct wl_signal activate_signal;
777         struct wl_signal transform_signal;
778
779         struct wl_signal kill_signal;
780         struct wl_signal idle_signal;
781         struct wl_signal wake_signal;
782
783         struct wl_signal show_input_panel_signal;
784         struct wl_signal hide_input_panel_signal;
785         struct wl_signal update_input_panel_signal;
786
787         struct wl_signal seat_created_signal;
788         struct wl_signal output_created_signal;
789         struct wl_signal output_destroyed_signal;
790         struct wl_signal output_moved_signal;
791         struct wl_signal output_resized_signal; /* callback argument: resized output */
792
793         struct wl_signal session_signal;
794         int session_active;
795
796         struct weston_layer fade_layer;
797         struct weston_layer cursor_layer;
798
799         struct wl_list output_list;
800         struct wl_list seat_list;
801         struct wl_list layer_list;
802         struct wl_list view_list;       /* struct weston_view::link */
803         struct wl_list plane_list;
804         struct wl_list key_binding_list;
805         struct wl_list modifier_binding_list;
806         struct wl_list button_binding_list;
807         struct wl_list touch_binding_list;
808         struct wl_list axis_binding_list;
809         struct wl_list debug_binding_list;
810
811         uint32_t state;
812         struct wl_event_source *idle_source;
813         uint32_t idle_inhibit;
814         int idle_time;                  /* timeout, s */
815
816         const struct weston_pointer_grab_interface *default_pointer_grab;
817
818         /* Repaint state. */
819         struct weston_plane primary_plane;
820         uint32_t capabilities; /* combination of enum weston_capability */
821
822         struct weston_renderer *renderer;
823
824         pixman_format_code_t read_format;
825
826         struct weston_backend *backend;
827
828         struct weston_launcher *launcher;
829
830         struct wl_list plugin_api_list; /* struct weston_plugin_api::link */
831
832         uint32_t output_id_pool;
833
834         struct xkb_rule_names xkb_names;
835         struct xkb_context *xkb_context;
836         struct weston_xkb_info *xkb_info;
837
838         /* Raw keyboard processing (no libxkbcommon initialization or handling) */
839         int use_xkbcommon;
840
841         int32_t kb_repeat_rate;
842         int32_t kb_repeat_delay;
843
844         bool vt_switching;
845
846         clockid_t presentation_clock;
847         int32_t repaint_msec;
848
849         unsigned int activate_serial;
850
851         struct wl_global *pointer_constraints;
852
853         int exit_code;
854
855         void *user_data;
856         void (*exit)(struct weston_compositor *c);
857 };
858
859 struct weston_buffer {
860         struct wl_resource *resource;
861         struct wl_signal destroy_signal;
862         struct wl_listener destroy_listener;
863
864         union {
865                 struct wl_shm_buffer *shm_buffer;
866                 void *legacy_buffer;
867         };
868         int32_t width, height;
869         uint32_t busy_count;
870         int y_inverted;
871 };
872
873 struct weston_buffer_reference {
874         struct weston_buffer *buffer;
875         struct wl_listener destroy_listener;
876 };
877
878 struct weston_buffer_viewport {
879         struct {
880                 /* wl_surface.set_buffer_transform */
881                 uint32_t transform;
882
883                 /* wl_surface.set_scaling_factor */
884                 int32_t scale;
885
886                 /*
887                  * If src_width != wl_fixed_from_int(-1),
888                  * then and only then src_* are used.
889                  */
890                 wl_fixed_t src_x, src_y;
891                 wl_fixed_t src_width, src_height;
892         } buffer;
893
894         struct {
895                 /*
896                  * If width == -1, the size is inferred from the buffer.
897                  */
898                 int32_t width, height;
899         } surface;
900
901         int changed;
902 };
903
904 struct weston_region {
905         struct wl_resource *resource;
906         pixman_region32_t region;
907 };
908
909 /* Using weston_view transformations
910  *
911  * To add a transformation to a view, create a struct weston_transform, and
912  * add it to the list view->geometry.transformation_list. Whenever you
913  * change the list, anything under view->geometry, or anything in the
914  * weston_transforms linked into the list, you must call
915  * weston_view_geometry_dirty().
916  *
917  * The order in the list defines the order of transformations. Let the list
918  * contain the transformation matrices M1, ..., Mn as head to tail. The
919  * transformation is applied to view-local coordinate vector p as
920  *    P = Mn * ... * M2 * M1 * p
921  * to produce the global coordinate vector P. The total transform
922  *    Mn * ... * M2 * M1
923  * is cached in view->transform.matrix, and the inverse of it in
924  * view->transform.inverse.
925  *
926  * The list always contains view->transform.position transformation, which
927  * is the translation by view->geometry.x and y.
928  *
929  * If you want to apply a transformation in local coordinates, add your
930  * weston_transform to the head of the list. If you want to apply a
931  * transformation in global coordinates, add it to the tail of the list.
932  *
933  * If view->geometry.parent is set, the total transformation of this
934  * view will be the parent's total transformation and this transformation
935  * combined:
936  *    Mparent * Mn * ... * M2 * M1
937  */
938
939 struct weston_view {
940         struct weston_surface *surface;
941         struct wl_list surface_link;
942         struct wl_signal destroy_signal;
943
944         struct wl_list link;             /* weston_compositor::view_list */
945         struct weston_layer_entry layer_link; /* part of geometry */
946         struct weston_plane *plane;
947
948         /* For weston_layer inheritance from another view */
949         struct weston_view *parent_view;
950
951         unsigned int click_to_activate_serial;
952
953         pixman_region32_t clip;          /* See weston_view_damage_below() */
954         float alpha;                     /* part of geometry, see below */
955
956         void *renderer_state;
957
958         /* Surface geometry state, mutable.
959          * If you change anything, call weston_surface_geometry_dirty().
960          * That includes the transformations referenced from the list.
961          */
962         struct {
963                 float x, y; /* surface translation on display */
964
965                 /* struct weston_transform */
966                 struct wl_list transformation_list;
967
968                 /* managed by weston_surface_set_transform_parent() */
969                 struct weston_view *parent;
970                 struct wl_listener parent_destroy_listener;
971                 struct wl_list child_list; /* geometry.parent_link */
972                 struct wl_list parent_link;
973
974                 /* managed by weston_view_set_mask() */
975                 bool scissor_enabled;
976                 pixman_region32_t scissor; /* always a simple rect */
977         } geometry;
978
979         /* State derived from geometry state, read-only.
980          * This is updated by weston_view_update_transform().
981          */
982         struct {
983                 int dirty;
984
985                 /* Approximations in global coordinates:
986                  * - boundingbox is guaranteed to include the whole view in
987                  *   the smallest possible single rectangle.
988                  * - opaque is guaranteed to be fully opaque, though not
989                  *   necessarily include all opaque areas.
990                  */
991                 pixman_region32_t boundingbox;
992                 pixman_region32_t opaque;
993
994                 /* matrix and inverse are used only if enabled = 1.
995                  * If enabled = 0, use x, y, width, height directly.
996                  */
997                 int enabled;
998                 struct weston_matrix matrix;
999                 struct weston_matrix inverse;
1000
1001                 struct weston_transform position; /* matrix from x, y */
1002         } transform;
1003
1004         /*
1005          * The primary output for this view.
1006          * Used for picking the output for driving internal animations on the
1007          * view, inheriting the primary output for related views in shells, etc.
1008          */
1009         struct weston_output *output;
1010
1011         /*
1012          * A more complete representation of all outputs this surface is
1013          * displayed on.
1014          */
1015         uint32_t output_mask;
1016
1017         /* Per-surface Presentation feedback flags, controlled by backend. */
1018         uint32_t psf_flags;
1019
1020         bool is_mapped;
1021 };
1022
1023 struct weston_surface_state {
1024         /* wl_surface.attach */
1025         int newly_attached;
1026         struct weston_buffer *buffer;
1027         struct wl_listener buffer_destroy_listener;
1028         int32_t sx;
1029         int32_t sy;
1030
1031         /* wl_surface.damage */
1032         pixman_region32_t damage_surface;
1033         /* wl_surface.damage_buffer */
1034         pixman_region32_t damage_buffer;
1035
1036         /* wl_surface.set_opaque_region */
1037         pixman_region32_t opaque;
1038
1039         /* wl_surface.set_input_region */
1040         pixman_region32_t input;
1041
1042         /* wl_surface.frame */
1043         struct wl_list frame_callback_list;
1044
1045         /* presentation.feedback */
1046         struct wl_list feedback_list;
1047
1048         /* wl_surface.set_buffer_transform */
1049         /* wl_surface.set_scaling_factor */
1050         /* wp_viewport.set_source */
1051         /* wp_viewport.set_destination */
1052         struct weston_buffer_viewport buffer_viewport;
1053 };
1054
1055 struct weston_surface_activation_data {
1056         struct weston_surface *surface;
1057         struct weston_seat *seat;
1058 };
1059
1060 struct weston_pointer_constraint {
1061         struct wl_list link;
1062
1063         struct weston_surface *surface;
1064         struct weston_view *view;
1065         struct wl_resource *resource;
1066         struct weston_pointer_grab grab;
1067         struct weston_pointer *pointer;
1068         uint32_t lifetime;
1069
1070         pixman_region32_t region;
1071         pixman_region32_t region_pending;
1072         bool region_is_pending;
1073
1074         wl_fixed_t hint_x;
1075         wl_fixed_t hint_y;
1076         wl_fixed_t hint_x_pending;
1077         wl_fixed_t hint_y_pending;
1078         bool hint_is_pending;
1079
1080         struct wl_listener pointer_destroy_listener;
1081         struct wl_listener surface_destroy_listener;
1082         struct wl_listener surface_commit_listener;
1083         struct wl_listener surface_activate_listener;
1084 };
1085
1086 struct weston_surface {
1087         struct wl_resource *resource;
1088         struct wl_signal destroy_signal; /* callback argument: this surface */
1089         struct weston_compositor *compositor;
1090         struct wl_signal commit_signal;
1091
1092         /** Damage in local coordinates from the client, for tex upload. */
1093         pixman_region32_t damage;
1094
1095         pixman_region32_t opaque;        /* part of geometry, see below */
1096         pixman_region32_t input;
1097         int32_t width, height;
1098         int32_t ref_count;
1099
1100         /* Not for long-term storage.  This exists for book-keeping while
1101          * iterating over surfaces and views
1102          */
1103         bool touched;
1104
1105         void *renderer_state;
1106
1107         struct wl_list views;
1108
1109         /*
1110          * Which output to vsync this surface to.
1111          * Used to determine whether to send or queue frame events, and for
1112          * other client-visible syncing/throttling tied to the output
1113          * repaint cycle.
1114          */
1115         struct weston_output *output;
1116
1117         /*
1118          * A more complete representation of all outputs this surface is
1119          * displayed on.
1120          */
1121         uint32_t output_mask;
1122
1123         struct wl_list frame_callback_list;
1124         struct wl_list feedback_list;
1125
1126         struct weston_buffer_reference buffer_ref;
1127         struct weston_buffer_viewport buffer_viewport;
1128         int32_t width_from_buffer; /* before applying viewport */
1129         int32_t height_from_buffer;
1130         bool keep_buffer; /* for backends to prevent early release */
1131
1132         /* wp_viewport resource for this surface */
1133         struct wl_resource *viewport_resource;
1134
1135         /* All the pending state, that wl_surface.commit will apply. */
1136         struct weston_surface_state pending;
1137
1138         /* Matrices representating of the full transformation between
1139          * buffer and surface coordinates.  These matrices are updated
1140          * using the weston_surface_build_buffer_matrix function. */
1141         struct weston_matrix buffer_to_surface_matrix;
1142         struct weston_matrix surface_to_buffer_matrix;
1143
1144         /*
1145          * If non-NULL, this function will be called on
1146          * wl_surface::commit after a new buffer has been set up for
1147          * this surface. The integer params are the sx and sy
1148          * parameters supplied to wl_surface::attach.
1149          */
1150         void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy);
1151         void *committed_private;
1152         int (*get_label)(struct weston_surface *surface, char *buf, size_t len);
1153
1154         /* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
1155          * Contains also the parent itself as a dummy weston_subsurface,
1156          * if the list is not empty.
1157          */
1158         struct wl_list subsurface_list; /* weston_subsurface::parent_link */
1159         struct wl_list subsurface_list_pending; /* ...::parent_link_pending */
1160
1161         /*
1162          * For tracking protocol role assignments. Different roles may
1163          * have the same configure hook, e.g. in shell.c. Configure hook
1164          * may get reset, this will not.
1165          * XXX: map configure functions 1:1 to roles, and never reset it,
1166          * and replace role_name with configure.
1167          */
1168         const char *role_name;
1169
1170         struct weston_timeline_object timeline;
1171
1172         bool is_mapped;
1173
1174         /* An list of per seat pointer constraints. */
1175         struct wl_list pointer_constraints;
1176 };
1177
1178 struct weston_subsurface {
1179         struct wl_resource *resource;
1180
1181         /* guaranteed to be valid and non-NULL */
1182         struct weston_surface *surface;
1183         struct wl_listener surface_destroy_listener;
1184
1185         /* can be NULL */
1186         struct weston_surface *parent;
1187         struct wl_listener parent_destroy_listener;
1188         struct wl_list parent_link;
1189         struct wl_list parent_link_pending;
1190
1191         struct {
1192                 int32_t x;
1193                 int32_t y;
1194                 int set;
1195         } position;
1196
1197         int has_cached_data;
1198         struct weston_surface_state cached;
1199         struct weston_buffer_reference cached_buffer_ref;
1200
1201         int synchronized;
1202
1203         /* Used for constructing the view tree */
1204         struct wl_list unused_views;
1205 };
1206
1207 enum weston_key_state_update {
1208         STATE_UPDATE_AUTOMATIC,
1209         STATE_UPDATE_NONE,
1210 };
1211
1212 enum weston_activate_flag {
1213         WESTON_ACTIVATE_FLAG_NONE = 0,
1214         WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
1215         WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1,
1216 };
1217
1218 void
1219 weston_version(int *major, int *minor, int *micro);
1220
1221 void
1222 weston_view_update_transform(struct weston_view *view);
1223
1224 void
1225 weston_view_geometry_dirty(struct weston_view *view);
1226
1227 void
1228 weston_view_to_global_fixed(struct weston_view *view,
1229                             wl_fixed_t sx, wl_fixed_t sy,
1230                             wl_fixed_t *x, wl_fixed_t *y);
1231 void
1232 weston_view_to_global_float(struct weston_view *view,
1233                             float sx, float sy, float *x, float *y);
1234
1235 void
1236 weston_view_from_global_float(struct weston_view *view,
1237                               float x, float y, float *vx, float *vy);
1238 void
1239 weston_view_from_global(struct weston_view *view,
1240                         int32_t x, int32_t y, int32_t *vx, int32_t *vy);
1241 void
1242 weston_view_from_global_fixed(struct weston_view *view,
1243                               wl_fixed_t x, wl_fixed_t y,
1244                               wl_fixed_t *vx, wl_fixed_t *vy);
1245
1246 void
1247 weston_surface_to_buffer_float(struct weston_surface *surface,
1248                                float x, float y, float *bx, float *by);
1249 pixman_box32_t
1250 weston_surface_to_buffer_rect(struct weston_surface *surface,
1251                               pixman_box32_t rect);
1252
1253 void
1254 weston_surface_to_buffer_region(struct weston_surface *surface,
1255                                 pixman_region32_t *surface_region,
1256                                 pixman_region32_t *buffer_region);
1257
1258 void
1259 weston_spring_init(struct weston_spring *spring,
1260                    double k, double current, double target);
1261 void
1262 weston_spring_update(struct weston_spring *spring, uint32_t msec);
1263 int
1264 weston_spring_done(struct weston_spring *spring);
1265
1266 void
1267 weston_view_activate(struct weston_view *view,
1268                      struct weston_seat *seat,
1269                      uint32_t flags);
1270
1271 void
1272 notify_motion(struct weston_seat *seat, uint32_t time,
1273               struct weston_pointer_motion_event *event);
1274 void
1275 notify_motion_absolute(struct weston_seat *seat, uint32_t time,
1276                        double x, double y);
1277 void
1278 notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
1279               enum wl_pointer_button_state state);
1280 void
1281 notify_axis(struct weston_seat *seat, uint32_t time,
1282             struct weston_pointer_axis_event *event);
1283 void
1284 notify_axis_source(struct weston_seat *seat, uint32_t source);
1285
1286 void
1287 notify_pointer_frame(struct weston_seat *seat);
1288
1289 void
1290 notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
1291            enum wl_keyboard_key_state state,
1292            enum weston_key_state_update update_state);
1293 void
1294 notify_modifiers(struct weston_seat *seat, uint32_t serial);
1295
1296 void
1297 notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
1298                      double x, double y);
1299
1300 void
1301 notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
1302                          enum weston_key_state_update update_state);
1303 void
1304 notify_keyboard_focus_out(struct weston_seat *seat);
1305
1306 void
1307 notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
1308              double x, double y, int touch_type);
1309 void
1310 notify_touch_frame(struct weston_seat *seat);
1311
1312 void
1313 notify_touch_cancel(struct weston_seat *seat);
1314
1315 void
1316 weston_layer_entry_insert(struct weston_layer_entry *list,
1317                           struct weston_layer_entry *entry);
1318 void
1319 weston_layer_entry_remove(struct weston_layer_entry *entry);
1320 void
1321 weston_layer_init(struct weston_layer *layer, struct wl_list *below);
1322
1323 void
1324 weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height);
1325
1326 void
1327 weston_layer_set_mask_infinite(struct weston_layer *layer);
1328
1329 void
1330 weston_plane_init(struct weston_plane *plane,
1331                         struct weston_compositor *ec,
1332                         int32_t x, int32_t y);
1333 void
1334 weston_plane_release(struct weston_plane *plane);
1335
1336 void
1337 weston_compositor_stack_plane(struct weston_compositor *ec,
1338                               struct weston_plane *plane,
1339                               struct weston_plane *above);
1340
1341 /* An invalid flag in presented_flags to catch logic errors. */
1342 #define WP_PRESENTATION_FEEDBACK_INVALID (1U << 31)
1343
1344 void
1345 weston_output_finish_frame(struct weston_output *output,
1346                            const struct timespec *stamp,
1347                            uint32_t presented_flags);
1348 void
1349 weston_output_schedule_repaint(struct weston_output *output);
1350 void
1351 weston_output_damage(struct weston_output *output);
1352 void
1353 weston_compositor_schedule_repaint(struct weston_compositor *compositor);
1354 void
1355 weston_compositor_fade(struct weston_compositor *compositor, float tint);
1356 void
1357 weston_compositor_damage_all(struct weston_compositor *compositor);
1358 void
1359 weston_compositor_unlock(struct weston_compositor *compositor);
1360 void
1361 weston_compositor_wake(struct weston_compositor *compositor);
1362 void
1363 weston_compositor_offscreen(struct weston_compositor *compositor);
1364 void
1365 weston_compositor_sleep(struct weston_compositor *compositor);
1366 struct weston_view *
1367 weston_compositor_pick_view(struct weston_compositor *compositor,
1368                             wl_fixed_t x, wl_fixed_t y,
1369                             wl_fixed_t *sx, wl_fixed_t *sy);
1370
1371
1372 struct weston_binding;
1373 typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
1374                                              uint32_t time, uint32_t key,
1375                                              void *data);
1376 struct weston_binding *
1377 weston_compositor_add_key_binding(struct weston_compositor *compositor,
1378                                   uint32_t key,
1379                                   enum weston_keyboard_modifier modifier,
1380                                   weston_key_binding_handler_t binding,
1381                                   void *data);
1382
1383 typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard,
1384                                                   enum weston_keyboard_modifier modifier,
1385                                                   void *data);
1386 struct weston_binding *
1387 weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
1388                                        enum weston_keyboard_modifier modifier,
1389                                        weston_modifier_binding_handler_t binding,
1390                                        void *data);
1391
1392 typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
1393                                                 uint32_t time, uint32_t button,
1394                                                 void *data);
1395 struct weston_binding *
1396 weston_compositor_add_button_binding(struct weston_compositor *compositor,
1397                                      uint32_t button,
1398                                      enum weston_keyboard_modifier modifier,
1399                                      weston_button_binding_handler_t binding,
1400                                      void *data);
1401
1402 typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
1403                                                uint32_t time,
1404                                                void *data);
1405 struct weston_binding *
1406 weston_compositor_add_touch_binding(struct weston_compositor *compositor,
1407                                     enum weston_keyboard_modifier modifier,
1408                                     weston_touch_binding_handler_t binding,
1409                                     void *data);
1410
1411 typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
1412                                               uint32_t time,
1413                                               struct weston_pointer_axis_event *event,
1414                                               void *data);
1415 struct weston_binding *
1416 weston_compositor_add_axis_binding(struct weston_compositor *compositor,
1417                                    uint32_t axis,
1418                                    enum weston_keyboard_modifier modifier,
1419                                    weston_axis_binding_handler_t binding,
1420                                    void *data);
1421 struct weston_binding *
1422 weston_compositor_add_debug_binding(struct weston_compositor *compositor,
1423                                     uint32_t key,
1424                                     weston_key_binding_handler_t binding,
1425                                     void *data);
1426 void
1427 weston_binding_destroy(struct weston_binding *binding);
1428
1429 void
1430 weston_install_debug_key_binding(struct weston_compositor *compositor,
1431                                  uint32_t mod);
1432
1433 void
1434 weston_binding_list_destroy_all(struct wl_list *list);
1435
1436 void
1437 weston_compositor_run_key_binding(struct weston_compositor *compositor,
1438                                   struct weston_keyboard *keyboard,
1439                                   uint32_t time,
1440                                   uint32_t key,
1441                                   enum wl_keyboard_key_state state);
1442
1443 void
1444 weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
1445                                        struct weston_keyboard *keyboard,
1446                                        enum weston_keyboard_modifier modifier,
1447                                        enum wl_keyboard_key_state state);
1448 void
1449 weston_compositor_run_button_binding(struct weston_compositor *compositor,
1450                                      struct weston_pointer *pointer, uint32_t time,
1451                                      uint32_t button,
1452                                      enum wl_pointer_button_state value);
1453 void
1454 weston_compositor_run_touch_binding(struct weston_compositor *compositor,
1455                                     struct weston_touch *touch, uint32_t time,
1456                                     int touch_type);
1457 int
1458 weston_compositor_run_axis_binding(struct weston_compositor *compositor,
1459                                    struct weston_pointer *pointer, uint32_t time,
1460                                    struct weston_pointer_axis_event *event);
1461 int
1462 weston_compositor_run_debug_binding(struct weston_compositor *compositor,
1463                                     struct weston_keyboard *keyboard, uint32_t time,
1464                                     uint32_t key,
1465                                     enum wl_keyboard_key_state state);
1466
1467 void
1468 weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
1469                         const struct weston_pointer_grab_interface *interface);
1470
1471 int
1472 weston_environment_get_fd(const char *env);
1473
1474 struct wl_list *
1475 weston_compositor_top(struct weston_compositor *compositor);
1476
1477 struct weston_surface *
1478 weston_surface_create(struct weston_compositor *compositor);
1479
1480 struct weston_view *
1481 weston_view_create(struct weston_surface *surface);
1482
1483 void
1484 weston_view_destroy(struct weston_view *view);
1485
1486 void
1487 weston_view_set_position(struct weston_view *view,
1488                          float x, float y);
1489
1490 void
1491 weston_view_set_transform_parent(struct weston_view *view,
1492                                  struct weston_view *parent);
1493
1494 void
1495 weston_view_set_mask(struct weston_view *view,
1496                      int x, int y, int width, int height);
1497
1498 void
1499 weston_view_set_mask_infinite(struct weston_view *view);
1500
1501 bool
1502 weston_view_is_mapped(struct weston_view *view);
1503
1504 void
1505 weston_view_schedule_repaint(struct weston_view *view);
1506
1507 bool
1508 weston_surface_is_mapped(struct weston_surface *surface);
1509
1510 void
1511 weston_surface_set_size(struct weston_surface *surface,
1512                         int32_t width, int32_t height);
1513
1514 void
1515 weston_surface_schedule_repaint(struct weston_surface *surface);
1516
1517 void
1518 weston_surface_damage(struct weston_surface *surface);
1519
1520 void
1521 weston_view_damage_below(struct weston_view *view);
1522
1523 void
1524 weston_view_move_to_plane(struct weston_view *view,
1525                           struct weston_plane *plane);
1526 void
1527 weston_view_unmap(struct weston_view *view);
1528
1529 void
1530 weston_surface_unmap(struct weston_surface *surface);
1531
1532 struct weston_surface *
1533 weston_surface_get_main_surface(struct weston_surface *surface);
1534
1535 int
1536 weston_surface_set_role(struct weston_surface *surface,
1537                         const char *role_name,
1538                         struct wl_resource *error_resource,
1539                         uint32_t error_code);
1540
1541 void
1542 weston_surface_set_label_func(struct weston_surface *surface,
1543                               int (*desc)(struct weston_surface *,
1544                                           char *, size_t));
1545
1546 void
1547 weston_surface_get_content_size(struct weston_surface *surface,
1548                                 int *width, int *height);
1549
1550 int
1551 weston_surface_copy_content(struct weston_surface *surface,
1552                             void *target, size_t size,
1553                             int src_x, int src_y,
1554                             int width, int height);
1555
1556 struct weston_buffer *
1557 weston_buffer_from_resource(struct wl_resource *resource);
1558
1559 void
1560 weston_buffer_reference(struct weston_buffer_reference *ref,
1561                         struct weston_buffer *buffer);
1562
1563 uint32_t
1564 weston_compositor_get_time(void);
1565
1566 void
1567 weston_compositor_destroy(struct weston_compositor *ec);
1568 struct weston_compositor *
1569 weston_compositor_create(struct wl_display *display, void *user_data);
1570
1571 enum weston_compositor_backend {
1572         WESTON_BACKEND_DRM,
1573         WESTON_BACKEND_FBDEV,
1574         WESTON_BACKEND_HEADLESS,
1575         WESTON_BACKEND_RDP,
1576         WESTON_BACKEND_WAYLAND,
1577         WESTON_BACKEND_X11,
1578 };
1579
1580 int
1581 weston_compositor_load_backend(struct weston_compositor *compositor,
1582                                enum weston_compositor_backend backend,
1583                                struct weston_backend_config *config_base);
1584 void
1585 weston_compositor_exit(struct weston_compositor *ec);
1586 void *
1587 weston_compositor_get_user_data(struct weston_compositor *compositor);
1588 int
1589 weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
1590                                          clockid_t clk_id);
1591 int
1592 weston_compositor_set_presentation_clock_software(
1593                                         struct weston_compositor *compositor);
1594 void
1595 weston_compositor_read_presentation_clock(
1596                         const struct weston_compositor *compositor,
1597                         struct timespec *ts);
1598
1599 bool
1600 weston_compositor_import_dmabuf(struct weston_compositor *compositor,
1601                                 struct linux_dmabuf_buffer *buffer);
1602
1603 void
1604 weston_compositor_shutdown(struct weston_compositor *ec);
1605 void
1606 weston_compositor_exit_with_code(struct weston_compositor *compositor,
1607                                  int exit_code);
1608 void
1609 weston_output_init_zoom(struct weston_output *output);
1610 void
1611 weston_output_update_zoom(struct weston_output *output);
1612 void
1613 weston_output_activate_zoom(struct weston_output *output,
1614                             struct weston_seat *seat);
1615 void
1616 weston_output_update_matrix(struct weston_output *output);
1617 void
1618 weston_output_move(struct weston_output *output, int x, int y);
1619 void
1620 weston_output_init(struct weston_output *output, struct weston_compositor *c,
1621                    int x, int y, int width, int height, uint32_t transform, int32_t scale);
1622 void
1623 weston_compositor_add_output(struct weston_compositor *compositor,
1624                              struct weston_output *output);
1625 void
1626 weston_output_destroy(struct weston_output *output);
1627 void
1628 weston_output_transform_coordinate(struct weston_output *output,
1629                                    double device_x, double device_y,
1630                                    double *x, double *y);
1631
1632 void
1633 weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
1634                  const char *seat_name);
1635 void
1636 weston_seat_init_pointer(struct weston_seat *seat);
1637 void
1638 weston_seat_release_pointer(struct weston_seat *seat);
1639 int
1640 weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
1641 void
1642 weston_seat_release_keyboard(struct weston_seat *seat);
1643 void
1644 weston_seat_init_touch(struct weston_seat *seat);
1645 void
1646 weston_seat_release_touch(struct weston_seat *seat);
1647 void
1648 weston_seat_repick(struct weston_seat *seat);
1649 void
1650 weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
1651
1652 void
1653 weston_seat_release(struct weston_seat *seat);
1654 int
1655 weston_compositor_set_xkb_rule_names(struct weston_compositor *ec,
1656                                      struct xkb_rule_names *names);
1657 void
1658 weston_compositor_xkb_destroy(struct weston_compositor *ec);
1659
1660 /* String literal of spaces, the same width as the timestamp. */
1661 #define STAMP_SPACE "               "
1662
1663 typedef int (*log_func_t)(const char *fmt, va_list ap);
1664 void
1665 weston_log_set_handler(log_func_t log, log_func_t cont);
1666 int
1667 weston_vlog(const char *fmt, va_list ap);
1668 int
1669 weston_vlog_continue(const char *fmt, va_list ap);
1670 int
1671 weston_log(const char *fmt, ...)
1672         __attribute__ ((format (printf, 1, 2)));
1673 int
1674 weston_log_continue(const char *fmt, ...)
1675         __attribute__ ((format (printf, 1, 2)));
1676
1677 enum {
1678         TTY_ENTER_VT,
1679         TTY_LEAVE_VT
1680 };
1681
1682 struct tty *
1683 tty_create(struct weston_compositor *compositor, int tty_nr);
1684
1685 void
1686 tty_destroy(struct tty *tty);
1687
1688 void
1689 tty_reset(struct tty *tty);
1690
1691 int
1692 tty_activate_vt(struct tty *tty, int vt);
1693
1694 enum weston_screenshooter_outcome {
1695         WESTON_SCREENSHOOTER_SUCCESS,
1696         WESTON_SCREENSHOOTER_NO_MEMORY,
1697         WESTON_SCREENSHOOTER_BAD_BUFFER
1698 };
1699
1700 typedef void (*weston_screenshooter_done_func_t)(void *data,
1701                                 enum weston_screenshooter_outcome outcome);
1702 int
1703 weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer,
1704                            weston_screenshooter_done_func_t done, void *data);
1705 struct weston_recorder *
1706 weston_recorder_start(struct weston_output *output, const char *filename);
1707 void
1708 weston_recorder_stop(struct weston_recorder *recorder);
1709
1710 struct clipboard *
1711 clipboard_create(struct weston_seat *seat);
1712
1713 struct text_backend;
1714
1715 struct text_backend *
1716 text_backend_init(struct weston_compositor *ec);
1717
1718 void
1719 text_backend_destroy(struct text_backend *text_backend);
1720
1721 struct weston_view_animation;
1722 typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data);
1723
1724 void
1725 weston_view_animation_destroy(struct weston_view_animation *animation);
1726
1727 struct weston_view_animation *
1728 weston_zoom_run(struct weston_view *view, float start, float stop,
1729                 weston_view_animation_done_func_t done, void *data);
1730
1731 struct weston_view_animation *
1732 weston_fade_run(struct weston_view *view,
1733                 float start, float end, float k,
1734                 weston_view_animation_done_func_t done, void *data);
1735
1736 struct weston_view_animation *
1737 weston_move_scale_run(struct weston_view *view, int dx, int dy,
1738                       float start, float end, int reverse,
1739                       weston_view_animation_done_func_t done, void *data);
1740
1741 void
1742 weston_fade_update(struct weston_view_animation *fade, float target);
1743
1744 struct weston_view_animation *
1745 weston_stable_fade_run(struct weston_view *front_view, float start,
1746                        struct weston_view *back_view, float end,
1747                        weston_view_animation_done_func_t done, void *data);
1748
1749 struct weston_view_animation *
1750 weston_slide_run(struct weston_view *view, float start, float stop,
1751                  weston_view_animation_done_func_t done, void *data);
1752
1753 void
1754 weston_surface_set_color(struct weston_surface *surface,
1755                          float red, float green, float blue, float alpha);
1756
1757 void
1758 weston_surface_destroy(struct weston_surface *surface);
1759
1760 int
1761 weston_output_mode_set_native(struct weston_output *output,
1762                               struct weston_mode *mode,
1763                               int32_t scale);
1764 int
1765 weston_output_mode_switch_to_temporary(struct weston_output *output,
1766                                        struct weston_mode *mode,
1767                                        int32_t scale);
1768 int
1769 weston_output_mode_switch_to_native(struct weston_output *output);
1770
1771 int
1772 noop_renderer_init(struct weston_compositor *ec);
1773
1774 int
1775 weston_input_init(struct weston_compositor *compositor);
1776
1777 int
1778 backend_init(struct weston_compositor *c,
1779              struct weston_backend_config *config_base);
1780 int
1781 module_init(struct weston_compositor *compositor,
1782             int *argc, char *argv[]);
1783
1784 void
1785 weston_transformed_coord(int width, int height,
1786                          enum wl_output_transform transform,
1787                          int32_t scale,
1788                          float sx, float sy, float *bx, float *by);
1789 pixman_box32_t
1790 weston_transformed_rect(int width, int height,
1791                         enum wl_output_transform transform,
1792                         int32_t scale,
1793                         pixman_box32_t rect);
1794 void
1795 weston_matrix_transform_region(pixman_region32_t *dest,
1796                                struct weston_matrix *matrix,
1797                                pixman_region32_t *src);
1798 void
1799 weston_transformed_region(int width, int height,
1800                           enum wl_output_transform transform,
1801                           int32_t scale,
1802                           pixman_region32_t *src, pixman_region32_t *dest);
1803
1804 void *
1805 weston_load_module(const char *name, const char *entrypoint);
1806
1807 int
1808 weston_parse_transform(const char *transform, uint32_t *out);
1809
1810 const char *
1811 weston_transform_to_string(uint32_t output_transform);
1812
1813 struct weston_keyboard *
1814 weston_seat_get_keyboard(struct weston_seat *seat);
1815
1816 struct weston_pointer *
1817 weston_seat_get_pointer(struct weston_seat *seat);
1818
1819 struct weston_touch *
1820 weston_seat_get_touch(struct weston_seat *seat);
1821
1822 void
1823 weston_seat_set_keyboard_focus(struct weston_seat *seat,
1824                                struct weston_surface *surface);
1825
1826 int
1827 weston_compositor_load_xwayland(struct weston_compositor *compositor);
1828
1829 #ifdef  __cplusplus
1830 }
1831 #endif
1832
1833 #endif