mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
ext-image-capture-source-v1: add start/stop hooks
This allows the source to change its behavior when actively captured.
This commit is contained in:
parent
82f9cd5310
commit
6bb8bb1cb7
2 changed files with 35 additions and 0 deletions
|
|
@ -18,6 +18,9 @@ struct wlr_renderer;
|
||||||
struct wlr_seat;
|
struct wlr_seat;
|
||||||
|
|
||||||
struct wlr_ext_image_capture_source_v1_interface {
|
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 (*schedule_frame)(struct wlr_ext_image_capture_source_v1 *source);
|
||||||
void (*copy_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,
|
struct wlr_ext_image_copy_capture_frame_v1 *dst_frame,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@ struct wlr_ext_output_image_capture_source_v1 {
|
||||||
struct wl_listener output_commit;
|
struct wl_listener output_commit;
|
||||||
|
|
||||||
struct output_cursor_source cursor;
|
struct output_cursor_source cursor;
|
||||||
|
|
||||||
|
size_t num_started;
|
||||||
|
bool software_cursors_locked;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_output_image_capture_source_v1_frame_event {
|
struct wlr_ext_output_image_capture_source_v1_frame_event {
|
||||||
|
|
@ -41,6 +44,33 @@ struct wlr_ext_output_image_capture_source_v1_frame_event {
|
||||||
struct timespec *when;
|
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);
|
||||||
|
source->num_started--;
|
||||||
|
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) {
|
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);
|
struct wlr_ext_output_image_capture_source_v1 *source = wl_container_of(base, source, base);
|
||||||
wlr_output_update_needs_frame(source->output);
|
wlr_output_update_needs_frame(source->output);
|
||||||
|
|
@ -68,6 +98,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 = {
|
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,
|
.schedule_frame = output_source_schedule_frame,
|
||||||
.copy_frame = output_source_copy_frame,
|
.copy_frame = output_source_copy_frame,
|
||||||
.get_pointer_cursor = output_source_get_pointer_cursor,
|
.get_pointer_cursor = output_source_get_pointer_cursor,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue