2017-09-23 10:26:01 +02:00
|
|
|
#ifndef WLR_TYPES_WLR_SURFACE_H
|
|
|
|
#define WLR_TYPES_WLR_SURFACE_H
|
2018-02-12 21:29:23 +01:00
|
|
|
|
|
|
|
#include <pixman.h>
|
2017-09-22 04:17:29 +02:00
|
|
|
#include <stdbool.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <stdint.h>
|
2017-11-20 20:53:13 +01:00
|
|
|
#include <time.h>
|
|
|
|
#include <wayland-server.h>
|
2017-10-23 05:19:21 +02:00
|
|
|
#include <wlr/types/wlr_output.h>
|
2017-08-09 15:33:30 +02:00
|
|
|
|
2017-08-09 21:58:41 +02:00
|
|
|
struct wlr_frame_callback {
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct wl_list link;
|
|
|
|
};
|
|
|
|
|
2017-08-10 05:34:50 +02:00
|
|
|
#define WLR_SURFACE_INVALID_BUFFER 1
|
|
|
|
#define WLR_SURFACE_INVALID_SURFACE_DAMAGE 2
|
|
|
|
#define WLR_SURFACE_INVALID_BUFFER_DAMAGE 4
|
|
|
|
#define WLR_SURFACE_INVALID_OPAQUE_REGION 8
|
|
|
|
#define WLR_SURFACE_INVALID_INPUT_REGION 16
|
2017-08-11 20:30:42 +02:00
|
|
|
#define WLR_SURFACE_INVALID_TRANSFORM 32
|
|
|
|
#define WLR_SURFACE_INVALID_SCALE 64
|
2017-09-25 00:24:48 +02:00
|
|
|
#define WLR_SURFACE_INVALID_SUBSURFACE_POSITION 128
|
|
|
|
#define WLR_SURFACE_INVALID_FRAME_CALLBACK_LIST 256
|
2017-08-10 05:34:50 +02:00
|
|
|
|
|
|
|
struct wlr_surface_state {
|
|
|
|
uint32_t invalid;
|
|
|
|
struct wl_resource *buffer;
|
2017-10-03 20:57:23 +02:00
|
|
|
struct wl_listener buffer_destroy_listener;
|
2017-08-10 05:34:50 +02:00
|
|
|
int32_t sx, sy;
|
|
|
|
pixman_region32_t surface_damage, buffer_damage;
|
|
|
|
pixman_region32_t opaque, input;
|
2017-08-14 22:30:53 +02:00
|
|
|
enum wl_output_transform transform;
|
2017-08-10 05:34:50 +02:00
|
|
|
int32_t scale;
|
2017-08-15 14:17:17 +02:00
|
|
|
int width, height;
|
|
|
|
int buffer_width, buffer_height;
|
2017-09-25 00:24:48 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
int32_t x, y;
|
|
|
|
} subsurface_position;
|
|
|
|
|
|
|
|
struct wl_list frame_callback_list; // wl_surface.frame
|
2017-08-10 05:34:50 +02:00
|
|
|
};
|
2017-08-09 15:33:30 +02:00
|
|
|
|
2017-09-24 17:17:17 +02:00
|
|
|
struct wlr_subsurface {
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct wlr_surface *surface;
|
|
|
|
struct wlr_surface *parent;
|
|
|
|
|
2017-09-25 00:24:48 +02:00
|
|
|
struct wlr_surface_state *cached;
|
|
|
|
bool has_cache;
|
2017-09-24 17:17:17 +02:00
|
|
|
|
|
|
|
bool synchronized;
|
2017-09-29 14:40:37 +02:00
|
|
|
bool reordered;
|
2017-09-25 00:24:48 +02:00
|
|
|
|
|
|
|
struct wl_list parent_link;
|
2017-09-29 14:40:37 +02:00
|
|
|
struct wl_list parent_pending_link;
|
2017-09-30 19:24:59 +02:00
|
|
|
|
|
|
|
struct wl_listener parent_destroy_listener;
|
2018-01-21 14:22:33 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
2017-09-24 17:17:17 +02:00
|
|
|
};
|
|
|
|
|
2017-08-10 05:34:50 +02:00
|
|
|
struct wlr_surface {
|
|
|
|
struct wl_resource *resource;
|
2017-08-11 04:15:37 +02:00
|
|
|
struct wlr_renderer *renderer;
|
2017-08-09 15:33:30 +02:00
|
|
|
struct wlr_texture *texture;
|
2017-09-25 00:24:48 +02:00
|
|
|
struct wlr_surface_state *current, *pending;
|
2017-08-09 15:33:30 +02:00
|
|
|
const char *role; // the lifetime-bound role or null
|
2017-08-10 05:34:50 +02:00
|
|
|
|
2018-03-15 15:33:58 +01:00
|
|
|
float buffer_to_surface_matrix[9];
|
|
|
|
float surface_to_buffer_matrix[9];
|
2017-08-09 15:33:30 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal commit;
|
2018-01-21 14:22:33 +01:00
|
|
|
struct wl_signal new_subsurface;
|
2017-09-11 19:01:53 +02:00
|
|
|
struct wl_signal destroy;
|
2017-10-08 19:12:28 +02:00
|
|
|
} events;
|
2017-08-09 21:58:41 +02:00
|
|
|
|
2017-09-24 14:25:53 +02:00
|
|
|
// destroy listener used by compositor
|
|
|
|
struct wl_listener compositor_listener;
|
2017-08-10 12:42:35 +02:00
|
|
|
void *compositor_data;
|
2017-08-11 20:23:53 +02:00
|
|
|
|
2017-12-27 12:06:29 +01:00
|
|
|
// surface commit callback for the role that runs before all others
|
|
|
|
void (*role_committed)(struct wlr_surface *surface, void *role_data);
|
|
|
|
void *role_data;
|
|
|
|
|
2017-09-24 14:23:18 +02:00
|
|
|
// subsurface properties
|
|
|
|
struct wlr_subsurface *subsurface;
|
2017-09-25 00:24:48 +02:00
|
|
|
struct wl_list subsurface_list; // wlr_subsurface::parent_link
|
2017-09-24 14:23:18 +02:00
|
|
|
|
2017-09-29 14:40:37 +02:00
|
|
|
// wlr_subsurface::parent_pending_link
|
|
|
|
struct wl_list subsurface_pending_list;
|
2017-08-11 20:23:53 +02:00
|
|
|
void *data;
|
2017-08-09 15:33:30 +02:00
|
|
|
};
|
|
|
|
|
2017-08-09 15:58:10 +02:00
|
|
|
struct wlr_renderer;
|
2017-08-09 15:33:30 +02:00
|
|
|
struct wlr_surface *wlr_surface_create(struct wl_resource *res,
|
|
|
|
struct wlr_renderer *renderer);
|
2018-03-15 11:10:56 +01:00
|
|
|
|
2017-09-12 00:06:19 +02:00
|
|
|
/**
|
|
|
|
* Set the lifetime role for this surface. Returns 0 on success or -1 if the
|
|
|
|
* role cannot be set.
|
|
|
|
*/
|
|
|
|
int wlr_surface_set_role(struct wlr_surface *surface, const char *role,
|
|
|
|
struct wl_resource *error_resource, uint32_t error_code);
|
|
|
|
|
2017-10-23 03:07:32 +02:00
|
|
|
/**
|
|
|
|
* Whether or not this surface currently has an attached buffer. A surface has
|
|
|
|
* an attached buffer when it commits with a non-null buffer in its pending
|
|
|
|
* state. A surface will not have a buffer if it has never committed one, has
|
|
|
|
* committed a null buffer, or something went wrong with uploading the buffer.
|
|
|
|
*/
|
|
|
|
bool wlr_surface_has_buffer(struct wlr_surface *surface);
|
|
|
|
|
2017-09-24 14:23:18 +02:00
|
|
|
/**
|
|
|
|
* Create the subsurface implementation for this surface.
|
|
|
|
*/
|
|
|
|
void wlr_surface_make_subsurface(struct wlr_surface *surface,
|
|
|
|
struct wlr_surface *parent, uint32_t id);
|
|
|
|
|
2017-09-29 14:58:17 +02:00
|
|
|
/**
|
|
|
|
* Get the top of the subsurface tree for this surface.
|
|
|
|
*/
|
|
|
|
struct wlr_surface *wlr_surface_get_main_surface(struct wlr_surface *surface);
|
|
|
|
|
2017-10-09 22:51:55 +02:00
|
|
|
/**
|
|
|
|
* Find a subsurface within this surface at the surface-local coordinates.
|
|
|
|
* Returns the surface and coordinates in the topmost surface coordinate system
|
|
|
|
* or NULL if no subsurface is found at that location.
|
|
|
|
*/
|
|
|
|
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
|
|
|
|
double sx, double sy, double *sub_x, double *sub_y);
|
2017-10-23 05:19:21 +02:00
|
|
|
|
2018-03-31 04:19:33 +02:00
|
|
|
bool wlr_surface_point_accepts_input(
|
|
|
|
struct wlr_surface *surface, double sx, double sy);
|
|
|
|
|
2017-10-23 05:19:21 +02:00
|
|
|
void wlr_surface_send_enter(struct wlr_surface *surface,
|
|
|
|
struct wlr_output *output);
|
|
|
|
|
2017-10-26 04:37:02 +02:00
|
|
|
void wlr_surface_send_leave(struct wlr_surface *surface,
|
|
|
|
struct wlr_output *output);
|
|
|
|
|
2017-11-20 20:53:13 +01:00
|
|
|
void wlr_surface_send_frame_done(struct wlr_surface *surface,
|
|
|
|
const struct timespec *when);
|
|
|
|
|
2017-12-27 12:06:29 +01:00
|
|
|
/**
|
|
|
|
* Set a callback for surface commit that runs before all the other callbacks.
|
|
|
|
* This is intended for use by the surface role.
|
|
|
|
*/
|
|
|
|
void wlr_surface_set_role_committed(struct wlr_surface *surface,
|
|
|
|
void (*role_committed)(struct wlr_surface *surface, void *role_data),
|
|
|
|
void *role_data);
|
|
|
|
|
2018-02-13 23:48:46 +01:00
|
|
|
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource);
|
|
|
|
|
2017-08-09 15:33:30 +02:00
|
|
|
#endif
|