2018-07-13 14:40:56 +02:00
|
|
|
/*
|
|
|
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
|
|
* future consistency of this API.
|
|
|
|
*/
|
|
|
|
#ifndef WLR_USE_UNSTABLE
|
|
|
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
|
|
#endif
|
|
|
|
|
2017-09-23 10:26:01 +02:00
|
|
|
#ifndef WLR_TYPES_WLR_OUTPUT_H
|
|
|
|
#define WLR_TYPES_WLR_OUTPUT_H
|
|
|
|
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <pixman.h>
|
2017-11-01 20:08:15 +01:00
|
|
|
#include <stdbool.h>
|
2018-01-19 14:08:47 +01:00
|
|
|
#include <time.h>
|
2017-06-20 00:41:02 +02:00
|
|
|
#include <wayland-server.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <wayland-util.h>
|
2018-07-19 22:50:00 +02:00
|
|
|
#include <wlr/render/dmabuf.h>
|
2017-06-20 00:41:02 +02:00
|
|
|
|
|
|
|
struct wlr_output_mode {
|
|
|
|
uint32_t flags; // enum wl_output_mode
|
|
|
|
int32_t width, height;
|
|
|
|
int32_t refresh; // mHz
|
2017-10-15 12:32:37 +02:00
|
|
|
struct wl_list link;
|
2017-06-20 00:41:02 +02:00
|
|
|
};
|
|
|
|
|
2017-10-29 09:09:21 +01:00
|
|
|
struct wlr_output_cursor {
|
|
|
|
struct wlr_output *output;
|
2017-11-04 06:35:12 +01:00
|
|
|
double x, y;
|
2017-11-02 11:37:43 +01:00
|
|
|
bool enabled;
|
2017-12-08 14:23:33 +01:00
|
|
|
bool visible;
|
2017-10-29 17:43:26 +01:00
|
|
|
uint32_t width, height;
|
2017-10-29 09:09:21 +01:00
|
|
|
int32_t hotspot_x, hotspot_y;
|
|
|
|
struct wl_list link;
|
|
|
|
|
2017-11-02 11:37:43 +01:00
|
|
|
// only when using a software cursor without a surface
|
2017-10-29 09:09:21 +01:00
|
|
|
struct wlr_texture *texture;
|
|
|
|
|
|
|
|
// only when using a cursor surface
|
|
|
|
struct wlr_surface *surface;
|
|
|
|
struct wl_listener surface_commit;
|
|
|
|
struct wl_listener surface_destroy;
|
2018-02-01 12:08:35 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
2017-10-29 09:09:21 +01:00
|
|
|
};
|
|
|
|
|
2017-06-20 00:41:02 +02:00
|
|
|
struct wlr_output_impl;
|
|
|
|
|
2018-02-11 13:04:00 +01:00
|
|
|
/**
|
|
|
|
* A compositor output region. This typically corresponds to a monitor that
|
|
|
|
* displays part of the compositor space.
|
|
|
|
*
|
|
|
|
* Compositors should listen to the `frame` event to render an output. They
|
|
|
|
* should call `wlr_output_make_current`, render and then call
|
|
|
|
* `wlr_output_swap_buffers`. No rendering should happen outside a `frame` event
|
|
|
|
* handler.
|
|
|
|
*/
|
2017-06-20 00:41:02 +02:00
|
|
|
struct wlr_output {
|
|
|
|
const struct wlr_output_impl *impl;
|
2017-10-21 06:37:25 +02:00
|
|
|
struct wlr_backend *backend;
|
2018-01-04 12:46:15 +01:00
|
|
|
struct wl_display *display;
|
2017-08-13 16:51:50 +02:00
|
|
|
|
2018-07-08 20:21:31 +02:00
|
|
|
struct wl_global *global;
|
|
|
|
struct wl_list resources;
|
2017-06-20 00:41:02 +02:00
|
|
|
|
2018-04-05 06:58:23 +02:00
|
|
|
char name[24];
|
2018-10-04 17:01:48 +02:00
|
|
|
char make[56];
|
2017-06-20 00:41:02 +02:00
|
|
|
char model[16];
|
2017-11-11 19:09:34 +01:00
|
|
|
char serial[16];
|
2017-06-20 00:41:02 +02:00
|
|
|
int32_t phys_width, phys_height; // mm
|
2018-01-04 12:46:15 +01:00
|
|
|
|
2018-01-21 11:11:25 +01:00
|
|
|
// Note: some backends may have zero modes
|
|
|
|
struct wl_list modes;
|
|
|
|
struct wlr_output_mode *current_mode;
|
|
|
|
int32_t width, height;
|
|
|
|
int32_t refresh; // mHz, may be zero
|
|
|
|
|
2018-01-04 12:46:15 +01:00
|
|
|
bool enabled;
|
|
|
|
float scale;
|
2017-11-01 20:08:15 +01:00
|
|
|
enum wl_output_subpixel subpixel;
|
|
|
|
enum wl_output_transform transform;
|
2017-06-20 00:41:02 +02:00
|
|
|
|
2018-01-20 16:43:14 +01:00
|
|
|
bool needs_swap;
|
2018-01-26 22:11:09 +01:00
|
|
|
// damage for cursors and fullscreen surface, in output-local coordinates
|
|
|
|
pixman_region32_t damage;
|
2018-01-26 22:39:23 +01:00
|
|
|
bool frame_pending;
|
2018-03-15 15:33:58 +01:00
|
|
|
float transform_matrix[9];
|
2017-06-20 00:41:02 +02:00
|
|
|
|
|
|
|
struct {
|
2018-10-01 14:08:07 +02:00
|
|
|
// Request to render a frame
|
2017-06-20 00:41:02 +02:00
|
|
|
struct wl_signal frame;
|
2018-10-01 14:08:07 +02:00
|
|
|
// Emitted when buffers need to be swapped (because software cursors or
|
|
|
|
// fullscreen damage or because of backend-specific logic)
|
2018-01-20 16:43:14 +01:00
|
|
|
struct wl_signal needs_swap;
|
2018-10-01 14:08:07 +02:00
|
|
|
// Emitted right before buffer swap
|
2018-05-23 10:02:19 +02:00
|
|
|
struct wl_signal swap_buffers; // wlr_output_event_swap_buffers
|
2018-10-01 14:08:07 +02:00
|
|
|
// Emitted right after the buffer has been presented to the user
|
2018-09-29 22:38:13 +02:00
|
|
|
struct wl_signal present; // wlr_output_event_present
|
2018-01-04 14:51:36 +01:00
|
|
|
struct wl_signal enable;
|
2018-01-06 12:42:32 +01:00
|
|
|
struct wl_signal mode;
|
2017-12-12 21:58:00 +01:00
|
|
|
struct wl_signal scale;
|
|
|
|
struct wl_signal transform;
|
2017-08-30 19:28:50 +02:00
|
|
|
struct wl_signal destroy;
|
2017-06-20 00:41:02 +02:00
|
|
|
} events;
|
2017-06-26 07:34:15 +02:00
|
|
|
|
2018-01-30 14:45:02 +01:00
|
|
|
struct wl_event_source *idle_frame;
|
|
|
|
|
2017-10-29 09:09:21 +01:00
|
|
|
struct wl_list cursors; // wlr_output_cursor::link
|
|
|
|
struct wlr_output_cursor *hardware_cursor;
|
2018-09-17 15:07:08 +02:00
|
|
|
int software_cursor_locks; // number of locks forcing software cursors
|
2017-08-11 20:23:53 +02:00
|
|
|
|
2017-10-19 18:57:45 +02:00
|
|
|
// the output position in layout space reported to clients
|
|
|
|
int32_t lx, ly;
|
|
|
|
|
2017-12-07 01:12:04 +01:00
|
|
|
struct wl_listener display_destroy;
|
|
|
|
|
2017-08-11 20:23:53 +02:00
|
|
|
void *data;
|
2017-06-20 00:41:02 +02:00
|
|
|
};
|
|
|
|
|
2018-05-23 10:02:19 +02:00
|
|
|
struct wlr_output_event_swap_buffers {
|
|
|
|
struct wlr_output *output;
|
|
|
|
struct timespec *when;
|
|
|
|
pixman_region32_t *damage;
|
|
|
|
};
|
|
|
|
|
2018-09-29 22:38:13 +02:00
|
|
|
enum wlr_output_present_flag {
|
2018-10-02 12:11:09 +02:00
|
|
|
// The presentation was synchronized to the "vertical retrace" by the
|
|
|
|
// display hardware such that tearing does not happen.
|
2018-09-29 22:38:13 +02:00
|
|
|
WLR_OUTPUT_PRESENT_VSYNC = 0x1,
|
2018-10-02 12:11:09 +02:00
|
|
|
// The display hardware provided measurements that the hardware driver
|
|
|
|
// converted into a presentation timestamp.
|
2018-09-29 22:38:13 +02:00
|
|
|
WLR_OUTPUT_PRESENT_HW_CLOCK = 0x2,
|
2018-10-02 12:11:09 +02:00
|
|
|
// The display hardware signalled that it started using the new image
|
|
|
|
// content.
|
2018-09-29 22:38:13 +02:00
|
|
|
WLR_OUTPUT_PRESENT_HW_COMPLETION = 0x4,
|
2018-10-02 12:11:09 +02:00
|
|
|
// The presentation of this update was done zero-copy.
|
|
|
|
WLR_OUTPUT_PRESENT_ZERO_COPY = 0x8,
|
2018-09-29 22:38:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_output_event_present {
|
|
|
|
struct wlr_output *output;
|
2018-10-02 12:11:09 +02:00
|
|
|
// Time when the content update turned into light the first time.
|
2018-09-29 22:38:13 +02:00
|
|
|
struct timespec *when;
|
2018-10-02 12:11:09 +02:00
|
|
|
// Vertical retrace counter. Zero if unavailable.
|
2018-09-29 22:38:13 +02:00
|
|
|
unsigned seq;
|
2018-10-02 12:11:09 +02:00
|
|
|
// Prediction of how many nanoseconds after `when` the very next output
|
|
|
|
// refresh may occur. Zero if unknown.
|
|
|
|
int refresh; // nsec
|
2018-09-29 22:38:13 +02:00
|
|
|
uint32_t flags; // enum wlr_output_present_flag
|
|
|
|
};
|
|
|
|
|
2017-10-08 21:21:06 +02:00
|
|
|
struct wlr_surface;
|
|
|
|
|
2018-09-14 18:18:07 +02:00
|
|
|
/**
|
|
|
|
* Enables or disables the output. A disabled output is turned off and doesn't
|
|
|
|
* emit `frame` events.
|
|
|
|
*/
|
|
|
|
bool wlr_output_enable(struct wlr_output *output, bool enable);
|
2018-01-24 10:23:48 +01:00
|
|
|
void wlr_output_create_global(struct wlr_output *output);
|
|
|
|
void wlr_output_destroy_global(struct wlr_output *output);
|
2018-04-04 05:05:49 +02:00
|
|
|
/**
|
2018-09-14 18:18:07 +02:00
|
|
|
* Sets the output mode. Enables the output if it's currently disabled.
|
2018-04-04 05:05:49 +02:00
|
|
|
*/
|
2017-06-20 00:41:02 +02:00
|
|
|
bool wlr_output_set_mode(struct wlr_output *output,
|
2017-10-08 21:21:06 +02:00
|
|
|
struct wlr_output_mode *mode);
|
2018-04-04 05:05:49 +02:00
|
|
|
/**
|
|
|
|
* Sets a custom mode on the output. If modes are available, they are preferred.
|
|
|
|
* Setting `refresh` to zero lets the backend pick a preferred value.
|
|
|
|
*/
|
2017-12-11 12:14:23 +01:00
|
|
|
bool wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
|
|
|
|
int32_t height, int32_t refresh);
|
2017-12-12 21:58:00 +01:00
|
|
|
void wlr_output_set_transform(struct wlr_output *output,
|
2017-10-08 21:21:06 +02:00
|
|
|
enum wl_output_transform transform);
|
2017-10-19 18:57:45 +02:00
|
|
|
void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly);
|
2017-12-15 01:00:03 +01:00
|
|
|
void wlr_output_set_scale(struct wlr_output *output, float scale);
|
2017-06-20 00:41:02 +02:00
|
|
|
void wlr_output_destroy(struct wlr_output *output);
|
2018-01-30 10:23:35 +01:00
|
|
|
/**
|
|
|
|
* Computes the transformed output resolution.
|
|
|
|
*/
|
|
|
|
void wlr_output_transformed_resolution(struct wlr_output *output,
|
|
|
|
int *width, int *height);
|
|
|
|
/**
|
|
|
|
* Computes the transformed and scaled output resolution.
|
|
|
|
*/
|
2017-06-20 00:41:02 +02:00
|
|
|
void wlr_output_effective_resolution(struct wlr_output *output,
|
2017-10-08 21:21:06 +02:00
|
|
|
int *width, int *height);
|
2018-01-21 00:06:35 +01:00
|
|
|
/**
|
2018-01-21 11:11:25 +01:00
|
|
|
* Makes the output rendering context current.
|
2018-01-21 00:06:35 +01:00
|
|
|
*
|
|
|
|
* `buffer_age` is set to the drawing buffer age in number of frames or -1 if
|
2018-01-21 11:11:25 +01:00
|
|
|
* unknown. This is useful for damage tracking.
|
2018-01-21 00:06:35 +01:00
|
|
|
*/
|
|
|
|
bool wlr_output_make_current(struct wlr_output *output, int *buffer_age);
|
2018-01-19 14:08:47 +01:00
|
|
|
/**
|
|
|
|
* Swaps the output buffers. If the time of the frame isn't known, set `when` to
|
|
|
|
* NULL. If the compositor doesn't support damage tracking, set `damage` to
|
|
|
|
* NULL.
|
2018-01-21 11:11:25 +01:00
|
|
|
*
|
|
|
|
* Swapping buffers schedules a `frame` event.
|
2018-01-19 14:08:47 +01:00
|
|
|
*/
|
2018-01-21 00:06:35 +01:00
|
|
|
bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when,
|
2018-01-19 14:08:47 +01:00
|
|
|
pixman_region32_t *damage);
|
2018-01-26 22:39:23 +01:00
|
|
|
/**
|
|
|
|
* Manually schedules a `frame` event. If a `frame` event is already pending,
|
|
|
|
* it is a no-op.
|
|
|
|
*/
|
|
|
|
void wlr_output_schedule_frame(struct wlr_output *output);
|
2018-07-22 18:23:34 +02:00
|
|
|
/**
|
|
|
|
* Returns the maximum length of each gamma ramp, or 0 if unsupported.
|
|
|
|
*/
|
2018-10-03 10:36:33 +02:00
|
|
|
size_t wlr_output_get_gamma_size(struct wlr_output *output);
|
2018-07-22 18:23:34 +02:00
|
|
|
/**
|
|
|
|
* Sets the gamma table for this output. `r`, `g` and `b` are gamma ramps for
|
|
|
|
* red, green and blue. `size` is the length of the ramps and must not exceed
|
|
|
|
* the value returned by `wlr_output_get_gamma_size`.
|
2018-07-22 18:37:01 +02:00
|
|
|
*
|
|
|
|
* Providing zero-sized ramps resets the gamma table.
|
2018-07-22 18:23:34 +02:00
|
|
|
*/
|
2018-10-03 10:36:33 +02:00
|
|
|
bool wlr_output_set_gamma(struct wlr_output *output, size_t size,
|
|
|
|
const uint16_t *r, const uint16_t *g, const uint16_t *b);
|
2018-05-21 19:50:51 +02:00
|
|
|
bool wlr_output_export_dmabuf(struct wlr_output *output,
|
2018-05-31 13:33:27 +02:00
|
|
|
struct wlr_dmabuf_attributes *attribs);
|
2018-02-13 23:48:46 +01:00
|
|
|
struct wlr_output *wlr_output_from_resource(struct wl_resource *resource);
|
2018-09-17 15:07:08 +02:00
|
|
|
/**
|
|
|
|
* Locks the output to only use software cursors instead of hardware cursors.
|
|
|
|
* This is useful if hardware cursors need to be temporarily disabled (e.g.
|
|
|
|
* during screen capture). There must be as many unlocks as there have been
|
|
|
|
* locks to restore the original state. There should never be an unlock before
|
|
|
|
* a lock.
|
|
|
|
*/
|
|
|
|
void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock);
|
2018-11-10 15:50:28 +01:00
|
|
|
/**
|
|
|
|
* Renders software cursors. This is a utility function that can be called when
|
|
|
|
* compositors render.
|
|
|
|
*/
|
|
|
|
void wlr_output_render_software_cursors(struct wlr_output *output,
|
|
|
|
pixman_region32_t *damage);
|
2017-10-07 19:01:11 +02:00
|
|
|
|
2018-01-21 11:11:25 +01:00
|
|
|
|
2017-10-29 09:09:21 +01:00
|
|
|
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output);
|
2017-12-08 14:23:33 +01:00
|
|
|
/**
|
|
|
|
* Sets the cursor image. The image must be already scaled for the output.
|
|
|
|
*/
|
2017-10-29 09:09:21 +01:00
|
|
|
bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
|
|
|
|
const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height,
|
|
|
|
int32_t hotspot_x, int32_t hotspot_y);
|
|
|
|
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
|
|
|
|
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
|
2017-11-04 06:35:12 +01:00
|
|
|
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
|
|
|
double x, double y);
|
2017-10-29 09:09:21 +01:00
|
|
|
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
|
|
|
|
|
2017-12-27 11:17:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the transform that, when composed with `tr`, gives
|
|
|
|
* `WL_OUTPUT_TRANSFORM_NORMAL`.
|
|
|
|
*/
|
2017-12-26 18:16:37 +01:00
|
|
|
enum wl_output_transform wlr_output_transform_invert(
|
|
|
|
enum wl_output_transform tr);
|
2017-12-27 11:17:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a transform that, when applied, has the same effect as applying
|
|
|
|
* sequentially `tr_a` and `tr_b`.
|
|
|
|
*/
|
2017-12-26 18:16:37 +01:00
|
|
|
enum wl_output_transform wlr_output_transform_compose(
|
|
|
|
enum wl_output_transform tr_a, enum wl_output_transform tr_b);
|
2017-11-30 23:58:12 +01:00
|
|
|
|
2017-06-20 00:41:02 +02:00
|
|
|
#endif
|