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