Compositor

Compositor c

booo

Defines

WL_HIDE_DEPRECATED
WP_PRESENTATION_FEEDBACK_INVALID
STAMP_SPACE

Typedefs

typedef int (*weston_touch_calibration_save_func)(struct weston_compositor *compositor, struct weston_touch_device *device, const struct weston_touch_device_matrix *calibration)

Callback for saving calibration

Failure will prevent taking the new calibration into use.

Return
-1 on failure, 0 on success.
Parameters
  • compositor: The compositor.
  • device: The physical touch device to save for.
  • calibration: The new calibration from a client.

typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data)
typedef void (*weston_modifier_binding_handler_t)(struct weston_keyboard *keyboard, enum weston_keyboard_modifier modifier, void *data)
typedef void (*weston_button_binding_handler_t)(struct weston_pointer *pointer, const struct timespec *time, uint32_t button, void *data)
typedef void (*weston_touch_binding_handler_t)(struct weston_touch *touch, const struct timespec *time, void *data)
typedef void (*weston_axis_binding_handler_t)(struct weston_pointer *pointer, const struct timespec *time, struct weston_pointer_axis_event *event, void *data)
typedef int (*log_func_t)(const char *fmt, va_list ap)
typedef void (*weston_screenshooter_done_func_t)(void *data, enum weston_screenshooter_outcome outcome)
typedef void (*weston_view_animation_done_func_t)(struct weston_view_animation *animation, void *data)

Enums

enum weston_keyboard_modifier

Values:

MODIFIER_CTRL = (1 << 0)
MODIFIER_ALT = (1 << 1)
MODIFIER_SUPER = (1 << 2)
MODIFIER_SHIFT = (1 << 3)
enum weston_keyboard_locks

Values:

WESTON_NUM_LOCK = (1 << 0)
WESTON_CAPS_LOCK = (1 << 1)
enum weston_led

Values:

LED_NUM_LOCK = (1 << 0)
LED_CAPS_LOCK = (1 << 1)
LED_SCROLL_LOCK = (1 << 2)
enum weston_mode_aspect_ratio

Values:

WESTON_MODE_PIC_AR_NONE = 0

The picture aspect ratio values, for the aspect_ratio field of weston_mode. The values here, are taken from DRM_MODE_PICTURE_ASPECT_* from drm_mode.h.

WESTON_MODE_PIC_AR_4_3 = 1
WESTON_MODE_PIC_AR_16_9 = 2
WESTON_MODE_PIC_AR_64_27 = 3
WESTON_MODE_PIC_AR_256_135 = 4
enum [anonymous]

Values:

WESTON_SPRING_OVERSHOOT
WESTON_SPRING_CLAMP
WESTON_SPRING_BOUNCE
enum dpms_enum

Values:

WESTON_DPMS_ON
WESTON_DPMS_STANDBY
WESTON_DPMS_SUSPEND
WESTON_DPMS_OFF
enum weston_pointer_motion_mask

Values:

WESTON_POINTER_MOTION_ABS = 1 << 0
WESTON_POINTER_MOTION_REL = 1 << 1
WESTON_POINTER_MOTION_REL_UNACCEL = 1 << 2
enum weston_touch_mode

Values:

WESTON_TOUCH_MODE_NORMAL

Normal touch event handling

WESTON_TOUCH_MODE_PREP_CALIB

Prepare moving to WESTON_TOUCH_MODE_CALIB.

   Move to WESTON_TOUCH_MODE_CALIB as soon as no touches are down on
   any seat. Until then, all touch events are routed normally.

WESTON_TOUCH_MODE_CALIB

Calibration mode

   Only a single weston_touch_device forwards events to the calibrator
   all other touch device cause a calibrator "wrong device" event to
   be sent.

WESTON_TOUCH_MODE_PREP_NORMAL

Prepare moving to WESTON_TOUCH_MODE_NORMAL.

   Move to WESTON_TOUCH_MODE_NORMAL as soon as no touches are down on
   any seat. Until then, touch events are routed as in
   WESTON_TOUCH_MODE_CALIB except "wrong device" events are not sent.

enum [anonymous]

Values:

WESTON_COMPOSITOR_ACTIVE
WESTON_COMPOSITOR_IDLE
WESTON_COMPOSITOR_OFFSCREEN
WESTON_COMPOSITOR_SLEEPING
enum weston_layer_position

Higher value means higher in the stack.

These values are based on well-known concepts in a classic desktop environment. Third-party modules based on libweston are encouraged to use them to integrate better with other projects.

A fully integrated environment can use any value, based on these or not, at their discretion.

Values:

WESTON_LAYER_POSITION_HIDDEN = 0x00000000
WESTON_LAYER_POSITION_BACKGROUND = 0x00000002
WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000
WESTON_LAYER_POSITION_NORMAL = 0x50000000
WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000
WESTON_LAYER_POSITION_TOP_UI = 0xe0000000
WESTON_LAYER_POSITION_LOCK = 0xffff0000
WESTON_LAYER_POSITION_CURSOR = 0xfffffffe
WESTON_LAYER_POSITION_FADE = 0xffffffff
enum weston_capability

Values:

WESTON_CAP_ROTATION_ANY = 0x0001
WESTON_CAP_CAPTURE_YFLIP = 0x0002
WESTON_CAP_CURSOR_PLANE = 0x0004
WESTON_CAP_VIEW_CLIP_MASK = 0x0010
WESTON_CAP_EXPLICIT_SYNC = 0x0020
enum weston_key_state_update

Values:

STATE_UPDATE_AUTOMATIC
STATE_UPDATE_NONE
enum weston_activate_flag

Values:

WESTON_ACTIVATE_FLAG_NONE = 0
WESTON_ACTIVATE_FLAG_CONFIGURE = 1 << 0
WESTON_ACTIVATE_FLAG_CLICKED = 1 << 1
enum weston_compositor_backend

Values:

WESTON_BACKEND_DRM
WESTON_BACKEND_FBDEV
WESTON_BACKEND_HEADLESS
WESTON_BACKEND_RDP
WESTON_BACKEND_WAYLAND
WESTON_BACKEND_X11
enum [anonymous]

Values:

TTY_ENTER_VT
TTY_LEAVE_VT
enum weston_screenshooter_outcome

Values:

WESTON_SCREENSHOOTER_SUCCESS
WESTON_SCREENSHOOTER_NO_MEMORY
WESTON_SCREENSHOOTER_BAD_BUFFER

Functions

void weston_pointer_motion_to_abs(struct weston_pointer *pointer, struct weston_pointer_motion_event *event, wl_fixed_t *x, wl_fixed_t *y)
void weston_pointer_send_motion(struct weston_pointer *pointer, const struct timespec *time, struct weston_pointer_motion_event *event)
bool weston_pointer_has_focus_resource(struct weston_pointer *pointer)

Check if the pointer has focused resources.

Return
Whether or not this pointer has focused resources
Parameters
  • pointer: The pointer to check for focused resources.

void weston_pointer_send_button(struct weston_pointer *pointer, const struct timespec *time, uint32_t button, uint32_t state_w)
void weston_pointer_send_axis(struct weston_pointer *pointer, const struct timespec *time, struct weston_pointer_axis_event *event)

Send wl_pointer.axis events to focused resources.

For every resource that is currently in focus, send a wl_pointer.axis event with the passed parameters. The focused resources are the wl_pointer resources of the client which currently has the surface with pointer focus.

Parameters
  • pointer: The pointer where the axis events originates from.
  • time: The timestamp of the event
  • event: The axis value of the event

void weston_pointer_send_axis_source(struct weston_pointer *pointer, uint32_t source)
void weston_pointer_send_frame(struct weston_pointer *pointer)

Send wl_pointer.frame events to focused resources.

For every resource that is currently in focus, send a wl_pointer.frame event. The focused resources are the wl_pointer resources of the client which currently has the surface with pointer focus.

Parameters
  • pointer: The pointer where the frame events originates from.

void weston_pointer_set_focus(struct weston_pointer *pointer, struct weston_view *view, wl_fixed_t sx, wl_fixed_t sy)
void weston_pointer_clear_focus(struct weston_pointer *pointer)

Clear the pointer focus

This can be used to unset pointer focus and set the co-ordinates to the arbitrary values we use for the no focus case.

Parameters
  • pointer: the pointer to clear focus for.

There’s no requirement to use this function. For example, passing the results of a weston_compositor_pick_view() directly to weston_pointer_set_focus() will do the right thing when no view is found.

void weston_pointer_start_grab(struct weston_pointer *pointer, struct weston_pointer_grab *grab)
void weston_pointer_end_grab(struct weston_pointer *pointer)
void weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t *fy)
void weston_pointer_move(struct weston_pointer *pointer, struct weston_pointer_motion_event *event)
void weston_pointer_set_default_grab(struct weston_pointer *pointer, const struct weston_pointer_grab_interface *interface)
void weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint)
void weston_keyboard_set_focus(struct weston_keyboard *keyboard, struct weston_surface *surface)
void weston_keyboard_start_grab(struct weston_keyboard *device, struct weston_keyboard_grab *grab)
void weston_keyboard_end_grab(struct weston_keyboard *keyboard)
int weston_keyboard_set_locks(struct weston_keyboard *keyboard, uint32_t mask, uint32_t value)
bool weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard)

Check if the keyboard has focused resources.

Return
Whether or not this keyboard has focused resources
Parameters
  • keyboard: The keyboard to check for focused resources.

void weston_keyboard_send_key(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state)

Send wl_keyboard.key events to focused resources.

For every resource that is currently in focus, send a wl_keyboard.key event with the passed parameters. The focused resources are the wl_keyboard resources of the client which currently has the surface with keyboard focus.

Parameters
  • keyboard: The keyboard where the key events originates from.
  • time: The timestamp of the event
  • key: The key value of the event
  • state: The state enum value of the event

void weston_keyboard_send_modifiers(struct weston_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)

Send wl_keyboard.modifiers events to focused resources and pointer focused resources.

For every resource that is currently in focus, send a wl_keyboard.modifiers event with the passed parameters. The focused resources are the wl_keyboard resources of the client which currently has the surface with keyboard focus. This also sends wl_keyboard.modifiers events to the wl_keyboard resources of the client having pointer focus (if different from the keyboard focus client).

Parameters
  • keyboard: The keyboard where the modifiers events originates from.
  • serial: The serial of the event
  • mods_depressed: The mods_depressed value of the event
  • mods_latched: The mods_latched value of the event
  • mods_locked: The mods_locked value of the event
  • group: The group value of the event

void weston_touch_set_focus(struct weston_touch *touch, struct weston_view *view)
void weston_touch_start_grab(struct weston_touch *touch, struct weston_touch_grab *grab)
void weston_touch_end_grab(struct weston_touch *touch)
bool weston_touch_has_focus_resource(struct weston_touch *touch)

Check if the touch has focused resources.

Return
Whether or not this touch has focused resources
Parameters
  • touch: The touch to check for focused resources.

void weston_touch_send_down(struct weston_touch *touch, const struct timespec *time, int touch_id, wl_fixed_t x, wl_fixed_t y)

Send wl_touch.down events to focused resources.

For every resource that is currently in focus, send a wl_touch.down event with the passed parameters. The focused resources are the wl_touch resources of the client which currently has the surface with touch focus.

Parameters
  • touch: The touch where the down events originates from.
  • time: The timestamp of the event
  • touch_id: The touch_id value of the event
  • x: The x value of the event
  • y: The y value of the event

void weston_touch_send_up(struct weston_touch *touch, const struct timespec *time, int touch_id)

Send wl_touch.up events to focused resources.

For every resource that is currently in focus, send a wl_touch.up event with the passed parameters. The focused resources are the wl_touch resources of the client which currently has the surface with touch focus.

Parameters
  • touch: The touch where the up events originates from.
  • time: The timestamp of the event
  • touch_id: The touch_id value of the event

void weston_touch_send_motion(struct weston_touch *touch, const struct timespec *time, int touch_id, wl_fixed_t x, wl_fixed_t y)

Send wl_touch.motion events to focused resources.

For every resource that is currently in focus, send a wl_touch.motion event with the passed parameters. The focused resources are the wl_touch resources of the client which currently has the surface with touch focus.

Parameters
  • touch: The touch where the motion events originates from.
  • time: The timestamp of the event
  • touch_id: The touch_id value of the event
  • x: The x value of the event
  • y: The y value of the event

void weston_touch_send_frame(struct weston_touch *touch)

Send wl_touch.frame events to focused resources.

For every resource that is currently in focus, send a wl_touch.frame event. The focused resources are the wl_touch resources of the client which currently has the surface with touch focus.

Parameters
  • touch: The touch where the frame events originates from.

struct weston_touch_device *weston_touch_create_touch_device(struct weston_touch *touch, const char *syspath, void *backend_data, const struct weston_touch_device_ops *ops)

Register a touchscreen input device

Return
New touch device, or NULL on failure.
Parameters
  • touch: The parent weston_touch that identifies the seat.
  • syspath: Unique device name.
  • backend_data: Backend private data if necessary.
  • ops: Calibration operations, or NULL for not able to run calibration.

void weston_touch_device_destroy(struct weston_touch_device *device)

Destroy the touch device.

bool weston_touch_device_can_calibrate(struct weston_touch_device *device)

Is it possible to run calibration on this touch device?

void wl_data_device_set_keyboard_focus(struct weston_seat *seat)
int wl_data_device_manager_init(struct wl_display *display)
void weston_seat_set_selection(struct weston_seat *seat, struct weston_data_source *source, uint32_t serial)
void weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client)

Send the selection to the specified client.

This function creates a new wl_data_offer if there is a wl_data_source currently set as the selection and sends it to the specified client, followed by the wl_data_device.selection() event. If there is no current selection the wl_data_device.selection() event will carry a NULL wl_data_offer.

If the client does not have a wl_data_device for the specified seat nothing will be done.

Parameters
  • seat: The seat owning the wl_data_device used to send the events.
  • client: The client to which to send the selection.

int weston_pointer_start_drag(struct weston_pointer *pointer, struct weston_data_source *source, struct weston_surface *icon, struct wl_client *client)
int weston_touch_start_drag(struct weston_touch *touch, struct weston_data_source *source, struct weston_surface *icon, struct wl_client *client)
void weston_version(int *major, int *minor, int *micro)
void weston_view_set_output(struct weston_view *view, struct weston_output *output)

Set the primary output of the view

Set

output to be the primary output of the view.
Parameters
  • view: The view whose primary output to set
  • output: The new primary output for the view

