screencopy: listen to buffer destroy
This commit is contained in:
parent
9aaa9ba477
commit
dbb01cbcd0
|
@ -23,6 +23,7 @@ struct wlr_screencopy_frame_v1 {
|
||||||
int stride;
|
int stride;
|
||||||
|
|
||||||
struct wl_shm_buffer *buffer;
|
struct wl_shm_buffer *buffer;
|
||||||
|
struct wl_listener buffer_destroy;
|
||||||
|
|
||||||
struct wlr_output *output;
|
struct wlr_output *output;
|
||||||
struct wl_listener output_swap_buffers;
|
struct wl_listener output_swap_buffers;
|
||||||
|
|
|
@ -23,6 +23,7 @@ static void frame_destroy(struct wlr_screencopy_frame_v1 *frame) {
|
||||||
}
|
}
|
||||||
wl_list_remove(&frame->link);
|
wl_list_remove(&frame->link);
|
||||||
wl_list_remove(&frame->output_swap_buffers.link);
|
wl_list_remove(&frame->output_swap_buffers.link);
|
||||||
|
wl_list_remove(&frame->buffer_destroy.link);
|
||||||
// Make the frame resource inert
|
// Make the frame resource inert
|
||||||
wl_resource_set_user_data(frame->resource, NULL);
|
wl_resource_set_user_data(frame->resource, NULL);
|
||||||
free(frame);
|
free(frame);
|
||||||
|
@ -73,6 +74,14 @@ static void frame_handle_output_swap_buffers(struct wl_listener *listener,
|
||||||
frame_destroy(frame);
|
frame_destroy(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void frame_handle_buffer_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_screencopy_frame_v1 *frame =
|
||||||
|
wl_container_of(listener, frame, buffer_destroy);
|
||||||
|
zwlr_screencopy_frame_v1_send_failed(frame->resource);
|
||||||
|
frame_destroy(frame);
|
||||||
|
}
|
||||||
|
|
||||||
static void frame_handle_copy(struct wl_client *client,
|
static void frame_handle_copy(struct wl_client *client,
|
||||||
struct wl_resource *frame_resource,
|
struct wl_resource *frame_resource,
|
||||||
struct wl_resource *buffer_resource) {
|
struct wl_resource *buffer_resource) {
|
||||||
|
@ -116,11 +125,12 @@ static void frame_handle_copy(struct wl_client *client,
|
||||||
wl_signal_add(&output->events.swap_buffers, &frame->output_swap_buffers);
|
wl_signal_add(&output->events.swap_buffers, &frame->output_swap_buffers);
|
||||||
frame->output_swap_buffers.notify = frame_handle_output_swap_buffers;
|
frame->output_swap_buffers.notify = frame_handle_output_swap_buffers;
|
||||||
|
|
||||||
|
wl_resource_add_destroy_listener(buffer_resource, &frame->buffer_destroy);
|
||||||
|
frame->buffer_destroy.notify = frame_handle_buffer_destroy;
|
||||||
|
|
||||||
// Schedule a buffer swap
|
// Schedule a buffer swap
|
||||||
output->needs_swap = true;
|
output->needs_swap = true;
|
||||||
wlr_output_schedule_frame(output);
|
wlr_output_schedule_frame(output);
|
||||||
|
|
||||||
// TODO: listen to buffer destroy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void frame_handle_destroy(struct wl_client *client,
|
static void frame_handle_destroy(struct wl_client *client,
|
||||||
|
|
Loading…
Reference in New Issue