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