Notice that the assignment may be temporary; the primary output could be automatically changed. Hence, one cannot rely on the value persisting.

Passing NULL as /a output will set the primary output to NULL.

void weston_view_update_transform(struct weston_view *view)
void weston_view_geometry_dirty(struct weston_view *view)
void weston_view_to_global_fixed(struct weston_view *view, wl_fixed_t sx, wl_fixed_t sy, wl_fixed_t *x, wl_fixed_t *y)
void weston_view_to_global_float(struct weston_view *view, float sx, float sy, float *x, float *y)
void weston_view_from_global_float(struct weston_view *view, float x, float y, float *vx, float *vy)
void weston_view_from_global(struct weston_view *view, int32_t x, int32_t y, int32_t *vx, int32_t *vy)
void weston_view_from_global_fixed(struct weston_view *view, wl_fixed_t x, wl_fixed_t y, wl_fixed_t *vx, wl_fixed_t *vy)
void weston_surface_to_buffer_float(struct weston_surface *surface, float x, float y, float *bx, float *by)
pixman_box32_t weston_surface_to_buffer_rect(struct weston_surface *surface, pixman_box32_t rect)

Transform a rectangle from surface coordinates to buffer coordinates

Viewport and buffer transformations can only do translation, scaling, and rotations in 90-degree steps. Therefore the only loss in the conversion is coordinate rounding.

Return
The transformed rectangle.
Parameters
  • surface: The surface to fetch wp_viewport and buffer transformation from.
  • rect: The rectangle to transform.

However, some coordinate rounding takes place as an intermediate step before the buffer scale factor is applied, so the rectangle boundary may not be exactly as expected.

This is OK for damage tracking since a little extra coverage is not a problem.

void weston_surface_to_buffer_region(struct weston_surface *surface, pixman_region32_t *surface_region, pixman_region32_t *buffer_region)

Transform a region from surface coordinates to buffer coordinates

Buffer_region must be init’d, but will be completely overwritten.

Parameters
  • surface: The surface to fetch wp_viewport and buffer transformation from.
  • surface_region[in]: The region in surface coordinates.
  • buffer_region[out]: The region converted to buffer coordinates.

Viewport and buffer transformations can only do translation, scaling, and rotations in 90-degree steps. Therefore the only loss in the conversion is from the coordinate rounding that takes place in weston_surface_to_buffer_rect.

void weston_spring_init(struct weston_spring *spring, double k, double current, double target)
void weston_spring_update(struct weston_spring *spring, const struct timespec *time)
int weston_spring_done(struct weston_spring *spring)
void weston_view_activate(struct weston_view *view, struct weston_seat *seat, uint32_t flags)
void notify_motion(struct weston_seat *seat, const struct timespec *time, struct weston_pointer_motion_event *event)
void notify_motion_absolute(struct weston_seat *seat, const struct timespec *time, double x, double y)
void notify_button(struct weston_seat *seat, const struct timespec *time, int32_t button, enum wl_pointer_button_state state)
void notify_axis(struct weston_seat *seat, const struct timespec *time, struct weston_pointer_axis_event *event)
void notify_axis_source(struct weston_seat *seat, uint32_t source)
void notify_pointer_frame(struct weston_seat *seat)
void notify_key(struct weston_seat *seat, const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state, enum weston_key_state_update update_state)
void notify_modifiers(struct weston_seat *seat, uint32_t serial)
void notify_pointer_focus(struct weston_seat *seat, struct weston_output *output, double x, double y)
void notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys, enum weston_key_state_update update_state)
void notify_keyboard_focus_out(struct weston_seat *seat)
void notify_touch_normalized(struct weston_touch_device *device, const struct timespec *time, int touch_id, double x, double y, const struct weston_point2d_device_normalized *norm, int touch_type)

Feed in touch down, motion, and up events, calibratable device.

It assumes always the correct cycle sequence until it gets here: touch_down → touch_update → … → touch_update → touch_end. The driver is responsible for sending along such order.

Coordinates double_x and double_y are used for normal operation.

Parameters
  • device: The physical device that generated the event.
  • time: The event timestamp.
  • touch_id: ID for the touch point of this event (multi-touch).
  • double_x: X coordinate in compositor global space.
  • double_y: Y coordinate in compositor global space.
  • norm: Normalized device X, Y coordinates in calibration space, or NULL.
  • touch_type: Either WL_TOUCH_DOWN, WL_TOUCH_UP, or WL_TOUCH_MOTION.

Coordinates norm are only used for touch device calibration. If and only if the weston_touch_device does not support calibrating, norm must be NULL.

The calibration space is the normalized coordinate space [0.0, 1.0]×[0.0, 1.0] of the weston_touch_device. This is assumed to map to the similar normalized coordinate space of the associated weston_output.

static void notify_touch(struct weston_touch_device *device, const struct timespec *time, int touch_id, double x, double y, int touch_type)

Feed in touch down, motion, and up events, non-calibratable device.

See
notify_touch_cal

void notify_touch_frame(struct weston_touch_device *device)
void notify_touch_cancel(struct weston_touch_device *device)
void weston_compositor_set_touch_mode_normal(struct weston_compositor *compositor)

Start transition to normal touch event handling

The touch event mode changes when all touches on all touch devices have been lifted. If no touches are currently down, the transition is immediate.

See
weston_touch_mode

void weston_compositor_set_touch_mode_calib(struct weston_compositor *compositor)

Start transition to calibrator touch event handling

The touch event mode changes when all touches on all touch devices have been lifted. If no touches are currently down, the transition is immediate.

See
weston_touch_mode

void touch_calibrator_mode_changed(struct weston_compositor *compositor)
void notify_touch_calibrator(struct weston_touch_device *device, const struct timespec *time, int32_t slot, const struct weston_point2d_device_normalized *norm, int touch_type)
void notify_touch_calibrator_frame(struct weston_touch_device *device)
void notify_touch_calibrator_cancel(struct weston_touch_device *device)
void weston_layer_entry_insert(struct weston_layer_entry *list, struct weston_layer_entry *entry)
void weston_layer_entry_remove(struct weston_layer_entry *entry)
void weston_layer_init(struct weston_layer *layer, struct weston_compositor *compositor)

Initialize the weston_layer struct.

Parameters
  • compositor: The compositor instance
  • layer: The layer to initialize

void weston_layer_set_position(struct weston_layer *layer, enum weston_layer_position position)

Sets the position of the layer in the layer list. The layer will be placed below any layer with the same position value, if any. This function is safe to call if the layer is already on the list, but the layer may be moved below other layers at the same position, if any.

Parameters
  • layer: The layer to modify
  • position: The position the layer will be placed at

void weston_layer_unset_position(struct weston_layer *layer)

Hide a layer by taking it off the layer list. This function is safe to call if the layer is not on the list.

Parameters
  • layer: The layer to hide

void weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height)
void weston_layer_set_mask_infinite(struct weston_layer *layer)
bool weston_layer_mask_is_infinite(struct weston_layer *layer)
void weston_plane_init(struct weston_plane *plane, struct weston_compositor *ec, int32_t x, int32_t y)
void weston_plane_release(struct weston_plane *plane)
void weston_compositor_stack_plane(struct weston_compositor *ec, struct weston_plane *plane, struct weston_plane *above)
void weston_output_finish_frame(struct weston_output *output, const struct timespec *stamp, uint32_t presented_flags)
void weston_output_schedule_repaint(struct weston_output *output)
void weston_output_damage(struct weston_output *output)
void weston_compositor_schedule_repaint(struct weston_compositor *compositor)
void weston_compositor_fade(struct weston_compositor *compositor, float tint)
void weston_compositor_damage_all(struct weston_compositor *compositor)
void weston_compositor_unlock(struct weston_compositor *compositor)
void weston_compositor_wake(struct weston_compositor *compositor)

Restores the compositor to active status

If the compositor was in a sleeping mode, all outputs are powered back on via DPMS. Otherwise if the compositor was inactive (idle/locked, offscreen, or sleeping) then the compositor’s wake signal will fire.

Parameters
  • compositor: The compositor instance

Restarts the idle timer.

void weston_compositor_offscreen(struct weston_compositor *compositor)

Turns off rendering and frame events for the compositor.

This is used for example to prevent further rendering while the compositor is shutting down.

Parameters
  • compositor: The compositor instance

Stops the idle timer.

void weston_compositor_sleep(struct weston_compositor *compositor)

Powers down all attached output devices

Causes rendering to the outputs to cease, and no frame events to be sent. Only powers down the outputs if the compositor is not already in sleep mode.

Parameters
  • compositor: The compositor instance

Stops the idle timer.

struct weston_view *weston_compositor_pick_view(struct weston_compositor *compositor, wl_fixed_t x, wl_fixed_t y, wl_fixed_t *sx, wl_fixed_t *sy)
struct weston_binding *weston_compositor_add_key_binding(struct weston_compositor *compositor, uint32_t key, enum weston_keyboard_modifier modifier, weston_key_binding_handler_t binding, void *data)
struct weston_binding *weston_compositor_add_modifier_binding(struct weston_compositor *compositor, enum weston_keyboard_modifier modifier, weston_modifier_binding_handler_t binding, void *data)
struct weston_binding *weston_compositor_add_button_binding(struct weston_compositor *compositor, uint32_t button, enum weston_keyboard_modifier modifier, weston_button_binding_handler_t binding, void *data)
struct weston_binding *weston_compositor_add_touch_binding(struct weston_compositor *compositor, enum weston_keyboard_modifier modifier, weston_touch_binding_handler_t binding, void *data)
struct weston_binding *weston_compositor_add_axis_binding(struct weston_compositor *compositor, uint32_t axis, enum weston_keyboard_modifier modifier, weston_axis_binding_handler_t binding, void *data)
struct weston_binding *weston_compositor_add_debug_binding(struct weston_compositor *compositor, uint32_t key, weston_key_binding_handler_t binding, void *data)
void weston_binding_destroy(struct weston_binding *binding)
void weston_install_debug_key_binding(struct weston_compositor *compositor, uint32_t mod)

Install the trigger binding for debug bindings.

This will add a key binding for modifier+SHIFT+SPACE that will trigger debug key bindings.

Parameters
  • compositor: The compositor.
  • mod: The modifier.

void weston_binding_list_destroy_all(struct wl_list *list)
void weston_compositor_run_key_binding(struct weston_compositor *compositor, struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state)
void weston_compositor_run_modifier_binding(struct weston_compositor *compositor, struct weston_keyboard *keyboard, enum weston_keyboard_modifier modifier, enum wl_keyboard_key_state state)
void weston_compositor_run_button_binding(struct weston_compositor *compositor, struct weston_pointer *pointer, const struct timespec *time, uint32_t button, enum wl_pointer_button_state value)
void weston_compositor_run_touch_binding(struct weston_compositor *compositor, struct weston_touch *touch, const struct timespec *time, int touch_type)
int weston_compositor_run_axis_binding(struct weston_compositor *compositor, struct weston_pointer *pointer, const struct timespec *time, struct weston_pointer_axis_event *event)
int weston_compositor_run_debug_binding(struct weston_compositor *compositor, struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, enum wl_keyboard_key_state state)
void weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor, const struct weston_pointer_grab_interface *interface)
int weston_environment_get_fd(const char *env)
struct weston_surface *weston_surface_create(struct weston_compositor *compositor)
struct weston_view *weston_view_create(struct weston_surface *surface)
void weston_view_destroy(struct weston_view *view)
void weston_view_set_position(struct weston_view *view, float x, float y)
void weston_view_set_transform_parent(struct weston_view *view, struct weston_view *parent)
void weston_view_set_mask(struct weston_view *view, int x, int y, int width, int height)

Set a clip mask rectangle on a view

A shell may set a clip mask rectangle on a view. Everything outside the rectangle is cut away for input and output purposes: it is not drawn and cannot be hit by hit-test based input like pointer motion or touch-downs. Everything inside the rectangle will behave normally. Clients are unaware of clipping.

Parameters
  • view: The view to set the clip mask on.
  • x: Top-left corner X coordinate of the clip rectangle.
  • y: Top-left corner Y coordinate of the clip rectangle.
  • width: Width of the clip rectangle, non-negative.
  • height: Height of the clip rectangle, non-negative.

The rectangle is set in surface-local coordinates. Setting a clip mask rectangle does not affect the view position, the view is positioned as it would be without a clip. The clip also does not change weston_surface::width,height.

The clip mask rectangle is part of transformation inheritance (weston_view_set_transform_parent()). A clip set in the root of the transformation inheritance tree will affect all views in the tree. A clip can be set only on the root view. Attempting to set a clip on view that has a transformation parent will fail. Assigning a parent to a view that has a clip set will cause the clip to be forgotten.

Because the clip mask is an axis-aligned rectangle, it poses restrictions on the additional transformations in the child views. These transformations may not rotate the coordinate axes, i.e., only translation and scaling are allowed. Violating this restriction causes the clipping to malfunction. Furthermore, using scaling may cause rounding errors in child clipping.

The clip mask rectangle is not automatically adjusted based on wl_surface.attach dx and dy arguments.

A clip mask rectangle can be set only if the compositor capability WESTON_CAP_VIEW_CLIP_MASK is present.

This function sets the clip mask rectangle and schedules a repaint for the view.

void weston_view_set_mask_infinite(struct weston_view *view)

Remove the clip mask from a view

Removed the clip mask rectangle and schedules a repaint.

Parameters
  • view: The view to remove the clip mask from.

See
weston_view_set_mask

bool weston_view_is_mapped(struct weston_view *view)
bool weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region)
void weston_view_schedule_repaint(struct weston_view *view)

Marks the output(s) that the view is shown on as needing to be repainted. See weston_output_schedule_repaint().

Parameters
  • view: The view to be repainted

bool weston_surface_is_mapped(struct weston_surface *surface)
void weston_surface_set_size(struct weston_surface *surface, int32_t width, int32_t height)
void weston_surface_schedule_repaint(struct weston_surface *surface)

Marks the output(s) that the surface is shown on as needing to be repainted. See weston_output_schedule_repaint().

Parameters
  • surface: The surface to be repainted

void weston_surface_damage(struct weston_surface *surface)

XXX: This function does it the wrong way. surface->damage is the damage from the client, and causes surface_flush_damage() to copy pixels. No window management action can cause damage to the client-provided content, warranting re-upload!

Instead of surface->damage, this function should record the damage with all the views for this surface to avoid extraneous texture uploads.

void weston_view_damage_below(struct weston_view *view)

Inflict damage on the plane where the view is visible.

If the view is currently on a plane (including the primary plane), take the view’s boundingbox, subtract all the opaque views that cover it, and add the remaining region as damage to the plane. This corresponds to the damage inflicted to the plane if this view disappeared.

Parameters
  • view: The view that causes the damage.

A repaint is scheduled for this view.

The region of all opaque views covering this view is stored in weston_view::clip and updated by view_accumulate_damage() during weston_output_repaint(). Specifically, that region matches the scenegraph as it was last painted.

void weston_view_move_to_plane(struct weston_view *view, struct weston_plane *plane)
void weston_view_unmap(struct weston_view *view)
void weston_surface_unmap(struct weston_surface *surface)
struct weston_surface *weston_surface_get_main_surface(struct weston_surface *surface)
int weston_surface_set_role(struct weston_surface *surface, const char *role_name, struct wl_resource *error_resource, uint32_t error_code)
const char *weston_surface_get_role(struct weston_surface *surface)
void weston_surface_set_label_func(struct weston_surface *surface, int (*desc)(struct weston_surface *, char *, size_t))
void weston_surface_get_content_size(struct weston_surface *surface, int *width, int *height)

Get the size of surface contents

Retrieves the raw surface content size in pixels for the given surface. This is the whole content size in buffer pixels. If the surface has no content or the renderer does not implement this feature, zeroes are returned.

Parameters
  • surface: The surface to query.
  • width: Returns the width of raw contents.
  • height: Returns the height of raw contents.

This function is used to determine the buffer size needed for a weston_surface_copy_content() call.

struct weston_geometry weston_surface_get_bounding_box(struct weston_surface *surface)

Get the bounding box of a surface and its subsurfaces

Return
The bounding box relative to the surface origin.
Parameters
  • surface: The surface to query.

int weston_surface_copy_content(struct weston_surface *surface, void *target, size_t size, int src_x, int src_y, int width, int height)

Copy surface contents to system memory.

Surface contents are maintained by the renderer. They can be in a reserved

weston_buffer or as a copy, e.g. a GL texture, or something else.
Return
0 for success, -1 for failure.
Parameters
  • surface: The surface to copy from.
  • target: Pointer to the target memory buffer.
  • size: Size of the target buffer in bytes.
  • src_x: X location on contents to copy from.
  • src_y: Y location on contents to copy from.
  • width: Width in pixels of the area to copy.
  • height: Height in pixels of the area to copy.

Surface contents are copied into memory pointed to by target, which has size bytes of space available. The target memory may be larger than needed, but being smaller returns an error. The extra bytes in target may or may not be written; their content is unspecified. Size must be large enough to hold the image.

The image in the target memory will be arranged in rows from top to bottom, and pixels on a row from left to right. The pixel format is PIXMAN_a8b8g8r8, 4 bytes per pixel, and stride is exactly width * 4.

Parameters src_x and src_y define the upper-left corner in buffer coordinates (pixels) to copy from. Parameters width and height define the size of the area to copy in pixels.

The rectangle defined by src_x, src_y, width, height must fit in the surface contents. Otherwise an error is returned.

Use weston_surface_get_content_size to determine the content size; the needed target buffer size and rectangle limits.

CURRENT IMPLEMENTATION RESTRICTIONS:

  • the machine must be little-endian due to Pixman formats.

NOTE: Pixman formats are premultiplied.

struct weston_buffer *weston_buffer_from_resource(struct wl_resource *resource)
void weston_buffer_reference(struct weston_buffer_reference *ref, struct weston_buffer *buffer)
void weston_buffer_release_reference(struct weston_buffer_release_reference *ref, struct weston_buffer_release *buf_release)
void weston_buffer_release_move(struct weston_buffer_release_reference *dest, struct weston_buffer_release_reference *src)
void weston_compositor_get_time(struct timespec *time)
char *weston_compositor_print_scene_graph(struct weston_compositor *ec)

Output information on how libweston is currently composing the scene graph.

void weston_compositor_destroy(struct weston_compositor *ec)

Destroys the compositor.

This function cleans up the compositor state and destroys it.

Parameters
  • compositor: The compositor to be destroyed.

struct weston_compositor *weston_compositor_create(struct wl_display *display, void *user_data)

Create the compositor.

This functions creates and initializes a compositor instance.

Return
The compositor instance on success or NULL on failure.
Parameters
  • display: The Wayland display to be used.
  • user_data: A pointer to an object that can later be retrieved using the weston_compositor_get_user_data function.

int weston_compositor_load_backend(struct weston_compositor *compositor, enum weston_compositor_backend backend, struct weston_backend_config *config_base)

Load a backend into a weston_compositor

A backend must be loaded to make a weston_compositor work. A backend provides input and output capabilities, and determines the renderer to use.

Return
0 on success, or -1 on error.
Parameters
  • compositor: A compositor that has not had a backend loaded yet.
  • backend: Name of the backend file.
  • config_base: A pointer to a backend-specific configuration structure’s ‘base’ member.

void weston_compositor_exit(struct weston_compositor *ec)

Instruct the compositor to exit.

This functions does not directly destroy the compositor object, it merely command it to start the tear down process. It is not guaranteed that the tear down will happen immediately.

Parameters
  • compositor: The compositor to tear down.

void *weston_compositor_get_user_data(struct weston_compositor *compositor)

Return the user data stored in the compositor.

This function returns the user data pointer set with user_data parameter to the weston_compositor_create function.

int weston_compositor_set_presentation_clock(struct weston_compositor *compositor, clockid_t clk_id)
int weston_compositor_set_presentation_clock_software(struct weston_compositor *compositor)
void weston_compositor_read_presentation_clock(const struct weston_compositor *compositor, struct timespec *ts)

Read the current time from the Presentation clock

This function is never meant to fail. If reading the clock does fail, an error message is logged and a zero time is returned. Callers are not supposed to detect or react to failures.

Note
Reading the current time in user space is always imprecise to some degree.
Parameters
  • compositor:
  • ts[out]: The current time.

bool weston_compositor_import_dmabuf(struct weston_compositor *compositor, struct linux_dmabuf_buffer *buffer)

Import dmabuf buffer into current renderer

This function tests that the

linux_dmabuf_buffer is usable for the current renderer. Returns false on unusable buffers. Usually usability is tested by importing the dmabufs for composition.
Return
true on usable buffers, false otherwise
Parameters
  • compositor:
  • buffer: the dmabuf buffer to import

This hook is also used for detecting if the renderer supports dmabufs at all. If the renderer hook is NULL, dmabufs are not supported.

void weston_compositor_shutdown(struct weston_compositor *ec)
void weston_compositor_exit_with_code(struct weston_compositor *compositor, int exit_code)
void weston_output_init_zoom(struct weston_output *output)
void weston_output_update_zoom(struct weston_output *output)
void weston_output_activate_zoom(struct weston_output *output, struct weston_seat *seat)
void weston_output_move(struct weston_output *output, int x, int y)
void weston_output_add_destroy_listener(struct weston_output *output, struct wl_listener *listener)

Add destroy callback for an output

The listener callback will be called when user destroys an output. This may be delayed by a backend in some cases. The main purpose of the listener is to allow hooking up custom data to the output. The custom data can be fetched via weston_output_get_destroy_listener() followed by container_of().

Parameters
  • output: The output to watch.
  • listener: The listener to add. The notify member must be set.

The data argument to the notify callback is the weston_output being destroyed.

Note
This is for the final destruction of an output, not when it gets disabled. If you want to keep track of enabled outputs, this is not it.

struct wl_listener *weston_output_get_destroy_listener(struct weston_output *output, wl_notify_func_t notify)

Look up destroy listener for an output

This looks up the previously added destroy listener struct based on the notify function it has. The listener can be used to access user data through

container_of().
Return
The listener, or NULL if not found.
Parameters
  • output: The output to query.
  • notify: The notify function used used for the added destroy listener.

See
wl_signal_get() weston_output_add_destroy_listener()

void weston_output_release(struct weston_output *output)
void weston_output_transform_coordinate(struct weston_output *output, double device_x, double device_y, double *x, double *y)
void weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec, const char *seat_name)
void weston_seat_init_pointer(struct weston_seat *seat)
void weston_seat_release_pointer(struct weston_seat *seat)
int weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap)
void weston_seat_release_keyboard(struct weston_seat *seat)
void weston_seat_init_touch(struct weston_seat *seat)
void weston_seat_release_touch(struct weston_seat *seat)
void weston_seat_repick(struct weston_seat *seat)
void weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap)
void weston_seat_release(struct weston_seat *seat)
int weston_compositor_set_xkb_rule_names(struct weston_compositor *ec, struct xkb_rule_names *names)
void weston_compositor_xkb_destroy(struct weston_compositor *ec)
void weston_log_set_handler(log_func_t log, log_func_t cont)

Install the log handler

The given functions will be called to output text as passed to the weston_log and weston_log_continue functions.

Parameters
  • log: The log function. This function will be called when weston_log is called, and should begin a new line, with user defined line headers, if any.
  • cont: The continue log function. This function will be called when weston_log_continue is called, and should append its output to the current line, without any header or other content in between.

int weston_vlog(const char *fmt, va_list ap)
int weston_vlog_continue(const char *fmt, va_list ap)
int weston_log(const char *fmt, ...)
int int weston_log_continue(const char * fmt, ...)
struct tty *tty_create(struct weston_compositor *compositor, int tty_nr)
void tty_destroy(struct tty *tty)
void tty_reset(struct tty *tty)
int tty_activate_vt(struct tty *tty, int vt)
int weston_screenshooter_shoot(struct weston_output *output, struct weston_buffer *buffer, weston_screenshooter_done_func_t done, void *data)
struct weston_recorder *weston_recorder_start(struct weston_output *output, const char *filename)
void weston_recorder_stop(struct weston_recorder *recorder)
struct clipboard *clipboard_create(struct weston_seat *seat)
void weston_view_animation_destroy(struct weston_view_animation *animation)
struct weston_view_animation *weston_zoom_run(struct weston_view *view, float start, float stop, weston_view_animation_done_func_t done, void *data)
struct weston_view_animation *weston_fade_run(struct weston_view *view, float start, float end, float k, weston_view_animation_done_func_t done, void *data)
struct weston_view_animation *weston_move_scale_run(struct weston_view *view, int dx, int dy, float start, float end, bool reverse, weston_view_animation_done_func_t done, void *data)
struct weston_view_animation *weston_move_run(struct weston_view *view, int dx, int dy, float start, float end, bool reverse, weston_view_animation_done_func_t done, void *data)
void weston_fade_update(struct weston_view_animation *fade, float target)
struct weston_view_animation *weston_stable_fade_run(struct weston_view *front_view, float start, struct weston_view *back_view, float end, weston_view_animation_done_func_t done, void *data)
struct weston_view_animation *weston_slide_run(struct weston_view *view, float start, float stop, weston_view_animation_done_func_t done, void *data)
void weston_surface_set_color(struct weston_surface *surface, float red, float green, float blue, float alpha)
void weston_surface_destroy(struct weston_surface *surface)
int weston_output_mode_set_native(struct weston_output *output, struct weston_mode *mode, int32_t scale)
int weston_output_mode_switch_to_temporary(struct weston_output *output, struct weston_mode *mode, int32_t scale)
int weston_output_mode_switch_to_native(struct weston_output *output)
int noop_renderer_init(struct weston_compositor *ec)
int weston_input_init(struct weston_compositor *compositor)
int weston_backend_init(struct weston_compositor *c, struct weston_backend_config *config_base)
int weston_module_init(struct weston_compositor *compositor)
void weston_transformed_coord(int width, int height, enum wl_output_transform transform, int32_t scale, float sx, float sy, float *bx, float *by)
pixman_box32_t weston_transformed_rect(int width, int height, enum wl_output_transform transform, int32_t scale, pixman_box32_t rect)
void weston_matrix_transform_region(pixman_region32_t *dest, struct weston_matrix *matrix, pixman_region32_t *src)

Transform a region by a matrix, restricted to axis-aligned transformations

Warning: This function does not work for projective, affine, or matrices that encode arbitrary rotations. Only 90-degree step rotations are supported.

void weston_transformed_region(int width, int height, enum wl_output_transform transform, int32_t scale, pixman_region32_t *src, pixman_region32_t *dest)
void *weston_load_module(const char *name, const char *entrypoint)
size_t weston_module_path_from_env(const char *name, char *path, size_t path_len)

Attempts to find a module path from the module map specified in the environment. If found, writes the full path into the path variable.

The module map is a string in environment variable WESTON_MODULE_MAP, where each entry is of the form “name=path” and entries are separated by semicolons. Whitespace is significant.

Return
The length of the string written to path on success, or 0 if the module was not specified in the environment map or path_len was too small.
Parameters
  • name: The name to search for.
  • path: Where the path is written to if found.
  • path_len: Allocated bytes at path .

int weston_parse_transform(const char *transform, uint32_t *out)
const char *weston_transform_to_string(uint32_t output_transform)
struct weston_keyboard *weston_seat_get_keyboard(struct weston_seat *seat)

Get a seat’s keyboard pointer

The keyboard pointer for a seat isn’t freed when all keyboards are removed, so it should only be used when the seat’s keyboard_device_count is greater than zero. This function does that test and only returns a pointer when a keyboard is present.

Return
The seat’s keyboard pointer, or NULL if no keyboard is present
Parameters
  • seat: The seat to query

struct weston_pointer *weston_seat_get_pointer(struct weston_seat *seat)

Get a seat’s pointer pointer

The pointer pointer for a seat isn’t freed when all mice are removed, so it should only be used when the seat’s pointer_device_count is greater than zero. This function does that test and only returns a pointer when a pointing device is present.

Return
The seat’s pointer pointer, or NULL if no pointer device is present
Parameters
  • seat: The seat to query

struct weston_touch *weston_seat_get_touch(struct weston_seat *seat)

Get a seat’s touch pointer

The touch pointer for a seat isn’t freed when all touch devices are removed, so it should only be used when the seat’s touch_device_count is greater than zero. This function does that test and only returns a pointer when a touch device is present.

Return
The seat’s touch pointer, or NULL if no touch device is present
Parameters
  • seat: The seat to query

void weston_seat_set_keyboard_focus(struct weston_seat *seat, struct weston_surface *surface)

Sets the keyboard focus to the given surface

Parameters
  • seat: The seat to query

