|
|
@ -13,19 +13,25 @@ static void surface_attach(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *buffer, int32_t sx, int32_t sy) {
|
|
|
|
struct wl_resource *buffer, int32_t sx, int32_t sy) {
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
surface->pending_buffer = buffer;
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_BUFFER;
|
|
|
|
surface->pending_attached = true;
|
|
|
|
surface->pending.buffer = buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void surface_damage(struct wl_client *client,
|
|
|
|
static void surface_damage(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height) {
|
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height) {
|
|
|
|
wlr_log(L_DEBUG, "damage: %dx%d@%d,%d", width, height, x, y);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_SURFACE_DAMAGE;
|
|
|
|
|
|
|
|
pixman_region32_union_rect(&surface->pending.surface_damage,
|
|
|
|
|
|
|
|
&surface->pending.surface_damage,
|
|
|
|
|
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void destroy_frame_callback(struct wl_resource *resource) {
|
|
|
|
static void destroy_frame_callback(struct wl_resource *resource) {
|
|
|
|
struct wlr_frame_callback *cb = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_frame_callback *cb = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&cb->link);
|
|
|
|
wl_list_remove(&cb->link);
|
|
|
|
free(cb);
|
|
|
|
free(cb);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -58,38 +64,65 @@ static void surface_frame(struct wl_client *client,
|
|
|
|
static void surface_set_opaque_region(struct wl_client *client,
|
|
|
|
static void surface_set_opaque_region(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
wlr_log(L_DEBUG, "TODO: surface opaque region");
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_OPAQUE_REGION;
|
|
|
|
|
|
|
|
if (region_resource) {
|
|
|
|
|
|
|
|
pixman_region32_t *region = wl_resource_get_user_data(region_resource);
|
|
|
|
|
|
|
|
pixman_region32_copy(&surface->pending.opaque, region);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.opaque);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void surface_set_input_region(struct wl_client *client,
|
|
|
|
static void surface_set_input_region(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
wlr_log(L_DEBUG, "TODO: surface input region");
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_INPUT_REGION;
|
|
|
|
|
|
|
|
if (region_resource) {
|
|
|
|
|
|
|
|
pixman_region32_t *region = wl_resource_get_user_data(region_resource);
|
|
|
|
|
|
|
|
pixman_region32_copy(&surface->pending.input, region);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->pending.input);
|
|
|
|
|
|
|
|
pixman_region32_init_rect(&surface->pending.input,
|
|
|
|
|
|
|
|
INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void surface_commit(struct wl_client *client,
|
|
|
|
static void surface_commit(struct wl_client *client,
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
|
|
|
|
// apply pending state
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER)) {
|
|
|
|
if (surface->pending_attached) {
|
|
|
|
surface->current.buffer = surface->pending.buffer;
|
|
|
|
surface->attached = surface->pending_buffer;
|
|
|
|
// TODO: Move to wlr_surface_flush_damage and call from output frame
|
|
|
|
if (surface->pending_buffer) {
|
|
|
|
// callbacks instead of immediately here
|
|
|
|
struct wl_shm_buffer *buffer = wl_shm_buffer_get(surface->pending_buffer);
|
|
|
|
if (surface->current.buffer) {
|
|
|
|
|
|
|
|
struct wl_shm_buffer *buffer = wl_shm_buffer_get(surface->current.buffer);
|
|
|
|
if (!buffer) {
|
|
|
|
if (!buffer) {
|
|
|
|
wlr_log(L_INFO, "Unknown buffer handle attached");
|
|
|
|
wlr_log(L_INFO, "Unknown buffer handle attached");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
uint32_t format = wl_shm_buffer_get_format(buffer);
|
|
|
|
uint32_t format = wl_shm_buffer_get_format(buffer);
|
|
|
|
wlr_texture_upload_shm(surface->texture, format, buffer);
|
|
|
|
wlr_texture_upload_shm(surface->texture, format, buffer);
|
|
|
|
wl_resource_queue_event(surface->pending_buffer, WL_BUFFER_RELEASE);
|
|
|
|
wl_resource_queue_event(surface->current.buffer, WL_BUFFER_RELEASE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) {
|
|
|
|
|
|
|
|
// TODO: Sort out buffer damage too
|
|
|
|
|
|
|
|
pixman_region32_union(&surface->current.surface_damage,
|
|
|
|
|
|
|
|
&surface->current.surface_damage,
|
|
|
|
|
|
|
|
&surface->pending.surface_damage);
|
|
|
|
|
|
|
|
// TODO: Surface sizing is complicated
|
|
|
|
|
|
|
|
//pixman_region32_intersect_rect(&surface->current.surface_damage,
|
|
|
|
|
|
|
|
// &surface->current.surface_damage,
|
|
|
|
|
|
|
|
// 0, 0, surface->width, surface->height);
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.surface_damage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Commit other changes
|
|
|
|
|
|
|
|
|
|
|
|
// reset pending state
|
|
|
|
surface->pending.invalid = 0;
|
|
|
|
surface->pending_buffer = NULL;
|
|
|
|
// TODO: add the invalid bitfield to this callback
|
|
|
|
surface->pending_attached = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_signal_emit(&surface->signals.commit, surface);
|
|
|
|
wl_signal_emit(&surface->signals.commit, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -104,7 +137,6 @@ static void surface_set_buffer_scale(struct wl_client *client,
|
|
|
|
wlr_log(L_DEBUG, "TODO: surface set buffer scale");
|
|
|
|
wlr_log(L_DEBUG, "TODO: surface set buffer scale");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void surface_damage_buffer(struct wl_client *client,
|
|
|
|
static void surface_damage_buffer(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width,
|
|
|
|
int32_t x, int32_t y, int32_t width,
|
|
|
|