ext-image-capture-source-v1: add start/stop hooks

This allows the source to change its behavior when actively
captured.
master
Simon Ser 5 months ago
parent d52f38c403
commit 324e894bf0

@ -18,6 +18,9 @@ struct wlr_renderer;
struct wlr_seat;
struct wlr_ext_image_capture_source_v1_interface {
// TODO: drop with_cursors flag
void (*start)(struct wlr_ext_image_capture_source_v1 *source, bool with_cursors);
void (*stop)(struct wlr_ext_image_capture_source_v1 *source);
void (*schedule_frame)(struct wlr_ext_image_capture_source_v1 *source);
void (*copy_frame)(struct wlr_ext_image_capture_source_v1 *source,
struct wlr_ext_image_copy_capture_frame_v1 *dst_frame,

@ -32,6 +32,9 @@ struct wlr_ext_output_image_capture_source_v1 {
struct wl_listener output_commit;
struct output_cursor_source cursor;
size_t num_started;
bool software_cursors_locked;
};
struct wlr_ext_output_image_capture_source_v1_frame_event {
@ -40,6 +43,32 @@ struct wlr_ext_output_image_capture_source_v1_frame_event {
struct timespec *when;
};
static void output_source_start(struct wlr_ext_image_capture_source_v1 *base,
bool with_cursors) {
struct wlr_ext_output_image_capture_source_v1 *source = wl_container_of(base, source, base);
source->num_started++;
if (source->num_started > 1) {
return;
}
wlr_output_lock_attach_render(source->output, true);
if (with_cursors) {
wlr_output_lock_software_cursors(source->output, true);
}
source->software_cursors_locked = with_cursors;
}
static void output_source_stop(struct wlr_ext_image_capture_source_v1 *base) {
struct wlr_ext_output_image_capture_source_v1 *source = wl_container_of(base, source, base);
assert(source->num_started > 0);
if (source->num_started > 0) {
return;
}
wlr_output_lock_attach_render(source->output, false);
if (source->software_cursors_locked) {
wlr_output_lock_software_cursors(source->output, false);
}
}
static void output_source_schedule_frame(struct wlr_ext_image_capture_source_v1 *base) {
struct wlr_ext_output_image_capture_source_v1 *source = wl_container_of(base, source, base);
wlr_output_update_needs_frame(source->output);
@ -67,6 +96,8 @@ static struct wlr_ext_image_capture_source_v1_cursor *output_source_get_pointer_
}
static const struct wlr_ext_image_capture_source_v1_interface output_source_impl = {
.start = output_source_start,
.stop = output_source_stop,
.schedule_frame = output_source_schedule_frame,
.copy_frame = output_source_copy_frame,
.get_pointer_cursor = output_source_get_pointer_cursor,

Loading…
Cancel
Save