2 * Copyright © 2008-2011 Kristian Høgsberg
3 * Copyright © 2012, 2017, 2018 Collabora, Ltd.
4 * Copyright © 2017, 2018 General Electric Company
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #ifndef _WAYLAND_SYSTEM_COMPOSITOR_H_
29 #define _WAYLAND_SYSTEM_COMPOSITOR_H_
39 #include <xkbcommon/xkbcommon.h>
41 #define WL_HIDE_DEPRECATED
42 #include <wayland-server.h>
45 #include "config-parser.h"
47 #include "timeline-object.h"
49 struct weston_geometry {
51 int32_t width, height;
54 struct weston_position {
59 int32_t width, height;
62 struct weston_transform {
63 struct weston_matrix matrix;
67 struct weston_surface;
73 struct weston_pointer;
74 struct linux_dmabuf_buffer;
75 struct weston_recorder;
76 struct weston_pointer_constraint;
78 enum weston_keyboard_modifier {
79 MODIFIER_CTRL = (1 << 0),
80 MODIFIER_ALT = (1 << 1),
81 MODIFIER_SUPER = (1 << 2),
82 MODIFIER_SHIFT = (1 << 3),
85 enum weston_keyboard_locks {
86 WESTON_NUM_LOCK = (1 << 0),
87 WESTON_CAPS_LOCK = (1 << 1),
91 LED_NUM_LOCK = (1 << 0),
92 LED_CAPS_LOCK = (1 << 1),
93 LED_SCROLL_LOCK = (1 << 2),
98 int32_t width, height;
103 struct weston_animation {
104 void (*frame)(struct weston_animation *animation,
105 struct weston_output *output,
106 const struct timespec *time);
112 WESTON_SPRING_OVERSHOOT,
117 struct weston_spring {
124 struct timespec timestamp;
128 struct weston_output_zoom {
133 float trans_x, trans_y;
137 struct weston_seat *seat;
138 struct weston_animation animation_z;
139 struct weston_spring spring_z;
140 struct wl_listener motion_listener;
143 /* bit compatible with drm definitions. */
151 /** Represents a monitor
153 * This object represents a monitor (hardware backends like DRM) or a window
154 * (windowed nested backends).
157 struct weston_compositor *compositor; /**< owning compositor */
158 struct wl_list compositor_link; /**< in weston_compositor::head_list */
159 struct wl_signal destroy_signal; /**< destroy callbacks */
161 struct weston_output *output; /**< the output driving this head */
162 struct wl_list output_link; /**< in weston_output::head_list */
164 struct wl_list resource_list; /**< wl_output protocol objects */
165 struct wl_global *global; /**< wl_output global */
167 int32_t mm_width; /**< physical image width in mm */
168 int32_t mm_height; /**< physical image height in mm */
169 char *make; /**< monitor manufacturer (PNP ID) */
170 char *model; /**< monitor model */
171 char *serial_number; /**< monitor serial */
172 uint32_t subpixel; /**< enum wl_output_subpixel */
173 bool connection_internal; /**< embedded monitor (e.g. laptop) */
174 bool device_changed; /**< monitor information has changed */
176 char *name; /**< head name, e.g. connector name */
177 bool connected; /**< is physically connected */
180 struct weston_output {
184 /** Matches the lifetime from the user perspective */
185 struct wl_signal user_destroy_signal;
187 void *renderer_state;
190 struct weston_compositor *compositor;
192 /** From global to output buffer coordinates. */
193 struct weston_matrix matrix;
194 /** From output buffer to global coordinates. */
195 struct weston_matrix inverse_matrix;
197 struct wl_list animation_list;
198 int32_t x, y, width, height;
200 /** Output area in global coordinates, simple rect */
201 pixman_region32_t region;
203 pixman_region32_t previous_damage;
205 /** True if damage has occurred since the last repaint for this output;
206 * if set, a repaint will eventually occur. */
209 /** State of the repaint loop */
211 REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */
212 REPAINT_BEGIN_FROM_IDLE, /**< start_repaint_loop scheduled */
213 REPAINT_SCHEDULED, /**< repaint is scheduled to occur */
214 REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
217 /** If repaint_status is REPAINT_SCHEDULED, contains the time the
218 * next repaint should be run */
219 struct timespec next_repaint;
221 /** For cancelling the idle_repaint callback on output destruction. */
222 struct wl_event_source *idle_repaint_source;
224 struct weston_output_zoom zoom;
226 struct wl_signal frame_signal;
227 struct wl_signal destroy_signal; /**< sent when disabled */
229 struct timespec frame_time; /* presentation timestamp */
230 uint64_t msc; /* media stream counter */
233 struct wl_list feedback_list;
236 int32_t native_scale;
237 int32_t current_scale;
238 int32_t original_scale;
240 struct weston_mode *native_mode;
241 struct weston_mode *current_mode;
242 struct weston_mode *original_mode;
243 struct wl_list mode_list;
245 struct wl_list head_list; /**< List of driven weston_heads */
247 void (*start_repaint_loop)(struct weston_output *output);
248 int (*repaint)(struct weston_output *output,
249 pixman_region32_t *damage,
251 void (*destroy)(struct weston_output *output);
252 void (*assign_planes)(struct weston_output *output, void *repaint_data);
253 int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
255 /* backlight values are on 0-255 range, where higher is brighter */
256 int32_t backlight_current;
257 void (*set_backlight)(struct weston_output *output, uint32_t value);
258 void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
261 void (*set_gamma)(struct weston_output *output,
267 struct weston_timeline_object timeline;
269 bool enabled; /**< is in the output_list, not pending list */
272 int (*enable)(struct weston_output *output);
273 int (*disable)(struct weston_output *output);
275 /** Attach a head in the backend
277 * @param output The output to attach to.
278 * @param head The head to attach.
279 * @return 0 on success, -1 on failure.
281 * Do anything necessary to account for a new head being attached to
282 * the output, and check any conditions possible. On failure, both
283 * the head and the output must be left as before the call.
285 * Libweston core will add the head to the head_list after a successful
288 int (*attach_head)(struct weston_output *output,
289 struct weston_head *head);
291 /** Detach a head in the backend
293 * @param output The output to detach from.
294 * @param head The head to detach.
296 * Do any clean-up necessary to detach this head from the output.
297 * The head has already been removed from the output's head_list.
299 void (*detach_head)(struct weston_output *output,
300 struct weston_head *head);
303 enum weston_pointer_motion_mask {
304 WESTON_POINTER_MOTION_ABS = 1 << 0,
305 WESTON_POINTER_MOTION_REL = 1 << 1,
306 WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2,
309 struct weston_pointer_motion_event {
311 struct timespec time;
320 struct weston_pointer_axis_event {
327 struct weston_pointer_grab;
328 struct weston_pointer_grab_interface {
329 void (*focus)(struct weston_pointer_grab *grab);
330 void (*motion)(struct weston_pointer_grab *grab,
331 const struct timespec *time,
332 struct weston_pointer_motion_event *event);
333 void (*button)(struct weston_pointer_grab *grab,
334 const struct timespec *time,
335 uint32_t button, uint32_t state);
336 void (*axis)(struct weston_pointer_grab *grab,
337 const struct timespec *time,
338 struct weston_pointer_axis_event *event);
339 void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source);
340 void (*frame)(struct weston_pointer_grab *grab);
341 void (*cancel)(struct weston_pointer_grab *grab);
344 struct weston_pointer_grab {
345 const struct weston_pointer_grab_interface *interface;
346 struct weston_pointer *pointer;
349 struct weston_keyboard_grab;
350 struct weston_keyboard_grab_interface {
351 void (*key)(struct weston_keyboard_grab *grab,
352 const struct timespec *time, uint32_t key, uint32_t state);
353 void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
354 uint32_t mods_depressed, uint32_t mods_latched,
355 uint32_t mods_locked, uint32_t group);
356 void (*cancel)(struct weston_keyboard_grab *grab);
359 struct weston_keyboard_grab {
360 const struct weston_keyboard_grab_interface *interface;
361 struct weston_keyboard *keyboard;
364 struct weston_touch_grab;
365 struct weston_touch_grab_interface {
366 void (*down)(struct weston_touch_grab *grab,
367 const struct timespec *time,
371 void (*up)(struct weston_touch_grab *grab,
372 const struct timespec *time,
374 void (*motion)(struct weston_touch_grab *grab,
375 const struct timespec *time,
379 void (*frame)(struct weston_touch_grab *grab);
380 void (*cancel)(struct weston_touch_grab *grab);
383 struct weston_touch_grab {
384 const struct weston_touch_grab_interface *interface;
385 struct weston_touch *touch;
388 struct weston_data_offer {
389 struct wl_resource *resource;
390 struct weston_data_source *source;
391 struct wl_listener source_destroy_listener;
392 uint32_t dnd_actions;
393 enum wl_data_device_manager_dnd_action preferred_dnd_action;
397 struct weston_data_source {
398 struct wl_resource *resource;
399 struct wl_signal destroy_signal;
400 struct wl_array mime_types;
401 struct weston_data_offer *offer;
402 struct weston_seat *seat;
405 uint32_t dnd_actions;
406 enum wl_data_device_manager_dnd_action current_dnd_action;
407 enum wl_data_device_manager_dnd_action compositor_action;
409 void (*accept)(struct weston_data_source *source,
410 uint32_t serial, const char *mime_type);
411 void (*send)(struct weston_data_source *source,
412 const char *mime_type, int32_t fd);
413 void (*cancel)(struct weston_data_source *source);
416 struct weston_pointer_client {
418 struct wl_client *client;
419 struct wl_list pointer_resources;
420 struct wl_list relative_pointer_resources;
423 struct weston_pointer {
424 struct weston_seat *seat;
426 struct wl_list pointer_clients;
428 struct weston_view *focus;
429 struct weston_pointer_client *focus_client;
430 uint32_t focus_serial;
431 struct wl_listener focus_view_listener;
432 struct wl_listener focus_resource_listener;
433 struct wl_signal focus_signal;
434 struct wl_signal motion_signal;
435 struct wl_signal destroy_signal;
437 struct weston_view *sprite;
438 struct wl_listener sprite_destroy_listener;
439 int32_t hotspot_x, hotspot_y;
441 struct weston_pointer_grab *grab;
442 struct weston_pointer_grab default_grab;
443 wl_fixed_t grab_x, grab_y;
444 uint32_t grab_button;
445 uint32_t grab_serial;
446 struct timespec grab_time;
450 uint32_t button_count;
452 struct wl_listener output_destroy_listener;
454 struct wl_list timestamps_list;
458 struct weston_touch {
459 struct weston_seat *seat;
461 struct wl_list resource_list;
462 struct wl_list focus_resource_list;
463 struct weston_view *focus;
464 struct wl_listener focus_view_listener;
465 struct wl_listener focus_resource_listener;
466 uint32_t focus_serial;
467 struct wl_signal focus_signal;
471 struct weston_touch_grab *grab;
472 struct weston_touch_grab default_grab;
474 wl_fixed_t grab_x, grab_y;
475 uint32_t grab_serial;
476 struct timespec grab_time;
478 struct wl_list timestamps_list;
482 weston_pointer_motion_to_abs(struct weston_pointer *pointer,
483 struct weston_pointer_motion_event *event,
484 wl_fixed_t *x, wl_fixed_t *y);
487 weston_pointer_send_motion(struct weston_pointer *pointer,
488 const struct timespec *time,
489 struct weston_pointer_motion_event *event);
491 weston_pointer_has_focus_resource(struct weston_pointer *pointer);
493 weston_pointer_send_button(struct weston_pointer *pointer,
494 const struct timespec *time,
495 uint32_t button, uint32_t state_w);
497 weston_pointer_send_axis(struct weston_pointer *pointer,
498 const struct timespec *time,
499 struct weston_pointer_axis_event *event);
501 weston_pointer_send_axis_source(struct weston_pointer *pointer,
504 weston_pointer_send_frame(struct weston_pointer *pointer);
507 weston_pointer_set_focus(struct weston_pointer *pointer,
508 struct weston_view *view,
509 wl_fixed_t sx, wl_fixed_t sy);
511 weston_pointer_clear_focus(struct weston_pointer *pointer);
513 weston_pointer_start_grab(struct weston_pointer *pointer,
514 struct weston_pointer_grab *grab);
516 weston_pointer_end_grab(struct weston_pointer *pointer);
518 weston_pointer_clamp(struct weston_pointer *pointer,
519 wl_fixed_t *fx, wl_fixed_t *fy);
521 weston_pointer_move(struct weston_pointer *pointer,
522 struct weston_pointer_motion_event *event);
524 weston_pointer_set_default_grab(struct weston_pointer *pointer,
525 const struct weston_pointer_grab_interface *interface);
528 weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint);
531 weston_keyboard_set_focus(struct weston_keyboard *keyboard,
532 struct weston_surface *surface);
534 weston_keyboard_start_grab(struct weston_keyboard *device,
535 struct weston_keyboard_grab *grab);
537 weston_keyboard_end_grab(struct weston_keyboard *keyboard);
540 * 'mask' and 'value' should be a bitwise mask of one or more
541 * valued of the weston_keyboard_locks enum.
543 weston_keyboard_set_locks(struct weston_keyboard *keyboard,
544 uint32_t mask, uint32_t value);
547 weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard);
549 weston_keyboard_send_key(struct weston_keyboard *keyboard,
550 const struct timespec *time, uint32_t key,
551 enum wl_keyboard_key_state state);
553 weston_keyboard_send_modifiers(struct weston_keyboard *keyboard,
554 uint32_t serial, uint32_t mods_depressed,
555 uint32_t mods_latched,
556 uint32_t mods_locked, uint32_t group);
559 weston_touch_set_focus(struct weston_touch *touch,
560 struct weston_view *view);
562 weston_touch_start_grab(struct weston_touch *touch,
563 struct weston_touch_grab *grab);
565 weston_touch_end_grab(struct weston_touch *touch);
568 weston_touch_has_focus_resource(struct weston_touch *touch);
570 weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
571 int touch_id, wl_fixed_t x, wl_fixed_t y);
573 weston_touch_send_up(struct weston_touch *touch, const struct timespec *time,
576 weston_touch_send_motion(struct weston_touch *touch,
577 const struct timespec *time, int touch_id,
578 wl_fixed_t x, wl_fixed_t y);
580 weston_touch_send_frame(struct weston_touch *touch);
583 wl_data_device_set_keyboard_focus(struct weston_seat *seat);
586 wl_data_device_manager_init(struct wl_display *display);
590 weston_seat_set_selection(struct weston_seat *seat,
591 struct weston_data_source *source, uint32_t serial);
593 weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client);
596 weston_pointer_start_drag(struct weston_pointer *pointer,
597 struct weston_data_source *source,
598 struct weston_surface *icon,
599 struct wl_client *client);
601 weston_touch_start_drag(struct weston_touch *touch,
602 struct weston_data_source *source,
603 struct weston_surface *icon,
604 struct wl_client *client);
606 struct weston_xkb_info {
607 struct xkb_keymap *keymap;
612 xkb_mod_index_t shift_mod;
613 xkb_mod_index_t caps_mod;
614 xkb_mod_index_t ctrl_mod;
615 xkb_mod_index_t alt_mod;
616 xkb_mod_index_t mod2_mod;
617 xkb_mod_index_t mod3_mod;
618 xkb_mod_index_t super_mod;
619 xkb_mod_index_t mod5_mod;
620 xkb_led_index_t num_led;
621 xkb_led_index_t caps_led;
622 xkb_led_index_t scroll_led;
625 struct weston_keyboard {
626 struct weston_seat *seat;
628 struct wl_list resource_list;
629 struct wl_list focus_resource_list;
630 struct weston_surface *focus;
631 struct wl_listener focus_resource_listener;
632 uint32_t focus_serial;
633 struct wl_signal focus_signal;
635 struct weston_keyboard_grab *grab;
636 struct weston_keyboard_grab default_grab;
638 uint32_t grab_serial;
639 struct timespec grab_time;
641 struct wl_array keys;
644 uint32_t mods_depressed;
645 uint32_t mods_latched;
646 uint32_t mods_locked;
650 struct weston_keyboard_grab input_method_grab;
651 struct wl_resource *input_method_resource;
653 struct weston_xkb_info *xkb_info;
655 struct xkb_state *state;
656 enum weston_led leds;
658 struct xkb_keymap *pending_keymap;
660 struct wl_list timestamps_list;
664 struct wl_list base_resource_list;
666 struct wl_global *global;
667 struct weston_pointer *pointer_state;
668 struct weston_keyboard *keyboard_state;
669 struct weston_touch *touch_state;
670 int pointer_device_count;
671 int keyboard_device_count;
672 int touch_device_count;
674 struct weston_output *output; /* constraint */
676 struct wl_signal destroy_signal;
677 struct wl_signal updated_caps_signal;
679 struct weston_compositor *compositor;
681 enum weston_keyboard_modifier modifier_state;
682 struct weston_surface *saved_kbd_focus;
683 struct wl_listener saved_kbd_focus_listener;
684 struct wl_list drag_resource_list;
686 uint32_t selection_serial;
687 struct weston_data_source *selection_data_source;
688 struct wl_listener selection_data_source_listener;
689 struct wl_signal selection_signal;
691 void (*led_update)(struct weston_seat *ws, enum weston_led leds);
693 struct input_method *input_method;
698 WESTON_COMPOSITOR_ACTIVE, /* normal rendering and events */
699 WESTON_COMPOSITOR_IDLE, /* shell->unlock called on activity */
700 WESTON_COMPOSITOR_OFFSCREEN, /* no rendering, no frame events */
701 WESTON_COMPOSITOR_SLEEPING /* same as offscreen, but also set dpms
705 struct weston_layer_entry {
707 struct weston_layer *layer;
711 * Higher value means higher in the stack.
713 * These values are based on well-known concepts in a classic desktop
714 * environment. Third-party modules based on libweston are encouraged to use
715 * them to integrate better with other projects.
717 * A fully integrated environment can use any value, based on these or not,
718 * at their discretion.
720 enum weston_layer_position {
722 * Special value to make the layer invisible and still rendered.
723 * This is used by compositors wanting e.g. minimized surfaces to still
724 * receive frame callbacks.
726 WESTON_LAYER_POSITION_HIDDEN = 0x00000000,
729 * There should always be a background layer with a surface covering
732 * If the compositor handles the background itself, it should use
735 * If the compositor supports runtime-loadable modules to set the
736 * background, it should put a solid color surface at (BACKGROUND - 1)
737 * and modules must use BACKGROUND.
739 WESTON_LAYER_POSITION_BACKGROUND = 0x00000002,
741 /* For "desktop widgets" and applications like conky. */
742 WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000,
744 /* For regular applications, only one layer should have this value
745 * to ensure proper stacking control. */
746 WESTON_LAYER_POSITION_NORMAL = 0x50000000,
748 /* For desktop UI, like panels. */
749 WESTON_LAYER_POSITION_UI = 0x80000000,
751 /* For fullscreen applications that should cover UI. */
752 WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000,
754 /* For special UI like on-screen keyboard that fullscreen applications
756 WESTON_LAYER_POSITION_TOP_UI = 0xe0000000,
758 /* For the lock surface. */
759 WESTON_LAYER_POSITION_LOCK = 0xffff0000,
761 /* Values reserved for libweston internal usage */
762 WESTON_LAYER_POSITION_CURSOR = 0xfffffffe,
763 WESTON_LAYER_POSITION_FADE = 0xffffffff,
766 struct weston_layer {
767 struct weston_compositor *compositor;
768 struct wl_list link; /* weston_compositor::layer_list */
769 enum weston_layer_position position;
771 struct weston_layer_entry view_list;
774 struct weston_plane {
775 struct weston_compositor *compositor;
776 pixman_region32_t damage; /**< in global coords */
777 pixman_region32_t clip;
782 struct weston_renderer {
783 int (*read_pixels)(struct weston_output *output,
784 pixman_format_code_t format, void *pixels,
785 uint32_t x, uint32_t y,
786 uint32_t width, uint32_t height);
787 void (*repaint_output)(struct weston_output *output,
788 pixman_region32_t *output_damage);
789 void (*flush_damage)(struct weston_surface *surface);
790 void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
791 void (*surface_set_color)(struct weston_surface *surface,
792 float red, float green,
793 float blue, float alpha);
794 void (*destroy)(struct weston_compositor *ec);
797 /** See weston_surface_get_content_size() */
798 void (*surface_get_content_size)(struct weston_surface *surface,
799 int *width, int *height);
801 /** See weston_surface_copy_content() */
802 int (*surface_copy_content)(struct weston_surface *surface,
803 void *target, size_t size,
804 int src_x, int src_y,
805 int width, int height);
807 /** See weston_compositor_import_dmabuf() */
808 bool (*import_dmabuf)(struct weston_compositor *ec,
809 struct linux_dmabuf_buffer *buffer);
811 /** On error sets num_formats to zero */
812 void (*query_dmabuf_formats)(struct weston_compositor *ec,
813 int **formats, int *num_formats);
815 /** On error sets num_modifiers to zero */
816 void (*query_dmabuf_modifiers)(struct weston_compositor *ec,
817 int format, uint64_t **modifiers,
821 enum weston_capability {
822 /* backend/renderer supports arbitrary rotation */
823 WESTON_CAP_ROTATION_ANY = 0x0001,
825 /* screencaptures need to be y-flipped */
826 WESTON_CAP_CAPTURE_YFLIP = 0x0002,
828 /* backend/renderer has a separate cursor plane */
829 WESTON_CAP_CURSOR_PLANE = 0x0004,
831 /* backend supports setting arbitrary resolutions */
832 WESTON_CAP_ARBITRARY_MODES = 0x0008,
834 /* renderer supports weston_view_set_mask() clipping */
835 WESTON_CAP_VIEW_CLIP_MASK = 0x0010,
838 /* Configuration struct for a backend.
840 * This struct carries the configuration for a backend, and it's
841 * passed to the backend's init entry point. The backend will
842 * likely want to subclass this in order to handle backend specific
845 * NOTE: Alternate designs were proposed (Feb 2016) for using opaque
846 * structures[1] and for section+key/value getter/setters[2]. The rationale
847 * for selecting the transparent structure design is based on several
848 * assumptions[3] which may require re-evaluating the design choice if they
851 * 1: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026989.html
852 * 2: https://lists.freedesktop.org/archives/wayland-devel/2016-February/026929.html
853 * 3: https://lists.freedesktop.org/archives/wayland-devel/2016-February/027228.html
855 struct weston_backend_config {
856 /** Major version for the backend-specific config struct
858 * This version must match exactly what the backend expects, otherwise
859 * the struct is incompatible.
861 uint32_t struct_version;
863 /** Minor version of the backend-specific config struct
865 * This must be set to sizeof(struct backend-specific config).
866 * If the value here is smaller than what the backend expects, the
867 * extra config members will assume their default values.
869 * A value greater than what the backend expects is incompatible.
874 struct weston_backend {
875 void (*destroy)(struct weston_compositor *compositor);
877 /** Begin a repaint sequence
879 * Provides the backend with explicit markers around repaint
880 * sequences, which may allow the backend to aggregate state
881 * application. This call will be bracketed by the repaint_flush (on
882 * success), or repaint_cancel (when any output in the grouping fails
885 * Returns an opaque pointer, which the backend may use as private
886 * data referring to the repaint cycle.
888 void * (*repaint_begin)(struct weston_compositor *compositor);
890 /** Cancel a repaint sequence
892 * Cancels a repaint sequence, when an error has occurred during
893 * one output's repaint; see repaint_begin.
895 * @param repaint_data Data returned by repaint_begin
897 void (*repaint_cancel)(struct weston_compositor *compositor,
900 /** Conclude a repaint sequence
902 * Called on successful completion of a repaint sequence; see
905 * @param repaint_data Data returned by repaint_begin
907 void (*repaint_flush)(struct weston_compositor *compositor,
910 /** Allocate a new output
912 * @param compositor The compositor.
913 * @param name Name for the new output.
915 * Allocates a new output structure that embeds a weston_output,
916 * initializes it, and returns the pointer to the weston_output
919 * Must set weston_output members @c destroy, @c enable and @c disable.
921 struct weston_output *
922 (*create_output)(struct weston_compositor *compositor,
926 struct weston_desktop_xwayland;
927 struct weston_desktop_xwayland_interface;
929 struct weston_compositor {
930 struct wl_signal destroy_signal;
932 struct wl_display *wl_display;
933 struct weston_desktop_xwayland *xwayland;
934 const struct weston_desktop_xwayland_interface *xwayland_interface;
936 /* surface signals */
937 struct wl_signal create_surface_signal;
938 struct wl_signal activate_signal;
939 struct wl_signal transform_signal;
941 struct wl_signal kill_signal;
942 struct wl_signal idle_signal;
943 struct wl_signal wake_signal;
945 struct wl_signal show_input_panel_signal;
946 struct wl_signal hide_input_panel_signal;
947 struct wl_signal update_input_panel_signal;
949 struct wl_signal seat_created_signal;
950 struct wl_signal output_created_signal;
951 struct wl_signal output_destroyed_signal;
952 struct wl_signal output_moved_signal;
953 struct wl_signal output_resized_signal; /* callback argument: resized output */
955 /* Signal for output changes triggered by configuration from frontend
956 * or head state changes from backend.
958 struct wl_signal output_heads_changed_signal; /* arg: weston_output */
960 struct wl_signal session_signal;
963 struct weston_layer fade_layer;
964 struct weston_layer cursor_layer;
966 struct wl_list pending_output_list;
967 struct wl_list output_list;
968 struct wl_list head_list; /* struct weston_head::compositor_link */
969 struct wl_list seat_list;
970 struct wl_list layer_list; /* struct weston_layer::link */
971 struct wl_list view_list; /* struct weston_view::link */
972 struct wl_list plane_list;
973 struct wl_list key_binding_list;
974 struct wl_list modifier_binding_list;
975 struct wl_list button_binding_list;
976 struct wl_list touch_binding_list;
977 struct wl_list axis_binding_list;
978 struct wl_list debug_binding_list;
981 struct wl_event_source *idle_source;
982 uint32_t idle_inhibit;
983 int idle_time; /* timeout, s */
984 struct wl_event_source *repaint_timer;
986 const struct weston_pointer_grab_interface *default_pointer_grab;
989 struct weston_plane primary_plane;
990 uint32_t capabilities; /* combination of enum weston_capability */
992 struct weston_renderer *renderer;
994 pixman_format_code_t read_format;
996 struct weston_backend *backend;
998 struct weston_launcher *launcher;
1000 struct wl_list plugin_api_list; /* struct weston_plugin_api::link */
1002 uint32_t output_id_pool;
1004 struct xkb_rule_names xkb_names;
1005 struct xkb_context *xkb_context;
1006 struct weston_xkb_info *xkb_info;
1008 int32_t kb_repeat_rate;
1009 int32_t kb_repeat_delay;
1013 clockid_t presentation_clock;
1014 int32_t repaint_msec;
1016 unsigned int activate_serial;
1018 struct wl_global *pointer_constraints;
1023 void (*exit)(struct weston_compositor *c);
1025 /* Whether to let the compositor run without any input device. */
1028 /* Signal for a backend to inform a frontend about possible changes
1031 struct wl_signal heads_changed_signal;
1032 struct wl_event_source *heads_changed_source;
1035 struct weston_buffer {
1036 struct wl_resource *resource;
1037 struct wl_signal destroy_signal;
1038 struct wl_listener destroy_listener;
1041 struct wl_shm_buffer *shm_buffer;
1042 void *legacy_buffer;
1044 int32_t width, height;
1045 uint32_t busy_count;
1049 struct weston_buffer_reference {
1050 struct weston_buffer *buffer;
1051 struct wl_listener destroy_listener;
1054 struct weston_buffer_viewport {
1056 /* wl_surface.set_buffer_transform */
1059 /* wl_surface.set_scaling_factor */
1063 * If src_width != wl_fixed_from_int(-1),
1064 * then and only then src_* are used.
1066 wl_fixed_t src_x, src_y;
1067 wl_fixed_t src_width, src_height;
1072 * If width == -1, the size is inferred from the buffer.
1074 int32_t width, height;
1080 struct weston_region {
1081 struct wl_resource *resource;
1082 pixman_region32_t region;
1085 /* Using weston_view transformations
1087 * To add a transformation to a view, create a struct weston_transform, and
1088 * add it to the list view->geometry.transformation_list. Whenever you
1089 * change the list, anything under view->geometry, or anything in the
1090 * weston_transforms linked into the list, you must call
1091 * weston_view_geometry_dirty().
1093 * The order in the list defines the order of transformations. Let the list
1094 * contain the transformation matrices M1, ..., Mn as head to tail. The
1095 * transformation is applied to view-local coordinate vector p as
1096 * P = Mn * ... * M2 * M1 * p
1097 * to produce the global coordinate vector P. The total transform
1098 * Mn * ... * M2 * M1
1099 * is cached in view->transform.matrix, and the inverse of it in
1100 * view->transform.inverse.
1102 * The list always contains view->transform.position transformation, which
1103 * is the translation by view->geometry.x and y.
1105 * If you want to apply a transformation in local coordinates, add your
1106 * weston_transform to the head of the list. If you want to apply a
1107 * transformation in global coordinates, add it to the tail of the list.
1109 * If view->geometry.parent is set, the total transformation of this
1110 * view will be the parent's total transformation and this transformation
1112 * Mparent * Mn * ... * M2 * M1
1115 struct weston_view {
1116 struct weston_surface *surface;
1117 struct wl_list surface_link;
1118 struct wl_signal destroy_signal;
1120 struct wl_list link; /* weston_compositor::view_list */
1121 struct weston_layer_entry layer_link; /* part of geometry */
1122 struct weston_plane *plane;
1124 /* For weston_layer inheritance from another view */
1125 struct weston_view *parent_view;
1127 unsigned int click_to_activate_serial;
1129 pixman_region32_t clip; /* See weston_view_damage_below() */
1130 float alpha; /* part of geometry, see below */
1132 void *renderer_state;
1134 /* Surface geometry state, mutable.
1135 * If you change anything, call weston_surface_geometry_dirty().
1136 * That includes the transformations referenced from the list.
1139 float x, y; /* surface translation on display */
1141 /* struct weston_transform */
1142 struct wl_list transformation_list;
1144 /* managed by weston_surface_set_transform_parent() */
1145 struct weston_view *parent;
1146 struct wl_listener parent_destroy_listener;
1147 struct wl_list child_list; /* geometry.parent_link */
1148 struct wl_list parent_link;
1150 /* managed by weston_view_set_mask() */
1151 bool scissor_enabled;
1152 pixman_region32_t scissor; /* always a simple rect */
1155 /* State derived from geometry state, read-only.
1156 * This is updated by weston_view_update_transform().
1161 /* Approximations in global coordinates:
1162 * - boundingbox is guaranteed to include the whole view in
1163 * the smallest possible single rectangle.
1164 * - opaque is guaranteed to be fully opaque, though not
1165 * necessarily include all opaque areas.
1167 pixman_region32_t boundingbox;
1168 pixman_region32_t opaque;
1170 /* matrix and inverse are used only if enabled = 1.
1171 * If enabled = 0, use x, y, width, height directly.
1174 struct weston_matrix matrix;
1175 struct weston_matrix inverse;
1177 struct weston_transform position; /* matrix from x, y */
1181 * The primary output for this view.
1182 * Used for picking the output for driving internal animations on the
1183 * view, inheriting the primary output for related views in shells, etc.
1185 struct weston_output *output;
1186 struct wl_listener output_destroy_listener;
1189 * A more complete representation of all outputs this surface is
1192 uint32_t output_mask;
1194 /* Per-surface Presentation feedback flags, controlled by backend. */
1200 struct weston_surface_state {
1201 /* wl_surface.attach */
1203 struct weston_buffer *buffer;
1204 struct wl_listener buffer_destroy_listener;
1208 /* wl_surface.damage */
1209 pixman_region32_t damage_surface;
1210 /* wl_surface.damage_buffer */
1211 pixman_region32_t damage_buffer;
1213 /* wl_surface.set_opaque_region */
1214 pixman_region32_t opaque;
1216 /* wl_surface.set_input_region */
1217 pixman_region32_t input;
1219 /* wl_surface.frame */
1220 struct wl_list frame_callback_list;
1222 /* presentation.feedback */
1223 struct wl_list feedback_list;
1225 /* wl_surface.set_buffer_transform */
1226 /* wl_surface.set_scaling_factor */
1227 /* wp_viewport.set_source */
1228 /* wp_viewport.set_destination */
1229 struct weston_buffer_viewport buffer_viewport;
1232 struct weston_surface_activation_data {
1233 struct weston_surface *surface;
1234 struct weston_seat *seat;
1237 struct weston_pointer_constraint {
1238 struct wl_list link;
1240 struct weston_surface *surface;
1241 struct weston_view *view;
1242 struct wl_resource *resource;
1243 struct weston_pointer_grab grab;
1244 struct weston_pointer *pointer;
1247 pixman_region32_t region;
1248 pixman_region32_t region_pending;
1249 bool region_is_pending;
1253 wl_fixed_t hint_x_pending;
1254 wl_fixed_t hint_y_pending;
1255 bool hint_is_pending;
1257 struct wl_listener pointer_destroy_listener;
1258 struct wl_listener surface_destroy_listener;
1259 struct wl_listener surface_commit_listener;
1260 struct wl_listener surface_activate_listener;
1263 struct weston_surface {
1264 struct wl_resource *resource;
1265 struct wl_signal destroy_signal; /* callback argument: this surface */
1266 struct weston_compositor *compositor;
1267 struct wl_signal commit_signal;
1269 /** Damage in local coordinates from the client, for tex upload. */
1270 pixman_region32_t damage;
1272 pixman_region32_t opaque; /* part of geometry, see below */
1273 pixman_region32_t input;
1274 int32_t width, height;
1277 /* Not for long-term storage. This exists for book-keeping while
1278 * iterating over surfaces and views
1282 void *renderer_state;
1284 struct wl_list views;
1287 * Which output to vsync this surface to.
1288 * Used to determine whether to send or queue frame events, and for
1289 * other client-visible syncing/throttling tied to the output
1292 struct weston_output *output;
1295 * A more complete representation of all outputs this surface is
1298 uint32_t output_mask;
1300 struct wl_list frame_callback_list;
1301 struct wl_list feedback_list;
1303 struct weston_buffer_reference buffer_ref;
1304 struct weston_buffer_viewport buffer_viewport;
1305 int32_t width_from_buffer; /* before applying viewport */
1306 int32_t height_from_buffer;
1307 bool keep_buffer; /* for backends to prevent early release */
1309 /* wp_viewport resource for this surface */
1310 struct wl_resource *viewport_resource;
1312 /* All the pending state, that wl_surface.commit will apply. */
1313 struct weston_surface_state pending;
1315 /* Matrices representating of the full transformation between
1316 * buffer and surface coordinates. These matrices are updated
1317 * using the weston_surface_build_buffer_matrix function. */
1318 struct weston_matrix buffer_to_surface_matrix;
1319 struct weston_matrix surface_to_buffer_matrix;
1322 * If non-NULL, this function will be called on
1323 * wl_surface::commit after a new buffer has been set up for
1324 * this surface. The integer params are the sx and sy
1325 * parameters supplied to wl_surface::attach.
1327 void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy);
1328 void *committed_private;
1329 int (*get_label)(struct weston_surface *surface, char *buf, size_t len);
1331 /* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
1332 * Contains also the parent itself as a dummy weston_subsurface,
1333 * if the list is not empty.
1335 struct wl_list subsurface_list; /* weston_subsurface::parent_link */
1336 struct wl_list subsurface_list_pending; /* ...::parent_link_pending */
1339 * For tracking protocol role assignments. Different roles may
1340 * have the same configure hook, e.g. in shell.c. Configure hook
1341 * may get reset, this will not.
1342 * XXX: map configure functions 1:1 to roles, and never reset it,
1343 * and replace role_name with configure.
1345 const char *role_name;
1347 struct weston_timeline_object timeline;
1351 /* An list of per seat pointer constraints. */
1352 struct wl_list pointer_constraints;
1355 struct weston_subsurface {
1356 struct wl_resource *resource;
1358 /* guaranteed to be valid and non-NULL */
1359 struct weston_surface *surface;
1360 struct wl_listener surface_destroy_listener;
1363 struct weston_surface *parent;
1364 struct wl_listener parent_destroy_listener;
1365 struct wl_list parent_link;
1366 struct wl_list parent_link_pending;
1374 int has_cached_data;
1375 struct weston_surface_state cached;
1376 struct weston_buffer_reference cached_buffer_ref;
1378 /* Sub-surface has been reordered; need to apply damage. */
1383 /* Used for constructing the view tree */
1384 struct wl_list unused_views;
1387 enum weston_key_state_update {
1388 STATE_UPDATE_AUTOMATIC,
1392 enum weston_activate_flag {
1393 WESTON_ACTIVATE_FLAG_NONE = 0,
1394 WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0,
1395 WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1,
1399 weston_version(int *major, int *minor, int *micro);
1402 weston_view_set_output(struct weston_view *view, struct weston_output *output);
1405 weston_view_update_transform(struct weston_view *view);
1408 weston_view_geometry_dirty(struct weston_view *view);
1411 weston_view_to_global_fixed(struct weston_view *view,
1412 wl_fixed_t sx, wl_fixed_t sy,
1413 wl_fixed_t *x, wl_fixed_t *y);
1415 weston_view_to_global_float(struct weston_view *view,
1416 float sx, float sy, float *x, float *y);
1419 weston_view_from_global_float(struct weston_view *view,
1420 float x, float y, float *vx, float *vy);
1422 weston_view_from_global(struct weston_view *view,
1423 int32_t x, int32_t y, int32_t *vx, int32_t *vy);
1425 weston_view_from_global_fixed(struct weston_view *view,
1426 wl_fixed_t x, wl_fixed_t y,
1427 wl_fixed_t *vx, wl_fixed_t *vy);
1430 weston_surface_to_buffer_float(struct weston_surface *surface,
1431 float x, float y, float *bx, float *by);
1433 weston_surface_to_buffer_rect(struct weston_surface *surface,
1434 pixman_box32_t rect);
1437 weston_surface_to_buffer_region(struct weston_surface *surface,
1438 pixman_region32_t *surface_region,
1439 pixman_region32_t *buffer_region);
1442 weston_spring_init(struct weston_spring *spring,
1443 double k, double current, double target);
1445 weston_spring_update(struct weston_spring *spring, const struct timespec *time);
1447 weston_spring_done(struct weston_spring *spring);
1450 weston_view_activate(struct weston_view *view,
1451 struct weston_seat *seat,
1455 notify_motion(struct weston_seat *seat, const struct timespec *time,
1456 struct weston_pointer_motion_event *event);
1458 notify_motion_absolute(struct weston_seat *seat, const struct timespec *time,
1459 double x, double y);
1461 notify_button(struct weston_seat *seat, const struct timespec *time,
1462 int32_t button, enum wl_pointer_button_state state);
1464 notify_axis(struct weston_seat *seat, const struct timespec *time,
1465 struct weston_pointer_axis_event *event);
1467 notify_axis_source(struct weston_seat *seat, uint32_t source);
1470 notify_pointer_frame(struct weston_seat *seat);
1473 notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key,
1474 enum wl_keyboard_key_state state,
1475 enum weston_key_state_update update_state);
1477 notify_modifiers(struct weston_seat *seat, uint32_t serial);
1480 notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
1481 double x, double y);
1484 notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
1485 enum weston_key_state_update update_state);
1487 notify_keyboard_focus_out(struct weston_seat *seat);
1490 notify_touch(struct weston_seat *seat, const struct timespec *time,
1491 int touch_id, double x, double y, int touch_type);
1493 notify_touch_frame(struct weston_seat *seat);
1496 notify_touch_cancel(struct weston_seat *seat);
1499 weston_layer_entry_insert(struct weston_layer_entry *list,
1500 struct weston_layer_entry *entry);
1502 weston_layer_entry_remove(struct weston_layer_entry *entry);
1504 weston_layer_init(struct weston_layer *layer,
1505 struct weston_compositor *compositor);
1507 weston_layer_set_position(struct weston_layer *layer,
1508 enum weston_layer_position position);
1510 weston_layer_unset_position(struct weston_layer *layer);
1513 weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height);
1516 weston_layer_set_mask_infinite(struct weston_layer *layer);
1519 weston_plane_init(struct weston_plane *plane,
1520 struct weston_compositor *ec,
1521 int32_t x, int32_t y);
1523 weston_plane_release(struct weston_plane *plane);
1526 weston_compositor_stack_plane(struct weston_compositor *ec,
1527 struct weston_plane *plane,
1528 struct weston_plane *above);
1530 /* An invalid flag in presented_flags to catch logic errors. */
1531 #define WP_PRESENTATION_FEEDBACK_INVALID (1U << 31)
1534 weston_output_finish_frame(struct weston_output *output,
1535 const struct timespec *stamp,
1536 uint32_t presented_flags);
1538 weston_output_schedule_repaint(struct weston_output *output);
1540 weston_output_damage(struct weston_output *output);
1542 weston_compositor_schedule_repaint(struct weston_compositor *compositor);
1544 weston_compositor_fade(struct weston_compositor *compositor, float tint);
1546 weston_compositor_damage_all(struct weston_compositor *compositor);
1548 weston_compositor_unlock(struct weston_compositor *compositor);
1550 weston_compositor_wake(struct weston_compositor *compositor);
1552 weston_compositor_offscreen(struct weston_compositor *compositor);
1554 weston_compositor_sleep(struct weston_compositor *compositor);
1555 struct weston_view *
1556 weston_compositor_pick_view(struct weston_compositor *compositor,
1557 wl_fixed_t x, wl_fixed_t y,
1558 wl_fixed_t *sx, wl_fixed_t *sy);
1561 struct weston_binding;
1562 typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
1563 const struct timespec *time,
1566 struct weston_binding *
1567 weston_compositor_add_key_binding(struct weston_compositor *compositor,
1569 enum weston_keyboard_modifier modifier,
1570 weston_key_binding_handler_t binding,
1573 typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard,
1574 enum weston_keyboard_modifier modifier,
1576 struct weston_binding *
1577 weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
1578 enum weston_keyboard_modifier modifier,
1579 weston_modifier_binding_handler_t binding,
1582 typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer,
1583 const struct timespec *time,
1586 struct weston_binding *
1587 weston_compositor_add_button_binding(struct weston_compositor *compositor,
1589 enum weston_keyboard_modifier modifier,
1590 weston_button_binding_handler_t binding,
1593 typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch,
1594 const struct timespec *time,
1596 struct weston_binding *
1597 weston_compositor_add_touch_binding(struct weston_compositor *compositor,
1598 enum weston_keyboard_modifier modifier,
1599 weston_touch_binding_handler_t binding,
1602 typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer,
1603 const struct timespec *time,
1604 struct weston_pointer_axis_event *event,
1606 struct weston_binding *
1607 weston_compositor_add_axis_binding(struct weston_compositor *compositor,
1609 enum weston_keyboard_modifier modifier,
1610 weston_axis_binding_handler_t binding,
1612 struct weston_binding *
1613 weston_compositor_add_debug_binding(struct weston_compositor *compositor,
1615 weston_key_binding_handler_t binding,
1618 weston_binding_destroy(struct weston_binding *binding);
1621 weston_install_debug_key_binding(struct weston_compositor *compositor,
1625 weston_binding_list_destroy_all(struct wl_list *list);
1628 weston_compositor_run_key_binding(struct weston_compositor *compositor,
1629 struct weston_keyboard *keyboard,
1630 const struct timespec *time,
1632 enum wl_keyboard_key_state state);
1635 weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
1636 struct weston_keyboard *keyboard,
1637 enum weston_keyboard_modifier modifier,
1638 enum wl_keyboard_key_state state);
1640 weston_compositor_run_button_binding(struct weston_compositor *compositor,
1641 struct weston_pointer *pointer,
1642 const struct timespec *time,
1644 enum wl_pointer_button_state value);
1646 weston_compositor_run_touch_binding(struct weston_compositor *compositor,
1647 struct weston_touch *touch,
1648 const struct timespec *time,
1651 weston_compositor_run_axis_binding(struct weston_compositor *compositor,
1652 struct weston_pointer *pointer,
1653 const struct timespec *time,
1654 struct weston_pointer_axis_event *event);
1656 weston_compositor_run_debug_binding(struct weston_compositor *compositor,
1657 struct weston_keyboard *keyboard,
1658 const struct timespec *time,
1660 enum wl_keyboard_key_state state);
1663 weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
1664 const struct weston_pointer_grab_interface *interface);
1667 weston_environment_get_fd(const char *env);
1669 struct weston_surface *
1670 weston_surface_create(struct weston_compositor *compositor);
1672 struct weston_view *
1673 weston_view_create(struct weston_surface *surface);
1676 weston_view_destroy(struct weston_view *view);
1679 weston_view_set_position(struct weston_view *view,
1683 weston_view_set_transform_parent(struct weston_view *view,
1684 struct weston_view *parent);
1687 weston_view_set_mask(struct weston_view *view,
1688 int x, int y, int width, int height);
1691 weston_view_set_mask_infinite(struct weston_view *view);
1694 weston_view_is_mapped(struct weston_view *view);
1697 weston_view_schedule_repaint(struct weston_view *view);
1700 weston_surface_is_mapped(struct weston_surface *surface);
1703 weston_surface_set_size(struct weston_surface *surface,
1704 int32_t width, int32_t height);
1707 weston_surface_schedule_repaint(struct weston_surface *surface);
1710 weston_surface_damage(struct weston_surface *surface);
1713 weston_view_damage_below(struct weston_view *view);
1716 weston_view_move_to_plane(struct weston_view *view,
1717 struct weston_plane *plane);
1719 weston_view_unmap(struct weston_view *view);
1722 weston_surface_unmap(struct weston_surface *surface);
1724 struct weston_surface *
1725 weston_surface_get_main_surface(struct weston_surface *surface);
1728 weston_surface_set_role(struct weston_surface *surface,
1729 const char *role_name,
1730 struct wl_resource *error_resource,
1731 uint32_t error_code);
1733 weston_surface_get_role(struct weston_surface *surface);
1736 weston_surface_set_label_func(struct weston_surface *surface,
1737 int (*desc)(struct weston_surface *,
1741 weston_surface_get_content_size(struct weston_surface *surface,
1742 int *width, int *height);
1744 struct weston_geometry
1745 weston_surface_get_bounding_box(struct weston_surface *surface);
1748 weston_surface_copy_content(struct weston_surface *surface,
1749 void *target, size_t size,
1750 int src_x, int src_y,
1751 int width, int height);
1753 struct weston_buffer *
1754 weston_buffer_from_resource(struct wl_resource *resource);
1757 weston_buffer_reference(struct weston_buffer_reference *ref,
1758 struct weston_buffer *buffer);
1761 weston_compositor_get_time(struct timespec *time);
1764 weston_compositor_destroy(struct weston_compositor *ec);
1765 struct weston_compositor *
1766 weston_compositor_create(struct wl_display *display, void *user_data);
1768 enum weston_compositor_backend {
1770 WESTON_BACKEND_FBDEV,
1771 WESTON_BACKEND_HEADLESS,
1773 WESTON_BACKEND_WAYLAND,
1778 weston_compositor_load_backend(struct weston_compositor *compositor,
1779 enum weston_compositor_backend backend,
1780 struct weston_backend_config *config_base);
1782 weston_compositor_exit(struct weston_compositor *ec);
1784 weston_compositor_get_user_data(struct weston_compositor *compositor);
1786 weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
1789 weston_compositor_set_presentation_clock_software(
1790 struct weston_compositor *compositor);
1792 weston_compositor_read_presentation_clock(
1793 const struct weston_compositor *compositor,
1794 struct timespec *ts);
1797 weston_compositor_import_dmabuf(struct weston_compositor *compositor,
1798 struct linux_dmabuf_buffer *buffer);
1801 weston_compositor_shutdown(struct weston_compositor *ec);
1803 weston_compositor_exit_with_code(struct weston_compositor *compositor,
1806 weston_output_init_zoom(struct weston_output *output);
1808 weston_output_update_zoom(struct weston_output *output);
1810 weston_output_activate_zoom(struct weston_output *output,
1811 struct weston_seat *seat);
1813 weston_output_move(struct weston_output *output, int x, int y);
1816 weston_output_add_destroy_listener(struct weston_output *output,
1817 struct wl_listener *listener);
1818 struct wl_listener *
1819 weston_output_get_destroy_listener(struct weston_output *output,
1820 wl_notify_func_t notify);
1822 weston_output_release(struct weston_output *output);
1824 weston_output_transform_coordinate(struct weston_output *output,
1825 double device_x, double device_y,
1826 double *x, double *y);
1829 weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
1830 const char *seat_name);
1832 weston_seat_init_pointer(struct weston_seat *seat);
1834 weston_seat_release_pointer(struct weston_seat *seat);
1836 weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
1838 weston_seat_release_keyboard(struct weston_seat *seat);
1840 weston_seat_init_touch(struct weston_seat *seat);
1842 weston_seat_release_touch(struct weston_seat *seat);
1844 weston_seat_repick(struct weston_seat *seat);
1846 weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap);
1849 weston_seat_release(struct weston_seat *seat);
1851 weston_compositor_set_xkb_rule_names(struct weston_compositor *ec,
1852 struct xkb_rule_names *names);
1854 weston_compositor_xkb_destroy(struct weston_compositor *ec);
1856 /* String literal of spaces, the same width as the timestamp. */
1857 #define STAMP_SPACE " "
1859 typedef int (*log_func_t)(const char *fmt, va_list ap);
1861 weston_log_set_handler(log_func_t log, log_func_t cont);
1863 weston_vlog(const char *fmt, va_list ap);
1865 weston_vlog_continue(const char *fmt, va_list ap);
1867 weston_log(const char *fmt, ...)
1868 __attribute__ ((format (printf, 1, 2)));
1870 weston_log_continue(const char *fmt, ...)
1871 __attribute__ ((format (printf, 1, 2)));
1879 tty_create(struct weston_compositor *compositor, int tty_nr);
1882 tty_destroy(struct tty *tty);
1885 tty_reset(struct tty *tty);
1888 tty_activate_vt(struct tty *tty, int vt);
1890 enum weston_screenshooter_outcome {
1891 WESTON_SCREENSHOOTER_SUCCESS,
1892 WESTON_SCREENSHOOTER_NO_MEMORY,
1893 WESTON_SCREENSHOOTER_BAD_BUFFER
1896 typedef void (*weston_screenshooter_done_func_t)(void *data,
1897 enum weston_screenshooter_outcome outcome);
1899 weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer,
1900 weston_screenshooter_done_func_t done, void *data);
1901 struct weston_recorder *
1902 weston_recorder_start(struct weston_output *output, const char *filename);
1904 weston_recorder_stop(struct weston_recorder *recorder);
1907 clipboard_create(struct weston_seat *seat);
1909 struct weston_view_animation;
1910 typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data);
1913 weston_view_animation_destroy(struct weston_view_animation *animation);
1915 struct weston_view_animation *
1916 weston_zoom_run(struct weston_view *view, float start, float stop,
1917 weston_view_animation_done_func_t done, void *data);
1919 struct weston_view_animation *
1920 weston_fade_run(struct weston_view *view,
1921 float start, float end, float k,
1922 weston_view_animation_done_func_t done, void *data);
1924 struct weston_view_animation *
1925 weston_move_scale_run(struct weston_view *view, int dx, int dy,
1926 float start, float end, bool reverse,
1927 weston_view_animation_done_func_t done, void *data);
1929 struct weston_view_animation *
1930 weston_move_run(struct weston_view *view, int dx, int dy,
1931 float start, float end, bool reverse,
1932 weston_view_animation_done_func_t done, void *data);
1935 weston_fade_update(struct weston_view_animation *fade, float target);
1937 struct weston_view_animation *
1938 weston_stable_fade_run(struct weston_view *front_view, float start,
1939 struct weston_view *back_view, float end,
1940 weston_view_animation_done_func_t done, void *data);
1942 struct weston_view_animation *
1943 weston_slide_run(struct weston_view *view, float start, float stop,
1944 weston_view_animation_done_func_t done, void *data);
1947 weston_surface_set_color(struct weston_surface *surface,
1948 float red, float green, float blue, float alpha);
1951 weston_surface_destroy(struct weston_surface *surface);
1954 weston_output_mode_set_native(struct weston_output *output,
1955 struct weston_mode *mode,
1958 weston_output_mode_switch_to_temporary(struct weston_output *output,
1959 struct weston_mode *mode,
1962 weston_output_mode_switch_to_native(struct weston_output *output);
1965 noop_renderer_init(struct weston_compositor *ec);
1968 weston_input_init(struct weston_compositor *compositor);
1971 weston_backend_init(struct weston_compositor *c,
1972 struct weston_backend_config *config_base);
1974 weston_module_init(struct weston_compositor *compositor);
1977 weston_transformed_coord(int width, int height,
1978 enum wl_output_transform transform,
1980 float sx, float sy, float *bx, float *by);
1982 weston_transformed_rect(int width, int height,
1983 enum wl_output_transform transform,
1985 pixman_box32_t rect);
1987 weston_matrix_transform_region(pixman_region32_t *dest,
1988 struct weston_matrix *matrix,
1989 pixman_region32_t *src);
1991 weston_transformed_region(int width, int height,
1992 enum wl_output_transform transform,
1994 pixman_region32_t *src, pixman_region32_t *dest);
1997 weston_load_module(const char *name, const char *entrypoint);
2000 weston_parse_transform(const char *transform, uint32_t *out);
2003 weston_transform_to_string(uint32_t output_transform);
2005 struct weston_keyboard *
2006 weston_seat_get_keyboard(struct weston_seat *seat);
2008 struct weston_pointer *
2009 weston_seat_get_pointer(struct weston_seat *seat);
2011 struct weston_touch *
2012 weston_seat_get_touch(struct weston_seat *seat);
2015 weston_seat_set_keyboard_focus(struct weston_seat *seat,
2016 struct weston_surface *surface);
2019 weston_compositor_load_xwayland(struct weston_compositor *compositor);
2022 weston_head_init(struct weston_head *head, const char *name);
2025 weston_head_release(struct weston_head *head);
2028 weston_compositor_add_head(struct weston_compositor *compositor,
2029 struct weston_head *head);
2032 weston_head_set_monitor_strings(struct weston_head *head,
2035 const char *serialno);
2038 weston_head_set_physical_size(struct weston_head *head,
2039 int32_t mm_width, int32_t mm_height);
2042 weston_head_set_subpixel(struct weston_head *head,
2043 enum wl_output_subpixel sp);
2046 weston_head_set_connection_status(struct weston_head *head, bool connected);
2049 weston_head_set_internal(struct weston_head *head);
2052 weston_head_is_connected(struct weston_head *head);
2055 weston_head_is_enabled(struct weston_head *head);
2058 weston_head_is_device_changed(struct weston_head *head);
2061 weston_head_reset_device_changed(struct weston_head *head);
2064 weston_head_get_name(struct weston_head *head);
2066 struct weston_output *
2067 weston_head_get_output(struct weston_head *head);
2070 weston_head_detach(struct weston_head *head);
2073 weston_head_add_destroy_listener(struct weston_head *head,
2074 struct wl_listener *listener);
2076 struct wl_listener *
2077 weston_head_get_destroy_listener(struct weston_head *head,
2078 wl_notify_func_t notify);
2080 struct weston_head *
2081 weston_compositor_iterate_heads(struct weston_compositor *compositor,
2082 struct weston_head *iter);
2085 weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor,
2086 struct wl_listener *listener);
2088 struct weston_output *
2089 weston_compositor_find_output_by_name(struct weston_compositor *compositor,
2092 struct weston_output *
2093 weston_compositor_create_output(struct weston_compositor *compositor,
2096 struct weston_output *
2097 weston_compositor_create_output_with_head(struct weston_compositor *compositor,
2098 struct weston_head *head);
2101 weston_output_destroy(struct weston_output *output);
2104 weston_output_attach_head(struct weston_output *output,
2105 struct weston_head *head);
2107 struct weston_head *
2108 weston_output_iterate_heads(struct weston_output *output,
2109 struct weston_head *iter);
2112 weston_output_set_scale(struct weston_output *output,
2116 weston_output_set_transform(struct weston_output *output,
2117 uint32_t transform);
2120 weston_output_init(struct weston_output *output,
2121 struct weston_compositor *compositor,
2125 weston_compositor_add_pending_output(struct weston_output *output,
2126 struct weston_compositor *compositor);
2129 weston_output_enable(struct weston_output *output);
2132 weston_output_disable(struct weston_output *output);
2135 weston_compositor_flush_heads_changed(struct weston_compositor *compositor);
2137 struct weston_head *
2138 weston_head_from_resource(struct wl_resource *resource);
2140 struct weston_head *
2141 weston_output_get_first_head(struct weston_output *output);