void weston_keyboard_send_keymap(struct weston_keyboard *kbd, struct wl_resource *resource)
int weston_compositor_load_xwayland(struct weston_compositor *compositor)
void weston_head_init(struct weston_head *head, const char *name)
void weston_head_release(struct weston_head *head)
void weston_compositor_add_head(struct weston_compositor *compositor, struct weston_head *head)
void weston_head_set_monitor_strings(struct weston_head *head, const char *make, const char *model, const char *serialno)
void weston_head_set_non_desktop(struct weston_head *head, bool non_desktop)
void weston_head_set_physical_size(struct weston_head *head, int32_t mm_width, int32_t mm_height)
void weston_head_set_subpixel(struct weston_head *head, enum wl_output_subpixel sp)
void weston_head_set_connection_status(struct weston_head *head, bool connected)
void weston_head_set_internal(struct weston_head *head)
bool weston_head_is_connected(struct weston_head *head)
bool weston_head_is_enabled(struct weston_head *head)
bool weston_head_is_device_changed(struct weston_head *head)
bool weston_head_is_non_desktop(struct weston_head *head)
void weston_head_reset_device_changed(struct weston_head *head)
const char *weston_head_get_name(struct weston_head *head)

Get the name of a head

The name depends on the backend. The DRM backend uses connector names, other backends may use hardcoded names or user-given names.

Return
The head’s name, not NULL.
Parameters
  • head: The head to query.

struct weston_output *weston_head_get_output(struct weston_head *head)

Get the output the head is attached to

Return
The output the head is attached to, or NULL if detached.
Parameters
  • head: The head to query.

void weston_head_detach(struct weston_head *head)
void weston_head_add_destroy_listener(struct weston_head *head, struct wl_listener *listener)

Add destroy callback for a head

Heads may get destroyed for various reasons by the backends. If a head is attached to an output, the compositor should listen for head destruction and reconfigure or destroy the output if necessary.

Parameters
  • head: The head to watch for.
  • listener: The listener to add. The notify member must be set.

The destroy callbacks will be called on weston_head destruction before any automatic detaching from an associated weston_output and before any weston_head information is lost.

The data argument to the notify callback is the weston_head being destroyed.

struct wl_listener *weston_head_get_destroy_listener(struct weston_head *head, wl_notify_func_t notify)

Look up destroy listener for a head

This looks up the previously added destroy listener struct based on the notify function it has. The listener can be used to access user data through

container_of().
Return
The listener, or NULL if not found.
Parameters
  • head: The head to query.
  • notify: The notify function used used for the added destroy listener.

See
wl_signal_get()

struct weston_head *weston_compositor_iterate_heads(struct weston_compositor *compositor, struct weston_head *iter)
void weston_compositor_add_heads_changed_listener(struct weston_compositor *compositor, struct wl_listener *listener)
struct weston_output *weston_compositor_find_output_by_name(struct weston_compositor *compositor, const char *name)
struct weston_output *weston_compositor_create_output(struct weston_compositor *compositor, const char *name)
struct weston_output *weston_compositor_create_output_with_head(struct weston_compositor *compositor, struct weston_head *head)
void weston_output_destroy(struct weston_output *output)
int weston_output_attach_head(struct weston_output *output, struct weston_head *head)
struct weston_head *weston_output_iterate_heads(struct weston_output *output, struct weston_head *iter)
void weston_output_set_scale(struct weston_output *output, int32_t scale)
void weston_output_set_transform(struct weston_output *output, uint32_t transform)
void weston_output_init(struct weston_output *output, struct weston_compositor *compositor, const char *name)
void weston_compositor_add_pending_output(struct weston_output *output, struct weston_compositor *compositor)
int weston_output_enable(struct weston_output *output)

Constructs a weston_output object that can be used by the compositor.

Output coordinates are calculated and each new output is by default assigned to the right of previous one.

Parameters
  • output: The weston_output object that needs to be enabled. Must not be enabled already. Must have at least one head attached.

Sets up the transformation, zoom, and geometry of the output using the properties that need to be configured by the compositor.

Establishes a repaint timer for the output with the relevant display object’s event loop. See output_repaint_timer_handler().

The output is assigned an ID. Weston can support up to 32 distinct outputs, with IDs numbered from 0-31; the compositor’s output_id_pool is referred to and used to find the first available ID number, and then this ID is marked as used in output_id_pool.

The output is also assigned a Wayland global with the wl_output external interface.

Backend specific function is called to set up the output output.

Output is added to the compositor’s output list

If the backend specific function fails, the weston_output object is returned to a state it was before calling this function and is added to the compositor’s pending_output_list in case it needs to be reconfigured or just so it can be destroyed at shutdown.

0 is returned on success, -1 on failure.

void weston_output_disable(struct weston_output *output)

Converts a weston_output object to a pending output state, so it can be configured again or destroyed.

Calls a backend specific function to disable an output, in case such function exists.

Parameters

The backend specific disable function may choose to postpone the disabling by returning a negative value, in which case this function returns early. In that case the backend will guarantee the output will be disabled soon by the backend calling this function again. One must not attempt to re-enable the output until that happens.

Otherwise, if the output is being used by the compositor, it is removed from weston’s output_list (see weston_compositor_remove_output()) and is returned to a state it was before weston_output_enable() was ran (see weston_output_enable_undo()).

See weston_output_init() for more information on the state output is returned to.

If the output has never been enabled yet, this function can still be called to ensure that the output is actually turned off rather than left in the state it was discovered in.

void weston_compositor_flush_heads_changed(struct weston_compositor *compositor)

Forces a synchronous call to heads_changed hook

If there are new or changed heads, calls the heads_changed hook and returns after the hook returns.

Parameters
  • compositor: The compositor instance

struct weston_head *weston_head_from_resource(struct wl_resource *resource)

Get the backing object of wl_output

Return
The backing object (user data) of a wl_resource representing a wl_output protocol object.
Parameters
  • resource: A wl_output protocol object.

struct weston_head *weston_output_get_first_head(struct weston_output *output)

When you need a head…

This function is a hack, used until all code has been converted to become multi-head aware.

Return
The first head in the output’s list.
Parameters

int weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor, weston_touch_calibration_save_func save)

Advertise touch_calibration support

Calling this initializes the weston_touch_calibration protocol support, so that the interface will be advertised to clients. It is recommended to use some mechanism, e.g. wl_display_set_global_filter(), to restrict access to the interface.

Return
Zero on success, -1 on failure or if already enabled.
Parameters
  • compositor: The compositor to init for.
  • save: The callback function for saving a new calibration, or NULL.

There is no way to disable this once enabled.

If the save callback is NULL, a new calibration provided by a client will always be accepted. If the save callback is not NULL, it must return success for the new calibration to be accepted.

int weston_debug_compositor_create(struct weston_compositor *compositor)

Initialize weston-debug structure

weston_debug_compositor is a singleton for each weston_compositor.

Return
0 on success, -1 on failure.
Parameters
  • compositor: The libweston compositor.

Sets weston_compositor::weston_debug.

void weston_debug_compositor_destroy(struct weston_compositor *compositor)

Destroy weston_debug_compositor structure

Clears weston_compositor::weston_debug.

Parameters
  • compositor: The libweston compositor whose weston-debug to tear down.

void weston_buffer_send_server_error(struct weston_buffer *buffer, const char *msg)

Resolve an internal compositor error by disconnecting the client.

This function is used in cases when the wl_buffer turns out unusable and there is no fallback path.

It is possible the fault is caused by a compositor bug, the underlying graphics stack bug or normal behaviour, or perhaps a client mistake. In any case, the options are to either composite garbage or nothing, or disconnect the client. This is a helper function for the latter.

The error is sent as an INVALID_OBJECT error on the client’s wl_display.

Parameters
  • buffer: The weston buffer that is unusable.
  • msg: A custom error message attached to the protocol error.

struct weston_geometry

Public Members

int32_t x
int32_t y
int32_t width
int32_t height
struct weston_position

Public Members

int32_t x
int32_t y
struct weston_size

Public Members

int32_t width
int32_t height
struct weston_transform

Public Members

struct weston_matrix matrix
struct wl_list link
struct weston_point2d_device_normalized
#include <compositor.h>

2D device coordinates normalized to [0, 1] range

Public Members

double x
double y
struct weston_mode

Public Members

uint32_t flags
weston_mode_aspect_ratio aspect_ratio
int32_t width
int32_t height
uint32_t refresh
struct wl_list link
struct weston_animation

Public Members

void (*frame)(struct weston_animation *animation, struct weston_output *output, const struct timespec *time)
int frame_counter
struct wl_list link
struct weston_spring

Public Members

double k
double friction
double current
double target
double previous
double min
double max
struct timespec timestamp
uint32_t clip
struct weston_output_zoom

Public Members

bool active
float increment
float level
float max_level
float trans_x
float trans_y
double x
double y
struct weston_output_zoom::[anonymous] current
struct weston_seat *seat
struct weston_animation animation_z
struct weston_spring spring_z
struct wl_listener motion_listener
struct weston_head
#include <compositor.h>

Represents a monitor

This object represents a monitor (hardware backends like DRM) or a window (windowed nested backends).

Public Members

struct weston_compositor *compositor

owning compositor

struct wl_list compositor_link

in weston_compositor::head_list

struct wl_signal destroy_signal

destroy callbacks

struct weston_output *output

the output driving this head

struct wl_list output_link

in weston_output::head_list

struct wl_list resource_list

wl_output protocol objects

struct wl_global *global

wl_output global

int32_t mm_width

physical image width in mm

int32_t mm_height

physical image height in mm

char *make

monitor manufacturer (PNP ID)

char *model

monitor model

char *serial_number

monitor serial

uint32_t subpixel

enum wl_output_subpixel

bool connection_internal

embedded monitor (e.g. laptop)

bool device_changed

monitor information has changed

char *name

head name, e.g. connector name

bool connected

is physically connected

bool non_desktop

non-desktop display, e.g. HMD

struct weston_output

Public Types

enum [anonymous]

State of the repaint loop

Values:

REPAINT_NOT_SCHEDULED = 0

idle; no repaint will occur

REPAINT_BEGIN_FROM_IDLE

start_repaint_loop scheduled

REPAINT_SCHEDULED

repaint is scheduled to occur

REPAINT_AWAITING_COMPLETION

last repaint not yet finished

Public Members

uint32_t id
char *name
struct wl_signal user_destroy_signal

Matches the lifetime from the user perspective

void *renderer_state
struct wl_list link
struct weston_compositor *compositor
struct weston_matrix matrix

From global to output buffer coordinates.

struct weston_matrix inverse_matrix

From output buffer to global coordinates.

struct wl_list animation_list
int32_t x
int32_t y
int32_t width
int32_t height
pixman_region32_t region

Output area in global coordinates, simple rect

pixman_region32_t previous_damage
bool repaint_needed

True if damage has occurred since the last repaint for this output; if set, a repaint will eventually occur.

bool repainted

Used only between repaint_begin and repaint_cancel.

weston_output::[anonymous] repaint_status

State of the repaint loop

struct timespec next_repaint

If repaint_status is REPAINT_SCHEDULED, contains the time the next repaint should be run

struct wl_event_source *idle_repaint_source

For cancelling the idle_repaint callback on output destruction.

struct weston_output_zoom zoom
int dirty
struct wl_signal frame_signal
struct wl_signal destroy_signal

sent when disabled

int move_x
int move_y
struct timespec frame_time
uint64_t msc
int disable_planes
int destroying
struct wl_list feedback_list
uint32_t transform
int32_t native_scale
int32_t current_scale
int32_t original_scale
struct weston_mode *native_mode
struct weston_mode *current_mode
struct weston_mode *original_mode
struct wl_list mode_list
struct wl_list head_list

List of driven weston_heads

void (*start_repaint_loop)(struct weston_output *output)
int (*repaint)(struct weston_output *output, pixman_region32_t *damage, void *repaint_data)
void (*destroy)(struct weston_output *output)
void (*assign_planes)(struct weston_output *output, void *repaint_data)
int (*switch_mode)(struct weston_output *output, struct weston_mode *mode)
int32_t backlight_current
void (*set_backlight)(struct weston_output *output, uint32_t value)
void (*set_dpms)(struct weston_output *output, enum dpms_enum level)
uint16_t gamma_size
void (*set_gamma)(struct weston_output *output, uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b)
struct weston_timeline_object timeline
bool enabled

is in the output_list, not pending list

int scale
int (*enable)(struct weston_output *output)
int (*disable)(struct weston_output *output)
int (*attach_head)(struct weston_output *output, struct weston_head *head)

Attach a head in the backend

Do anything necessary to account for a new head being attached to the output, and check any conditions possible. On failure, both the head and the output must be left as before the call.

Return
0 on success, -1 on failure.
Parameters
  • output: The output to attach to.
  • head: The head to attach.

Libweston core will add the head to the head_list after a successful call.

void (*detach_head)(struct weston_output *output, struct weston_head *head)

Detach a head in the backend

Do any clean-up necessary to detach this head from the output. The head has already been removed from the output’s head_list.

Parameters
  • output: The output to detach from.
  • head: The head to detach.

struct weston_pointer_motion_event

Public Members

uint32_t mask
struct timespec time
double x
double y
double dx
double dy
double dx_unaccel
double dy_unaccel
struct weston_pointer_axis_event

Public Members

uint32_t axis
double value
bool has_discrete
int32_t discrete
struct weston_pointer_grab_interface

Public Members

void (*focus)(struct weston_pointer_grab *grab)
void (*motion)(struct weston_pointer_grab *grab, const struct timespec *time, struct weston_pointer_motion_event *event)
void (*button)(struct weston_pointer_grab *grab, const struct timespec *time, uint32_t button, uint32_t state)
void (*axis)(struct weston_pointer_grab *grab, const struct timespec *time, struct weston_pointer_axis_event *event)
void (*axis_source)(struct weston_pointer_grab *grab, uint32_t source)
void (*frame)(struct weston_pointer_grab *grab)
void (*cancel)(struct weston_pointer_grab *grab)
struct weston_pointer_grab

Public Members

const struct weston_pointer_grab_interface *interface
struct weston_pointer *pointer
struct weston_keyboard_grab_interface

Public Members

void (*key)(struct weston_keyboard_grab *grab, const struct timespec *time, uint32_t key, uint32_t state)
void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
void (*cancel)(struct weston_keyboard_grab *grab)
struct weston_keyboard_grab

Public Members

const struct weston_keyboard_grab_interface *interface
struct weston_keyboard *keyboard
struct weston_touch_grab_interface

Public Members

void (*down)(struct weston_touch_grab *grab, const struct timespec *time, int touch_id, wl_fixed_t sx, wl_fixed_t sy)
void (*up)(struct weston_touch_grab *grab, const struct timespec *time, int touch_id)
void (*motion)(struct weston_touch_grab *grab, const struct timespec *time, int touch_id, wl_fixed_t sx, wl_fixed_t sy)
void (*frame)(struct weston_touch_grab *grab)
void (*cancel)(struct weston_touch_grab *grab)
struct weston_touch_grab

Public Members

const struct weston_touch_grab_interface *interface
struct weston_touch *touch
struct weston_data_offer

Public Members

struct wl_resource *resource
struct weston_data_source *source
struct wl_listener source_destroy_listener
uint32_t dnd_actions
wl_data_device_manager_dnd_action preferred_dnd_action
bool in_ask
struct weston_data_source

Public Members

struct wl_resource *resource
struct wl_signal destroy_signal
struct wl_array mime_types
struct weston_data_offer *offer
struct weston_seat *seat
bool accepted
bool actions_set
uint32_t dnd_actions
wl_data_device_manager_dnd_action current_dnd_action
wl_data_device_manager_dnd_action compositor_action
void (*accept)(struct weston_data_source *source, uint32_t serial, const char *mime_type)
void (*send)(struct weston_data_source *source, const char *mime_type, int32_t fd)
void (*cancel)(struct weston_data_source *source)
struct weston_pointer_client

Public Members

struct wl_list link
struct wl_client *client
struct wl_list pointer_resources
struct wl_list relative_pointer_resources
struct weston_pointer

Public Members

struct weston_seat *seat

the seat

struct wl_list pointer_clients
struct weston_view *focus
struct weston_pointer_client *focus_client
uint32_t focus_serial
struct wl_listener focus_view_listener
struct wl_listener focus_resource_listener
struct wl_signal focus_signal
struct wl_signal motion_signal
struct wl_signal destroy_signal
struct weston_view *sprite
struct wl_listener sprite_destroy_listener
int32_t hotspot_x
int32_t hotspot_y
struct weston_pointer_grab *grab
struct weston_pointer_grab default_grab
wl_fixed_t grab_x
wl_fixed_t grab_y
uint32_t grab_button
uint32_t grab_serial
struct timespec grab_time
wl_fixed_t x
wl_fixed_t y
wl_fixed_t sx
wl_fixed_t sy
uint32_t button_count
struct wl_listener output_destroy_listener
struct wl_list timestamps_list
struct weston_touch_device_matrix
#include <compositor.h>

libinput style calibration matrix

See https://wayland.freedesktop.org/libinput/doc/latest/absolute_axes.html and libinput_device_config_calibration_set_matrix().

Public Members

float m[6]
struct weston_touch_device_ops
#include <compositor.h>

Operations for a calibratable touchscreen

Public Members

struct weston_output *(*get_output)(struct weston_touch_device *device)

Get the associated output if existing.

const char *(*get_calibration_head_name)(struct weston_touch_device *device)

Get the name of the associated head if existing.

void (*get_calibration)(struct weston_touch_device *device, struct weston_touch_device_matrix *cal)

Retrieve the current calibration matrix.

void (*set_calibration)(struct weston_touch_device *device, const struct weston_touch_device_matrix *cal)

Set a new calibration matrix.

struct weston_touch_device
#include <compositor.h>

Represents a physical touchscreen input device

Public Members

char *syspath

unique name

struct weston_touch *aggregate

weston_touch this is part of

struct wl_list link

in weston_touch::device_list

struct wl_signal destroy_signal

destroy notifier

void *backend_data

backend-specific private

const struct weston_touch_device_ops *ops
struct weston_touch_device_matrix saved_calibration
struct weston_touch
#include <compositor.h>

Represents a set of touchscreen devices aggregated under a seat

Public Members

struct weston_seat *seat
struct wl_list device_list
struct wl_list resource_list
struct wl_list focus_resource_list
struct weston_view *focus
struct wl_listener focus_view_listener
struct wl_listener focus_resource_listener
uint32_t focus_serial
struct wl_signal focus_signal
uint32_t num_tp
struct weston_touch_grab *grab
struct weston_touch_grab default_grab
int grab_touch_id
wl_fixed_t grab_x
wl_fixed_t grab_y
uint32_t grab_serial
struct timespec grab_time
struct wl_list timestamps_list
struct weston_xkb_info

Public Members

struct xkb_keymap *keymap
size_t keymap_size
char *keymap_string
int32_t ref_count
xkb_mod_index_t shift_mod
xkb_mod_index_t caps_mod
xkb_mod_index_t ctrl_mod
xkb_mod_index_t alt_mod
xkb_mod_index_t mod2_mod
xkb_mod_index_t mod3_mod
xkb_mod_index_t super_mod
xkb_mod_index_t mod5_mod
xkb_led_index_t num_led
xkb_led_index_t caps_led
xkb_led_index_t scroll_led
struct weston_keyboard

Public Members

struct weston_seat *seat
struct wl_list resource_list
struct wl_list focus_resource_list
struct weston_surface *focus
struct wl_listener focus_resource_listener
uint32_t focus_serial
struct wl_signal focus_signal
struct weston_keyboard_grab *grab
struct weston_keyboard_grab default_grab
uint32_t grab_key
uint32_t grab_serial
struct timespec grab_time
struct wl_array keys
uint32_t mods_depressed
uint32_t mods_latched
uint32_t mods_locked
uint32_t group
struct weston_keyboard::[anonymous] modifiers
struct weston_keyboard_grab input_method_grab
struct wl_resource *input_method_resource
struct weston_xkb_info *xkb_info
struct xkb_state *state
weston_led leds
struct weston_keyboard::[anonymous] xkb_state
struct xkb_keymap *pending_keymap
struct wl_list timestamps_list
struct weston_seat

Public Members

struct wl_list base_resource_list
struct wl_global *global
struct weston_pointer *pointer_state
struct weston_keyboard *keyboard_state
struct weston_touch *touch_state
int pointer_device_count
int keyboard_device_count
int touch_device_count
struct weston_output *output
struct wl_signal destroy_signal
struct wl_signal updated_caps_signal
struct weston_compositor *compositor
struct wl_list link
weston_keyboard_modifier modifier_state
struct weston_surface *saved_kbd_focus
struct wl_listener saved_kbd_focus_listener
struct wl_list drag_resource_list
uint32_t selection_serial
struct weston_data_source *selection_data_source
struct wl_listener selection_data_source_listener
struct wl_signal selection_signal
void (*led_update)(struct weston_seat *ws, enum weston_led leds)
struct input_method *input_method
char *seat_name
struct weston_layer_entry

Public Members

struct wl_list link
struct weston_layer *layer
struct weston_layer

Public Members

struct weston_compositor *compositor
struct wl_list link
weston_layer_position position
pixman_box32_t mask
struct weston_layer_entry view_list
struct weston_plane

Public Members

struct weston_compositor *compositor
pixman_region32_t damage

in global coords

pixman_region32_t clip
int32_t x
int32_t y
struct wl_list link
struct weston_renderer

Public Members

int (*read_pixels)(struct weston_output *output, pixman_format_code_t format, void *pixels, uint32_t x, uint32_t y, uint32_t width, uint32_t height)
void (*repaint_output)(struct weston_output *output, pixman_region32_t *output_damage)
void (*flush_damage)(struct weston_surface *surface)
void (*attach)(struct weston_surface *es, struct weston_buffer *buffer)
void (*surface_set_color)(struct weston_surface *surface, float red, float green, float blue, float alpha)
void (*destroy)(struct weston_compositor *ec)
void (*surface_get_content_size)(struct weston_surface *surface, int *width, int *height)

See weston_surface_get_content_size()

int (*surface_copy_content)(struct weston_surface *surface, void *target, size_t size, int src_x, int src_y, int width, int height)

See weston_surface_copy_content()

bool (*import_dmabuf)(struct weston_compositor *ec, struct linux_dmabuf_buffer *buffer)

See weston_compositor_import_dmabuf()

void (*query_dmabuf_formats)(struct weston_compositor *ec, int **formats, int *num_formats)

On error sets num_formats to zero

void (*query_dmabuf_modifiers)(struct weston_compositor *ec, int format, uint64_t **modifiers, int *num_modifiers)

On error sets num_modifiers to zero

struct weston_backend_config

Public Members

uint32_t struct_version

Major version for the backend-specific config struct

This version must match exactly what the backend expects, otherwise the struct is incompatible.

size_t struct_size

Minor version of the backend-specific config struct

This must be set to sizeof(struct backend-specific config). If the value here is smaller than what the backend expects, the extra config members will assume their default values.

A value greater than what the backend expects is incompatible.

struct weston_backend

Public Members

void (*destroy)(struct weston_compositor *compositor)
void *(*repaint_begin)(struct weston_compositor *compositor)

Begin a repaint sequence

Provides the backend with explicit markers around repaint sequences, which may allow the backend to aggregate state application. This call will be bracketed by the repaint_flush (on success), or repaint_cancel (when any output in the grouping fails repaint).

Returns an opaque pointer, which the backend may use as private data referring to the repaint cycle.

void (*repaint_cancel)(struct weston_compositor *compositor, void *repaint_data)

Cancel a repaint sequence

Cancels a repaint sequence, when an error has occurred during one output’s repaint; see repaint_begin.

Parameters
  • repaint_data: Data returned by repaint_begin

void (*repaint_flush)(struct weston_compositor *compositor, void *repaint_data)

Conclude a repaint sequence

Called on successful completion of a repaint sequence; see repaint_begin.

Parameters
  • repaint_data: Data returned by repaint_begin

struct weston_output *(*create_output)(struct weston_compositor *compositor, const char *name)

Allocate a new output

Allocates a new output structure that embeds a

weston_output, initializes it, and returns the pointer to the weston_output member.
Parameters
  • compositor: The compositor.
  • name: Name for the new output.

Must set weston_output members destroy, enable and disable.

struct weston_compositor

Public Members

struct wl_signal destroy_signal
struct wl_display *wl_display
struct weston_desktop_xwayland *xwayland
const struct weston_desktop_xwayland_interface *xwayland_interface
struct wl_signal create_surface_signal
struct wl_signal activate_signal
struct wl_signal transform_signal
struct wl_signal kill_signal
struct wl_signal idle_signal
struct wl_signal wake_signal
struct wl_signal show_input_panel_signal
struct wl_signal hide_input_panel_signal
struct wl_signal update_input_panel_signal
struct wl_signal seat_created_signal
struct wl_signal output_created_signal
struct wl_signal output_destroyed_signal
struct wl_signal output_moved_signal
struct wl_signal output_resized_signal
struct wl_signal output_heads_changed_signal
struct wl_signal session_signal
int session_active
struct weston_layer fade_layer
struct weston_layer cursor_layer
struct wl_list pending_output_list
struct wl_list output_list
struct wl_list head_list
struct wl_list seat_list
struct wl_list layer_list
struct wl_list view_list
struct wl_list plane_list
struct wl_list key_binding_list
struct wl_list modifier_binding_list
struct wl_list button_binding_list
struct wl_list touch_binding_list
struct wl_list axis_binding_list
struct wl_list debug_binding_list
uint32_t state
struct wl_event_source *idle_source
uint32_t idle_inhibit
int idle_time
struct wl_event_source *repaint_timer
const struct weston_pointer_grab_interface *default_pointer_grab
struct weston_plane primary_plane
uint32_t capabilities
struct weston_renderer *renderer
pixman_format_code_t read_format
struct weston_backend *backend
struct weston_launcher *launcher
struct wl_list plugin_api_list
uint32_t output_id_pool
struct xkb_rule_names xkb_names
struct xkb_context *xkb_context
struct weston_xkb_info *xkb_info
int32_t kb_repeat_rate
int32_t kb_repeat_delay
bool vt_switching
clockid_t presentation_clock
int32_t repaint_msec
unsigned int activate_serial
struct wl_global *pointer_constraints
int exit_code
void *user_data
void (*exit)(struct weston_compositor *c)
bool require_input
struct wl_signal heads_changed_signal
struct wl_event_source *heads_changed_source
weston_touch_mode touch_mode
struct wl_global *touch_calibration
weston_touch_calibration_save_func touch_calibration_save
struct weston_layer calibrator_layer
struct weston_touch_calibrator *touch_calibrator
struct weston_debug_compositor *weston_debug
struct weston_debug_scope *debug_scene
struct weston_buffer

Public Members

struct wl_resource *resource
struct wl_signal destroy_signal
struct wl_listener destroy_listener
struct wl_shm_buffer *shm_buffer
void *legacy_buffer
union weston_buffer::[anonymous] [anonymous]
int32_t width
int32_t height
uint32_t busy_count
int y_inverted
struct weston_buffer_reference

Public Members

struct weston_buffer *buffer
struct wl_listener destroy_listener
struct weston_buffer_viewport

Public Members

uint32_t transform
int32_t scale
wl_fixed_t src_x
wl_fixed_t src_y
wl_fixed_t src_width
wl_fixed_t src_height
struct weston_buffer_viewport::[anonymous] buffer
int32_t width
int32_t height
struct weston_buffer_viewport::[anonymous] surface
int changed
struct weston_buffer_release

Public Members

struct wl_resource *resource
uint32_t ref_count
int fence_fd
struct weston_buffer_release_reference

Public Members

struct weston_buffer_release *buffer_release
struct wl_listener destroy_listener
struct weston_region

Public Members

struct wl_resource *resource
pixman_region32_t region
struct weston_view

Public Members

struct weston_surface *surface
struct wl_list surface_link
struct wl_signal destroy_signal
struct wl_list link
struct weston_layer_entry layer_link
struct weston_plane *plane
struct weston_view *parent_view
unsigned int click_to_activate_serial
pixman_region32_t clip
float alpha
void *renderer_state
float x
float y
struct wl_list transformation_list
struct weston_view *parent
struct wl_listener parent_destroy_listener
struct wl_list child_list
struct wl_list parent_link
bool scissor_enabled
pixman_region32_t scissor
struct weston_view::[anonymous] geometry
int dirty
pixman_region32_t boundingbox
pixman_region32_t opaque
int enabled
struct weston_matrix matrix
struct weston_matrix inverse
struct weston_transform position
struct weston_view::[anonymous] transform
struct weston_output *output
struct wl_listener output_destroy_listener
uint32_t output_mask
uint32_t psf_flags
bool is_mapped
struct weston_surface_state

Public Members

int newly_attached
struct weston_buffer *buffer
struct wl_listener buffer_destroy_listener
int32_t sx
int32_t sy
pixman_region32_t damage_surface
pixman_region32_t damage_buffer
pixman_region32_t opaque
pixman_region32_t input
struct wl_list frame_callback_list
struct wl_list feedback_list
struct weston_buffer_viewport buffer_viewport
int acquire_fence_fd
struct weston_buffer_release_reference buffer_release_ref
struct weston_surface_activation_data

Public Members

struct weston_surface *surface
struct weston_seat *seat
struct weston_pointer_constraint

Public Members

struct wl_list link
struct weston_surface *surface
struct weston_view *view
struct wl_resource *resource
struct weston_pointer_grab grab
struct weston_pointer *pointer
uint32_t lifetime
pixman_region32_t region
pixman_region32_t region_pending
bool region_is_pending
wl_fixed_t hint_x
wl_fixed_t hint_y
wl_fixed_t hint_x_pending
wl_fixed_t hint_y_pending
bool hint_is_pending
struct wl_listener pointer_destroy_listener
struct wl_listener surface_destroy_listener
struct wl_listener surface_commit_listener
struct wl_listener surface_activate_listener
struct weston_surface

Public Members

struct wl_resource *resource
struct wl_signal destroy_signal
struct weston_compositor *compositor
struct wl_signal commit_signal
pixman_region32_t damage

Damage in local coordinates from the client, for tex upload.

pixman_region32_t opaque
pixman_region32_t input
int32_t width
int32_t height
int32_t ref_count
bool touched
void *renderer_state
struct wl_list views
struct weston_output *output
uint32_t output_mask
struct wl_list frame_callback_list
struct wl_list feedback_list
struct weston_buffer_reference buffer_ref
struct weston_buffer_viewport buffer_viewport
int32_t width_from_buffer
int32_t height_from_buffer
bool keep_buffer
struct wl_resource *viewport_resource
struct weston_surface_state pending
struct weston_matrix buffer_to_surface_matrix
struct weston_matrix surface_to_buffer_matrix
void (*committed)(struct weston_surface *es, int32_t sx, int32_t sy)
void *committed_private
int (*get_label)(struct weston_surface *surface, char *buf, size_t len)
struct wl_list subsurface_list
struct wl_list subsurface_list_pending
const char *role_name
struct weston_timeline_object timeline
bool is_mapped
bool is_opaque
struct wl_list pointer_constraints
struct wl_resource *synchronization_resource
int acquire_fence_fd
struct weston_buffer_release_reference buffer_release_ref
struct weston_subsurface

Public Members

struct wl_resource *resource
struct weston_surface *surface
struct wl_listener surface_destroy_listener
struct weston_surface *parent
struct wl_listener parent_destroy_listener
struct wl_list parent_link
int32_t x
int32_t y
int set
struct weston_subsurface::[anonymous] position
int has_cached_data
struct weston_surface_state cached
struct weston_buffer_reference cached_buffer_ref
bool reordered
int synchronized
struct wl_list unused_views

booo

Defines

DEFAULT_REPAINT_WINDOW

Functions

static void weston_output_update_matrix(struct weston_output *output)
static void weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale)
static void weston_compositor_build_view_list(struct weston_compositor *compositor)
static char *weston_output_create_heads_string(struct weston_output *output)

Create a string with the attached heads’ names.

The string must be free()’d.

static void weston_mode_switch_send_events(struct weston_head *head, bool mode_changed, bool scale_changed)

Send wl_output events for mode and scale changes

Parameters
  • head: Send on all resources bound to this head.
  • mode_changed: If true, send the current mode.
  • scale_changed: If true, send the current scale.

static void weston_mode_switch_finish(struct weston_output *output, int mode_changed, int scale_changed)
static void weston_compositor_reflow_outputs(struct weston_compositor *compositor, struct weston_output *resized_output, int delta_width)
WL_EXPORT int weston_output_mode_set_native(struct weston_output * output, struct weston_mode * mode, int32_t scale)
WL_EXPORT int weston_output_mode_switch_to_native(struct weston_output * output)
WL_EXPORT int weston_output_mode_switch_to_temporary(struct weston_output * output, struct weston_mode * mode, int32_t scale)
static void region_init_infinite(pixman_region32_t *region)
static struct weston_subsurface *weston_surface_to_subsurface(struct weston_surface *surface)
WL_EXPORT struct weston_view* weston_view_create(struct weston_surface * surface)
static void weston_presentation_feedback_discard(struct weston_presentation_feedback *feedback)
static void weston_presentation_feedback_discard_list(struct wl_list *list)
static void weston_presentation_feedback_present(struct weston_presentation_feedback *feedback, struct weston_output *output, uint32_t refresh_nsec, const struct timespec *ts, uint64_t seq, uint32_t flags)
static void weston_presentation_feedback_present_list(struct wl_list *list, struct weston_output *output, uint32_t refresh_nsec, const struct timespec *ts, uint64_t seq, uint32_t flags)
static void surface_state_handle_buffer_destroy(struct wl_listener *listener, void *data)
static void weston_surface_state_init(struct weston_surface_state *state)
static void weston_surface_state_fini(struct weston_surface_state *state)
static void weston_surface_state_set_buffer(struct weston_surface_state *state, struct weston_buffer *buffer)
WL_EXPORT struct weston_surface* weston_surface_create(struct weston_compositor * compositor)
WL_EXPORT void weston_surface_set_color(struct weston_surface * surface, float red, float green, float blue, float alpha)
WL_EXPORT void weston_view_to_global_float(struct weston_view * view, float sx, float sy, float * x, float * y)
WL_EXPORT void weston_transformed_coord(int width, int height, enum wl_output_transform transform, int32_t scale, float sx, float sy, float * bx, float * by)
WL_EXPORT pixman_box32_t weston_transformed_rect(int width, int height, enum wl_output_transform transform, int32_t scale, pixman_box32_t rect)
WL_EXPORT void weston_matrix_transform_region(pixman_region32_t * dest, struct weston_matrix * matrix, pixman_region32_t * src)

Transform a region by a matrix, restricted to axis-aligned transformations

Warning: This function does not work for projective, affine, or matrices that encode arbitrary rotations. Only 90-degree step rotations are supported.

WL_EXPORT void weston_transformed_region(int width, int height, enum wl_output_transform transform, int32_t scale, pixman_region32_t * src, pixman_region32_t * dest)
static void viewport_surface_to_buffer(struct weston_surface *surface, float sx, float sy, float *bx, float *by)
WL_EXPORT void weston_surface_to_buffer_float(struct weston_surface * surface, float sx, float sy, float * bx, float * by)
WL_EXPORT pixman_box32_t weston_surface_to_buffer_rect(struct weston_surface * surface, pixman_box32_t rect)

Transform a rectangle from surface coordinates to buffer coordinates

Viewport and buffer transformations can only do translation, scaling, and rotations in 90-degree steps. Therefore the only loss in the conversion is coordinate rounding.

Return
The transformed rectangle.
Parameters
  • surface: The surface to fetch wp_viewport and buffer transformation from.
  • rect: The rectangle to transform.

However, some coordinate rounding takes place as an intermediate step before the buffer scale factor is applied, so the rectangle boundary may not be exactly as expected.

This is OK for damage tracking since a little extra coverage is not a problem.

WL_EXPORT void weston_surface_to_buffer_region(struct weston_surface * surface, pixman_region32_t * surface_region, pixman_region32_t * buffer_region)

Transform a region from surface coordinates to buffer coordinates

Buffer_region must be init’d, but will be completely overwritten.

Parameters
  • surface: The surface to fetch wp_viewport and buffer transformation from.
  • surface_region[in]: The region in surface coordinates.
  • buffer_region[out]: The region converted to buffer coordinates.

Viewport and buffer transformations can only do translation, scaling, and rotations in 90-degree steps. Therefore the only loss in the conversion is from the coordinate rounding that takes place in weston_surface_to_buffer_rect.

WL_EXPORT void weston_view_move_to_plane(struct weston_view * view, struct weston_plane * plane)
WL_EXPORT void weston_view_damage_below(struct weston_view * view)

Inflict damage on the plane where the view is visible.

If the view is currently on a plane (including the primary plane), take the view’s boundingbox, subtract all the opaque views that cover it, and add the remaining region as damage to the plane. This corresponds to the damage inflicted to the plane if this view disappeared.

Parameters
  • view: The view that causes the damage.

A repaint is scheduled for this view.

The region of all opaque views covering this view is stored in weston_view::clip and updated by view_accumulate_damage() during weston_output_repaint(). Specifically, that region matches the scenegraph as it was last painted.

static void weston_surface_send_enter_leave(struct weston_surface *surface, struct weston_head *head, bool enter, bool leave)

Send wl_surface.enter/leave events

Send the enter/leave events for all protocol objects bound to the given output by the client owning the surface.

Parameters
  • surface: The surface.
  • head: A head of the entered/left output.
  • enter: True if entered.
  • left: True if left.

static void weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)

Sets the surface’s set of outputs to the ones specified by the new output mask provided. Identifies the outputs that have changed, the posts enter and leave events for these outputs as appropriate.

Parameters
  • es: The surface
  • mask: The new set of outputs for the surface

static void notify_view_output_destroy(struct wl_listener *listener, void *data)
WL_EXPORT void weston_view_set_output(struct weston_view * view, struct weston_output * output)

Set the primary output of the view

Set

output to be the primary output of the view.
Parameters
  • view: The view whose primary output to set
  • output: The new primary output for the view

Notice that the assignment may be temporary; the primary output could be automatically changed. Hence, one cannot rely on the value persisting.

Passing NULL as /a output will set the primary output to NULL.

static void weston_surface_assign_output(struct weston_surface *es)

Recalculate which output(s) the surface has views displayed on

Finds the output that is showing the largest amount of one of the surface’s various views. This output becomes the surface’s primary output for vsync and frame callback purposes.

Parameters
  • es: The surface to remap to outputs

Also notes all outputs of all of the surface’s views in the output_mask for the surface.

static void weston_view_assign_output(struct weston_view *ev)

Recalculate which output(s) the view is displayed on

Identifies the set of outputs that the view is visible on, noting them into the output_mask. The output that the view is most visible on is set as the view’s primary output.

Parameters
  • ev: The view to remap to outputs

Also does the same for the view’s surface. See weston_surface_assign_output().

static void weston_view_to_view_map(struct weston_view *from, struct weston_view *to, int from_x, int from_y, int *to_x, int *to_y)
static void weston_view_transfer_scissor(struct weston_view *from, struct weston_view *to)
static void view_compute_bbox(struct weston_view *view, const pixman_box32_t *inbox, pixman_region32_t *bbox)
static void weston_view_update_transform_disable(struct weston_view *view)
static int weston_view_update_transform_enable(struct weston_view *view)
static struct weston_layer *get_view_layer(struct weston_view *view)
WL_EXPORT void weston_view_update_transform(struct weston_view * view)
WL_EXPORT void weston_view_geometry_dirty(struct weston_view * view)
WL_EXPORT void weston_view_to_global_fixed(struct weston_view * view, wl_fixed_t vx, wl_fixed_t vy, wl_fixed_t * x, wl_fixed_t * y)
WL_EXPORT void weston_view_from_global_float(struct weston_view * view, float x, float y, float * vx, float * vy)
WL_EXPORT void weston_view_from_global_fixed(struct weston_view * view, wl_fixed_t x, wl_fixed_t y, wl_fixed_t * vx, wl_fixed_t * vy)
WL_EXPORT void weston_view_from_global(struct weston_view * view, int32_t x, int32_t y, int32_t * vx, int32_t * vy)
WL_EXPORT void weston_surface_schedule_repaint(struct weston_surface * surface)

Marks the output(s) that the surface is shown on as needing to be repainted. See weston_output_schedule_repaint().

Parameters
  • surface: The surface to be repainted

WL_EXPORT void weston_view_schedule_repaint(struct weston_view * view)

Marks the output(s) that the view is shown on as needing to be repainted. See weston_output_schedule_repaint().

Parameters
  • view: The view to be repainted

WL_EXPORT void weston_surface_damage(struct weston_surface * surface)

XXX: This function does it the wrong way. surface->damage is the damage from the client, and causes surface_flush_damage() to copy pixels. No window management action can cause damage to the client-provided content, warranting re-upload!

Instead of surface->damage, this function should record the damage with all the views for this surface to avoid extraneous texture uploads.

WL_EXPORT void weston_view_set_position(struct weston_view * view, float x, float y)
static void transform_parent_handle_parent_destroy(struct wl_listener *listener, void *data)
WL_EXPORT void weston_view_set_transform_parent(struct weston_view * view, struct weston_view * parent)
WL_EXPORT void weston_view_set_mask(struct weston_view * view, int x, int y, int width, int height)

Set a clip mask rectangle on a view

A shell may set a clip mask rectangle on a view. Everything outside the rectangle is cut away for input and output purposes: it is not drawn and cannot be hit by hit-test based input like pointer motion or touch-downs. Everything inside the rectangle will behave normally. Clients are unaware of clipping.

Parameters
  • view: The view to set the clip mask on.
  • x: Top-left corner X coordinate of the clip rectangle.
  • y: Top-left corner Y coordinate of the clip rectangle.
  • width: Width of the clip rectangle, non-negative.
  • height: Height of the clip rectangle, non-negative.

The rectangle is set in surface-local coordinates. Setting a clip mask rectangle does not affect the view position, the view is positioned as it would be without a clip. The clip also does not change weston_surface::width,height.

The clip mask rectangle is part of transformation inheritance (weston_view_set_transform_parent()). A clip set in the root of the transformation inheritance tree will affect all views in the tree. A clip can be set only on the root view. Attempting to set a clip on view that has a transformation parent will fail. Assigning a parent to a view that has a clip set will cause the clip to be forgotten.

Because the clip mask is an axis-aligned rectangle, it poses restrictions on the additional transformations in the child views. These transformations may not rotate the coordinate axes, i.e., only translation and scaling are allowed. Violating this restriction causes the clipping to malfunction. Furthermore, using scaling may cause rounding errors in child clipping.

The clip mask rectangle is not automatically adjusted based on wl_surface.attach dx and dy arguments.

A clip mask rectangle can be set only if the compositor capability WESTON_CAP_VIEW_CLIP_MASK is present.

This function sets the clip mask rectangle and schedules a repaint for the view.

WL_EXPORT void weston_view_set_mask_infinite(struct weston_view * view)

Remove the clip mask from a view

Removed the clip mask rectangle and schedules a repaint.

Parameters
  • view: The view to remove the clip mask from.

See
weston_view_set_mask

WL_EXPORT bool weston_view_is_mapped(struct weston_view * view)
WL_EXPORT bool weston_view_is_opaque(struct weston_view * ev, pixman_region32_t * region)
WL_EXPORT bool weston_surface_is_mapped(struct weston_surface * surface)
static void surface_set_size(struct weston_surface *surface, int32_t width, int32_t height)
WL_EXPORT void weston_surface_set_size(struct weston_surface * surface, int32_t width, int32_t height)
static int fixed_round_up_to_int(wl_fixed_t f)
static void convert_size_by_transform_scale(int32_t *width_out, int32_t *height_out, int32_t width, int32_t height, uint32_t transform, int32_t scale)
static void weston_surface_calculate_size_from_buffer(struct weston_surface *surface)
static void weston_surface_update_size(struct weston_surface *surface)
WL_EXPORT void weston_compositor_get_time(struct timespec * time)
WL_EXPORT struct weston_view* weston_compositor_pick_view(struct weston_compositor * compositor, wl_fixed_t x, wl_fixed_t y, wl_fixed_t * vx, wl_fixed_t * vy)
static void weston_compositor_repick(struct weston_compositor *compositor)
WL_EXPORT void weston_view_unmap(struct weston_view * view)
WL_EXPORT void weston_surface_unmap(struct weston_surface * surface)
static void weston_surface_reset_pending_buffer(struct weston_surface *surface)
WL_EXPORT void weston_view_destroy(struct weston_view * view)
WL_EXPORT void weston_surface_destroy(struct weston_surface * surface)
static void destroy_surface(struct wl_resource *resource)
static void weston_buffer_destroy_handler(struct wl_listener *listener, void *data)
WL_EXPORT struct weston_buffer* weston_buffer_from_resource(struct wl_resource * resource)
static void weston_buffer_reference_handle_destroy(struct wl_listener *listener, void *data)
WL_EXPORT void weston_buffer_reference(struct weston_buffer_reference * ref, struct weston_buffer * buffer)
static void weston_buffer_release_reference_handle_destroy(struct wl_listener *listener, void *data)
static void weston_buffer_release_destroy(struct weston_buffer_release *buffer_release)
WL_EXPORT void weston_buffer_release_reference(struct weston_buffer_release_reference * ref, struct weston_buffer_release * buffer_release)
WL_EXPORT void weston_buffer_release_move(struct weston_buffer_release_reference * dest, struct weston_buffer_release_reference * src)
static void weston_surface_attach(struct weston_surface *surface, struct weston_buffer *buffer)
WL_EXPORT void weston_compositor_damage_all(struct weston_compositor * compositor)
WL_EXPORT void weston_output_damage(struct weston_output * output)
static void surface_flush_damage(struct weston_surface *surface)
static void view_accumulate_damage(struct weston_view *view, pixman_region32_t *opaque)
static void compositor_accumulate_damage(struct weston_compositor *ec)
static void surface_stash_subsurface_views(struct weston_surface *surface)
static void surface_free_unused_subsurface_views(struct weston_surface *surface)
static void view_list_add_subsurface_view(struct weston_compositor *compositor, struct weston_subsurface *sub, struct weston_view *parent)
static void view_list_add(struct weston_compositor *compositor, struct weston_view *view)
static void weston_output_take_feedback_list(struct weston_output *output, struct weston_surface *surface)
static int weston_output_repaint(struct weston_output *output, void *repaint_data)
static void weston_output_schedule_repaint_reset(struct weston_output *output)
static int weston_output_maybe_repaint(struct weston_output *output, struct timespec *now, void *repaint_data)
static void output_repaint_timer_arm(struct weston_compositor *compositor)
static int output_repaint_timer_handler(void *data)
WL_EXPORT void weston_output_finish_frame(struct weston_output * output, const struct timespec * stamp, uint32_t presented_flags)
static void idle_repaint(void *data)
WL_EXPORT void weston_layer_entry_insert(struct weston_layer_entry * list, struct weston_layer_entry * entry)
WL_EXPORT void weston_layer_entry_remove(struct weston_layer_entry * entry)
WL_EXPORT void weston_layer_init(struct weston_layer * layer, struct weston_compositor * compositor)

Initialize the weston_layer struct.

Parameters
  • compositor: The compositor instance
  • layer: The layer to initialize

WL_EXPORT void weston_layer_set_position(struct weston_layer * layer, enum weston_layer_position position)

Sets the position of the layer in the layer list. The layer will be placed below any layer with the same position value, if any. This function is safe to call if the layer is already on the list, but the layer may be moved below other layers at the same position, if any.

Parameters
  • layer: The layer to modify
  • position: The position the layer will be placed at

WL_EXPORT void weston_layer_unset_position(struct weston_layer * layer)

Hide a layer by taking it off the layer list. This function is safe to call if the layer is not on the list.

Parameters
  • layer: The layer to hide

WL_EXPORT void weston_layer_set_mask(struct weston_layer * layer, int x, int y, int width, int height)
WL_EXPORT void weston_layer_set_mask_infinite(struct weston_layer * layer)
WL_EXPORT bool weston_layer_mask_is_infinite(struct weston_layer * layer)
WL_EXPORT void weston_output_schedule_repaint(struct weston_output * output)
WL_EXPORT void weston_compositor_schedule_repaint(struct weston_compositor * compositor)
static void surface_destroy(struct wl_client *client, struct wl_resource *resource)
static void surface_attach(struct wl_client *client, struct wl_resource *resource, struct wl_resource *buffer_resource, int32_t sx, int32_t sy)
static void surface_damage(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
static void surface_damage_buffer(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
static void destroy_frame_callback(struct wl_resource *resource)
static void surface_frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback)
static void surface_set_opaque_region(struct wl_client *client, struct wl_resource *resource, struct wl_resource *region_resource)
static void surface_set_input_region(struct wl_client *client, struct wl_resource *resource, struct wl_resource *region_resource)
static void weston_surface_damage_subsurfaces(struct weston_subsurface *sub)
static void weston_surface_commit_subsurface_order(struct weston_surface *surface)
static void weston_surface_build_buffer_matrix(const struct weston_surface *surface, struct weston_matrix *matrix)
static bool fixed_sum_gt(wl_fixed_t a, wl_fixed_t b, wl_fixed_t c)

Compute a + b > c while being safe to overflows.

static bool weston_surface_is_pending_viewport_source_valid(const struct weston_surface *surface)
static bool fixed_is_integer(wl_fixed_t v)
static bool weston_surface_is_pending_viewport_dst_size_int(const struct weston_surface *surface)
static void apply_damage_buffer(pixman_region32_t *dest, struct weston_surface *surface, struct weston_surface_state *state)
static void weston_surface_commit_state(struct weston_surface *surface, struct weston_surface_state *state)
static void weston_surface_commit(struct weston_surface *surface)
static void weston_subsurface_commit(struct weston_subsurface *sub)
static void weston_subsurface_parent_commit(struct weston_subsurface *sub, int parent_is_synchronized)
static void surface_commit(struct wl_client *client, struct wl_resource *resource)
static void surface_set_buffer_transform(struct wl_client *client, struct wl_resource *resource, int transform)
static void surface_set_buffer_scale(struct wl_client *client, struct wl_resource *resource, int32_t scale)
static void compositor_create_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id)
static void destroy_region(struct wl_resource *resource)
static void region_destroy(struct wl_client *client, struct wl_resource *resource)
static void region_add(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
static void region_subtract(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
static void compositor_create_region(struct wl_client *client, struct wl_resource *resource, uint32_t id)
static void weston_subsurface_commit_from_cache(struct weston_subsurface *sub)
static void weston_subsurface_commit_to_cache(struct weston_subsurface *sub)
static bool weston_subsurface_is_synchronized(struct weston_subsurface *sub)
static void weston_subsurface_synchronized_commit(struct weston_subsurface *sub)
static int subsurface_get_label(struct weston_surface *surface, char *buf, size_t len)
static void subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy)
WL_EXPORT struct weston_surface* weston_surface_get_main_surface(struct weston_surface * surface)
WL_EXPORT int weston_surface_set_role(struct weston_surface * surface, const char * role_name, struct wl_resource * error_resource, uint32_t error_code)
WL_EXPORT const char* weston_surface_get_role(struct weston_surface * surface)
WL_EXPORT void weston_surface_set_label_func(struct weston_surface * surface, int(*desc)(struct weston_surface *, char *, size_t))
WL_EXPORT void weston_surface_get_content_size(struct weston_surface * surface, int * width, int * height)

Get the size of surface contents

Retrieves the raw surface content size in pixels for the given surface. This is the whole content size in buffer pixels. If the surface has no content or the renderer does not implement this feature, zeroes are returned.

Parameters
  • surface: The surface to query.
  • width: Returns the width of raw contents.
  • height: Returns the height of raw contents.

This function is used to determine the buffer size needed for a weston_surface_copy_content() call.

WL_EXPORT struct weston_geometry weston_surface_get_bounding_box(struct weston_surface * surface)

Get the bounding box of a surface and its subsurfaces

Return
The bounding box relative to the surface origin.
Parameters
  • surface: The surface to query.

WL_EXPORT int weston_surface_copy_content(struct weston_surface * surface, void * target, size_t size, int src_x, int src_y, int width, int height)

Copy surface contents to system memory.

Surface contents are maintained by the renderer. They can be in a reserved

weston_buffer or as a copy, e.g. a GL texture, or something else.
Return
0 for success, -1 for failure.
Parameters
  • surface: The surface to copy from.
  • target: Pointer to the target memory buffer.
  • size: Size of the target buffer in bytes.
  • src_x: X location on contents to copy from.
  • src_y: Y location on contents to copy from.
  • width: Width in pixels of the area to copy.
  • height: Height in pixels of the area to copy.

Surface contents are copied into memory pointed to by target, which has size bytes of space available. The target memory may be larger than needed, but being smaller returns an error. The extra bytes in target may or may not be written; their content is unspecified. Size must be large enough to hold the image.

The image in the target memory will be arranged in rows from top to bottom, and pixels on a row from left to right. The pixel format is PIXMAN_a8b8g8r8, 4 bytes per pixel, and stride is exactly width * 4.

Parameters src_x and src_y define the upper-left corner in buffer coordinates (pixels) to copy from. Parameters width and height define the size of the area to copy in pixels.

The rectangle defined by src_x, src_y, width, height must fit in the surface contents. Otherwise an error is returned.

Use weston_surface_get_content_size to determine the content size; the needed target buffer size and rectangle limits.

CURRENT IMPLEMENTATION RESTRICTIONS:

  • the machine must be little-endian due to Pixman formats.

NOTE: Pixman formats are premultiplied.

static void subsurface_set_position(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y)
static struct weston_subsurface *subsurface_find_sibling(struct weston_subsurface *sub, struct weston_surface *surface)
static struct weston_subsurface *subsurface_sibling_check(struct weston_subsurface *sub, struct weston_surface *surface, const char *request)
static void subsurface_place_above(struct wl_client *client, struct wl_resource *resource, struct wl_resource *sibling_resource)
static void subsurface_place_below(struct wl_client *client, struct wl_resource *resource, struct wl_resource *sibling_resource)
static void subsurface_set_sync(struct wl_client *client, struct wl_resource *resource)
static void subsurface_set_desync(struct wl_client *client, struct wl_resource *resource)
static void weston_subsurface_destroy(struct weston_subsurface *sub)
static void subsurface_handle_surface_destroy(struct wl_listener *listener, void *data)
static void subsurface_handle_parent_destroy(struct wl_listener *listener, void *data)
static void subsurface_resource_destroy(struct wl_resource *resource)
static void subsurface_destroy(struct wl_client *client, struct wl_resource *resource)
static struct weston_subsurface *weston_subsurface_create(uint32_t id, struct weston_surface *surface, struct weston_surface *parent)
static struct weston_subsurface *weston_subsurface_create_for_parent(struct weston_surface *parent)
static void subcompositor_get_subsurface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource)
static void subcompositor_destroy(struct wl_client *client, struct wl_resource *resource)
static void bind_subcompositor(struct wl_client *client, void *data, uint32_t version, uint32_t id)
static void weston_compositor_dpms(struct weston_compositor *compositor, enum dpms_enum state)

Set a DPMS mode on all of the compositor’s outputs

Parameters
  • compositor: The compositor instance
  • state: The DPMS state the outputs will be set to

WL_EXPORT void weston_compositor_wake(struct weston_compositor * compositor)

Restores the compositor to active status

If the compositor was in a sleeping mode, all outputs are powered back on via DPMS. Otherwise if the compositor was inactive (idle/locked, offscreen, or sleeping) then the compositor’s wake signal will fire.

Parameters
  • compositor: The compositor instance

Restarts the idle timer.

WL_EXPORT void weston_compositor_offscreen(struct weston_compositor * compositor)

Turns off rendering and frame events for the compositor.

This is used for example to prevent further rendering while the compositor is shutting down.

Parameters
  • compositor: The compositor instance

Stops the idle timer.

WL_EXPORT void weston_compositor_sleep(struct weston_compositor * compositor)

Powers down all attached output devices

Causes rendering to the outputs to cease, and no frame events to be sent. Only powers down the outputs if the compositor is not already in sleep mode.

Parameters
  • compositor: The compositor instance

Stops the idle timer.

static int idle_handler(void *data)

Sets compositor to idle mode

This is called when the idle timer fires. Once the compositor is in idle mode it requires a wake action (e.g. via weston_compositor_wake()) to restore it. The compositor’s idle_signal will be triggered when the idle event occurs.

Parameters
  • data: The compositor instance

Idleness can be inhibited by setting the compositor’s idle_inhibit property.

WL_EXPORT void weston_plane_init(struct weston_plane * plane, struct weston_compositor * ec, int32_t x, int32_t y)
WL_EXPORT void weston_plane_release(struct weston_plane * plane)
WL_EXPORT void weston_compositor_stack_plane(struct weston_compositor * ec, struct weston_plane * plane, struct weston_plane * above)
static void output_release(struct wl_client *client, struct wl_resource *resource)
static void unbind_resource(struct wl_resource *resource)
static void bind_output(struct wl_client *client, void *data, uint32_t version, uint32_t id)
static void weston_head_add_global(struct weston_head *head)
static void weston_head_remove_global(struct weston_head *head)

Remove the global wl_output protocol object

Also orphans the wl_resources for this head (wl_output).

Parameters
  • head: The head whose global to remove.

WL_EXPORT struct weston_head* weston_head_from_resource(struct wl_resource * resource)

Get the backing object of wl_output

Return
The backing object (user data) of a wl_resource representing a wl_output protocol object.
Parameters
  • resource: A wl_output protocol object.

static void weston_output_emit_heads_changed(struct weston_output *output)

Send output heads changed signal

Notify that the enabled output gained and/or lost heads, or that the associated heads may have changed their connection status. This does not include cases where the output becomes enabled or disabled. The registered callbacks are called after the change has successfully happened.

Parameters
  • output: The output that changed.

If connection status change causes the compositor to attach or detach a head to an enabled output, the registered callbacks may be called multiple times.

static void weston_compositor_call_heads_changed(void *data)

Idle task for emitting heads_changed_signal

WL_EXPORT void weston_compositor_add_heads_changed_listener(struct weston_compositor * compositor, struct wl_listener * listener)
static void weston_head_set_device_changed(struct weston_head *head)
static bool str_null_eq(const char *a, const char *b)

String equal comparison with NULLs being equal

WL_EXPORT const char* weston_head_get_name(struct weston_head * head)

Get the name of a head

The name depends on the backend. The DRM backend uses connector names, other backends may use hardcoded names or user-given names.

Return
The head’s name, not NULL.
Parameters
  • head: The head to query.

WL_EXPORT struct weston_output* weston_head_get_output(struct weston_head * head)

Get the output the head is attached to

Return
The output the head is attached to, or NULL if detached.
Parameters
  • head: The head to query.

WL_EXPORT void weston_head_add_destroy_listener(struct weston_head * head, struct wl_listener * listener)

Add destroy callback for a head

Heads may get destroyed for various reasons by the backends. If a head is attached to an output, the compositor should listen for head destruction and reconfigure or destroy the output if necessary.

Parameters
  • head: The head to watch for.
  • listener: The listener to add. The notify member must be set.

The destroy callbacks will be called on weston_head destruction before any automatic detaching from an associated weston_output and before any weston_head information is lost.

The data argument to the notify callback is the weston_head being destroyed.

WL_EXPORT struct wl_listener* weston_head_get_destroy_listener(struct weston_head * head, wl_notify_func_t notify)

Look up destroy listener for a head

This looks up the previously added destroy listener struct based on the notify function it has. The listener can be used to access user data through

container_of().
Return
The listener, or NULL if not found.
Parameters
  • head: The head to query.
  • notify: The notify function used used for the added destroy listener.

See
wl_signal_get()

static void weston_output_init_geometry(struct weston_output *output, int x, int y)
WL_EXPORT void weston_output_move(struct weston_output * output, int x, int y)
static void weston_compositor_add_output(struct weston_compositor *compositor, struct weston_output *output)

Signal that a pending output is taken into use.

Removes the output from the pending list and adds it to the compositor’s list of enabled outputs. The output created signal is emitted.

The output gets an internal ID assigned, and the wl_output global is created.

Parameters
  • compositor: The compositor instance.
  • output: The output to be added.

WL_EXPORT int weston_output_enable(struct weston_output * output)

Constructs a weston_output object that can be used by the compositor.

Output coordinates are calculated and each new output is by default assigned to the right of previous one.

Parameters
  • output: The weston_output object that needs to be enabled. Must not be enabled already. Must have at least one head attached.

Sets up the transformation, zoom, and geometry of the output using the properties that need to be configured by the compositor.

Establishes a repaint timer for the output with the relevant display object’s event loop. See output_repaint_timer_handler().

The output is assigned an ID. Weston can support up to 32 distinct outputs, with IDs numbered from 0-31; the compositor’s output_id_pool is referred to and used to find the first available ID number, and then this ID is marked as used in output_id_pool.

The output is also assigned a Wayland global with the wl_output external interface.

Backend specific function is called to set up the output output.

Output is added to the compositor’s output list

If the backend specific function fails, the weston_output object is returned to a state it was before calling this function and is added to the compositor’s pending_output_list in case it needs to be reconfigured or just so it can be destroyed at shutdown.

0 is returned on success, -1 on failure.

WL_EXPORT void weston_output_disable(struct weston_output * output)

Converts a weston_output object to a pending output state, so it can be configured again or destroyed.

Calls a backend specific function to disable an output, in case such function exists.

Parameters

The backend specific disable function may choose to postpone the disabling by returning a negative value, in which case this function returns early. In that case the backend will guarantee the output will be disabled soon by the backend calling this function again. One must not attempt to re-enable the output until that happens.

Otherwise, if the output is being used by the compositor, it is removed from weston’s output_list (see weston_compositor_remove_output()) and is returned to a state it was before weston_output_enable() was ran (see weston_output_enable_undo()).

See weston_output_init() for more information on the state output is returned to.

If the output has never been enabled yet, this function can still be called to ensure that the output is actually turned off rather than left in the state it was discovered in.

WL_EXPORT void weston_compositor_flush_heads_changed(struct weston_compositor * compositor)

Forces a synchronous call to heads_changed hook

If there are new or changed heads, calls the heads_changed hook and returns after the hook returns.

Parameters
  • compositor: The compositor instance

WL_EXPORT void weston_output_add_destroy_listener(struct weston_output * output, struct wl_listener * listener)

Add destroy callback for an output

The listener callback will be called when user destroys an output. This may be delayed by a backend in some cases. The main purpose of the listener is to allow hooking up custom data to the output. The custom data can be fetched via weston_output_get_destroy_listener() followed by container_of().

Parameters
  • output: The output to watch.
  • listener: The listener to add. The notify member must be set.

The data argument to the notify callback is the weston_output being destroyed.

Note
This is for the final destruction of an output, not when it gets disabled. If you want to keep track of enabled outputs, this is not it.

WL_EXPORT struct wl_listener* weston_output_get_destroy_listener(struct weston_output * output, wl_notify_func_t notify)

Look up destroy listener for an output

This looks up the previously added destroy listener struct based on the notify function it has. The listener can be used to access user data through

container_of().
Return
The listener, or NULL if not found.
Parameters
  • output: The output to query.
  • notify: The notify function used used for the added destroy listener.

See
wl_signal_get() weston_output_add_destroy_listener()

WL_EXPORT struct weston_head* weston_output_get_first_head(struct weston_output * output)

When you need a head…

This function is a hack, used until all code has been converted to become multi-head aware.

Return
The first head in the output’s list.
Parameters

static void destroy_viewport(struct wl_resource *resource)
static void viewport_destroy(struct wl_client *client, struct wl_resource *resource)
static void viewport_set_source(struct wl_client *client, struct wl_resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height)
static void viewport_set_destination(struct wl_client *client, struct wl_resource *resource, int32_t dst_width, int32_t dst_height)
static void viewporter_destroy(struct wl_client *client, struct wl_resource *resource)
static void viewporter_get_viewport(struct wl_client *client, struct wl_resource *viewporter, uint32_t id, struct wl_resource *surface_resource)
static void bind_viewporter(struct wl_client *client, void *data, uint32_t version, uint32_t id)
static void destroy_presentation_feedback(struct wl_resource *feedback_resource)
static void presentation_destroy(struct wl_client *client, struct wl_resource *resource)
static void presentation_feedback(struct wl_client *client, struct wl_resource *presentation_resource, struct wl_resource *surface_resource, uint32_t callback)
static void bind_presentation(struct wl_client *client, void *data, uint32_t version, uint32_t id)
static void compositor_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
WL_EXPORT int weston_environment_get_fd(const char * env)
static void timeline_key_binding_handler(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data)
static const char *output_repaint_status_text(struct weston_output *output)
static void debug_scene_view_print_buffer(FILE *fp, struct weston_view *view)
static void debug_scene_view_print(FILE *fp, struct weston_view *view, int view_idx)
static void debug_scene_view_print_tree(struct weston_view *view, FILE *fp, int view_idx)
WL_EXPORT char* weston_compositor_print_scene_graph(struct weston_compositor * ec)

Output information on how libweston is currently composing the scene graph.

static void debug_scene_graph_cb(struct weston_debug_stream *stream, void *data)

Called when the ‘scene-graph’ debug scope is bound by a client. This one-shot weston-debug scope prints the current scene graph when bound, and then terminates the stream.

WL_EXPORT struct weston_compositor* weston_compositor_create(struct wl_display * display, void * user_data)

Create the compositor.

This functions creates and initializes a compositor instance.

Return
The compositor instance on success or NULL on failure.
Parameters
  • display: The Wayland display to be used.
  • user_data: A pointer to an object that can later be retrieved using the weston_compositor_get_user_data function.

WL_EXPORT void weston_compositor_shutdown(struct weston_compositor * ec)
WL_EXPORT void weston_compositor_exit_with_code(struct weston_compositor * compositor, int exit_code)
WL_EXPORT void weston_compositor_set_default_pointer_grab(struct weston_compositor * ec, const struct weston_pointer_grab_interface * interface)
WL_EXPORT int weston_compositor_set_presentation_clock(struct weston_compositor * compositor, clockid_t clk_id)
WL_EXPORT int weston_compositor_set_presentation_clock_software(struct weston_compositor * compositor)
WL_EXPORT void weston_compositor_read_presentation_clock(const struct weston_compositor * compositor, struct timespec * ts)

Read the current time from the Presentation clock

This function is never meant to fail. If reading the clock does fail, an error message is logged and a zero time is returned. Callers are not supposed to detect or react to failures.

Note
Reading the current time in user space is always imprecise to some degree.
Parameters
  • compositor:
  • ts[out]: The current time.

WL_EXPORT bool weston_compositor_import_dmabuf(struct weston_compositor * compositor, struct linux_dmabuf_buffer * buffer)

Import dmabuf buffer into current renderer

This function tests that the

linux_dmabuf_buffer is usable for the current renderer. Returns false on unusable buffers. Usually usability is tested by importing the dmabufs for composition.
Return
true on usable buffers, false otherwise
Parameters
  • compositor:
  • buffer: the dmabuf buffer to import

This hook is also used for detecting if the renderer supports dmabufs at all. If the renderer hook is NULL, dmabufs are not supported.

WL_EXPORT void weston_version(int * major, int * minor, int * micro)
WL_EXPORT size_t weston_module_path_from_env(const char * name, char * path, size_t path_len)

Attempts to find a module path from the module map specified in the environment. If found, writes the full path into the path variable.

The module map is a string in environment variable WESTON_MODULE_MAP, where each entry is of the form “name=path” and entries are separated by semicolons. Whitespace is significant.

Return
The length of the string written to path on success, or 0 if the module was not specified in the environment map or path_len was too small.
Parameters
  • name: The name to search for.
  • path: Where the path is written to if found.
  • path_len: Allocated bytes at path .

WL_EXPORT void* weston_load_module(const char * name, const char * entrypoint)
WL_EXPORT void weston_compositor_destroy(struct weston_compositor * compositor)

Destroys the compositor.

This function cleans up the compositor state and destroys it.

Parameters
  • compositor: The compositor to be destroyed.

WL_EXPORT void weston_compositor_exit(struct weston_compositor * compositor)

Instruct the compositor to exit.

This functions does not directly destroy the compositor object, it merely command it to start the tear down process. It is not guaranteed that the tear down will happen immediately.

Parameters
  • compositor: The compositor to tear down.

WL_EXPORT void* weston_compositor_get_user_data(struct weston_compositor * compositor)

Return the user data stored in the compositor.

This function returns the user data pointer set with user_data parameter to the weston_compositor_create function.

WL_EXPORT int weston_compositor_load_backend(struct weston_compositor * compositor, enum weston_compositor_backend backend, struct weston_backend_config * config_base)

Load a backend into a weston_compositor

A backend must be loaded to make a weston_compositor work. A backend provides input and output capabilities, and determines the renderer to use.

Return
0 on success, or -1 on error.
Parameters
  • compositor: A compositor that has not had a backend loaded yet.
  • backend: Name of the backend file.
  • config_base: A pointer to a backend-specific configuration structure’s ‘base’ member.

WL_EXPORT int weston_compositor_load_xwayland(struct weston_compositor * compositor)
WL_EXPORT void weston_buffer_send_server_error(struct weston_buffer * buffer, const char * msg)

Resolve an internal compositor error by disconnecting the client.

This function is used in cases when the wl_buffer turns out unusable and there is no fallback path.

It is possible the fault is caused by a compositor bug, the underlying graphics stack bug or normal behaviour, or perhaps a client mistake. In any case, the options are to either composite garbage or nothing, or disconnect the client. This is a helper function for the latter.

The error is sent as an INVALID_OBJECT error on the client’s wl_display.

Parameters
  • buffer: The weston buffer that is unusable.
  • msg: A custom error message attached to the protocol error.

Variables

const struct wl_surface_interface surface_interface = { surface_destroy, surface_attach, surface_damage, surface_frame, surface_set_opaque_region, surface_set_input_region, surface_commit, surface_set_buffer_transform, surface_set_buffer_scale, surface_damage_buffer}
const struct wl_region_interface region_interface = { region_destroy, region_add, region_subtract}
const struct wl_compositor_interface compositor_interface = { compositor_create_surface, compositor_create_region}
const struct wl_subsurface_interface subsurface_implementation = { subsurface_destroy, subsurface_set_position, subsurface_place_above, subsurface_place_below, subsurface_set_sync, subsurface_set_desync}
const struct wl_subcompositor_interface subcompositor_interface = { subcompositor_destroy, subcompositor_get_subsurface}
const struct wl_output_interface output_interface = { output_release,}
const struct wp_viewport_interface viewport_interface = { viewport_destroy, viewport_set_source, viewport_set_destination}
const struct wp_viewporter_interface viewporter_interface = { viewporter_destroy, viewporter_get_viewport}
const struct wp_presentation_interface presentation_implementation = { presentation_destroy, presentation_feedback}
const char *const backend_map[] = { [WESTON_BACKEND_DRM] = "drm-backend.so", [WESTON_BACKEND_FBDEV] = "fbdev-backend.so", [WESTON_BACKEND_HEADLESS] = "headless-backend.so", [WESTON_BACKEND_RDP] = "rdp-backend.so", [WESTON_BACKEND_WAYLAND] = "wayland-backend.so", [WESTON_BACKEND_X11] = "x11-backend.so",}
struct weston_frame_callback

Public Members

struct wl_resource *resource
struct wl_list link
struct weston_presentation_feedback

Public Members

struct wl_resource *resource
struct wl_list link
uint32_t psf_flags

C-Ref

Testing, c-ref here: weston_touch_create_touch_device() or weston_touch_create_touch_device() or weston_touch_create_touch_device().