output: introduce wlr_output_lock_attach_render
This allows screen shooters and screen grabbers to ensure rendering will be used instead of direct scan-out.
This commit is contained in:
parent
e554c593f9
commit
6c659da98b
|
@ -137,6 +137,8 @@ struct wlr_output {
|
||||||
struct wl_event_source *idle_frame;
|
struct wl_event_source *idle_frame;
|
||||||
struct wl_event_source *idle_done;
|
struct wl_event_source *idle_done;
|
||||||
|
|
||||||
|
int attach_render_locks; // number of locks forcing rendering
|
||||||
|
|
||||||
struct wl_list cursors; // wlr_output_cursor::link
|
struct wl_list cursors; // wlr_output_cursor::link
|
||||||
struct wlr_output_cursor *hardware_cursor;
|
struct wlr_output_cursor *hardware_cursor;
|
||||||
int software_cursor_locks; // number of locks forcing software cursors
|
int software_cursor_locks; // number of locks forcing software cursors
|
||||||
|
@ -287,6 +289,13 @@ bool wlr_output_set_gamma(struct wlr_output *output, size_t size,
|
||||||
bool wlr_output_export_dmabuf(struct wlr_output *output,
|
bool wlr_output_export_dmabuf(struct wlr_output *output,
|
||||||
struct wlr_dmabuf_attributes *attribs);
|
struct wlr_dmabuf_attributes *attribs);
|
||||||
struct wlr_output *wlr_output_from_resource(struct wl_resource *resource);
|
struct wlr_output *wlr_output_from_resource(struct wl_resource *resource);
|
||||||
|
/**
|
||||||
|
* Locks the output to only use rendering instead of direct scan-out. This is
|
||||||
|
* useful if direct scan-out needs to be temporarily disabled (e.g. during
|
||||||
|
* screen capture). There must be as many unlocks as there have been locks to
|
||||||
|
* restore the original state. There should never be an unlock before a lock.
|
||||||
|
*/
|
||||||
|
void wlr_output_lock_attach_render(struct wlr_output *output, bool lock);
|
||||||
/**
|
/**
|
||||||
* Locks the output to only use software cursors instead of hardware cursors.
|
* Locks the output to only use software cursors instead of hardware cursors.
|
||||||
* This is useful if hardware cursors need to be temporarily disabled (e.g.
|
* This is useful if hardware cursors need to be temporarily disabled (e.g.
|
||||||
|
|
|
@ -34,6 +34,7 @@ static void frame_destroy(struct wlr_export_dmabuf_frame_v1 *frame) {
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wlr_output_lock_attach_render(frame->output, false);
|
||||||
if (frame->cursor_locked) {
|
if (frame->cursor_locked) {
|
||||||
wlr_output_lock_software_cursors(frame->output, false);
|
wlr_output_lock_software_cursors(frame->output, false);
|
||||||
}
|
}
|
||||||
|
@ -126,6 +127,7 @@ static void manager_handle_capture_output(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_output_lock_attach_render(frame->output, true);
|
||||||
if (overlay_cursor) {
|
if (overlay_cursor) {
|
||||||
wlr_output_lock_software_cursors(frame->output, true);
|
wlr_output_lock_software_cursors(frame->output, true);
|
||||||
frame->cursor_locked = true;
|
frame->cursor_locked = true;
|
||||||
|
|
|
@ -497,6 +497,9 @@ bool wlr_output_attach_buffer(struct wlr_output *output,
|
||||||
if (!output->impl->attach_buffer) {
|
if (!output->impl->attach_buffer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (output->attach_render_locks > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// If the output has at least one software cursor, refuse to attach the
|
// If the output has at least one software cursor, refuse to attach the
|
||||||
// buffer
|
// buffer
|
||||||
|
@ -614,6 +617,18 @@ struct wlr_output *wlr_output_from_resource(struct wl_resource *resource) {
|
||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_output_lock_attach_render(struct wlr_output *output, bool lock) {
|
||||||
|
if (lock) {
|
||||||
|
++output->attach_render_locks;
|
||||||
|
} else {
|
||||||
|
assert(output->attach_render_locks > 0);
|
||||||
|
--output->attach_render_locks;
|
||||||
|
}
|
||||||
|
wlr_log(WLR_DEBUG, "%s direct scan-out on output '%s' (locks: %d)",
|
||||||
|
lock ? "Disabling" : "Enabling", output->name,
|
||||||
|
output->attach_render_locks);
|
||||||
|
}
|
||||||
|
|
||||||
static void output_cursor_damage_whole(struct wlr_output_cursor *cursor);
|
static void output_cursor_damage_whole(struct wlr_output_cursor *cursor);
|
||||||
|
|
||||||
void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock) {
|
void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ static void frame_destroy(struct wlr_screencopy_frame_v1 *frame) {
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wlr_output_lock_attach_render(frame->output, false);
|
||||||
if (frame->cursor_locked) {
|
if (frame->cursor_locked) {
|
||||||
wlr_output_lock_software_cursors(frame->output, false);
|
wlr_output_lock_software_cursors(frame->output, false);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +144,7 @@ static void frame_handle_copy(struct wl_client *client,
|
||||||
output->needs_frame = true;
|
output->needs_frame = true;
|
||||||
wlr_output_schedule_frame(output);
|
wlr_output_schedule_frame(output);
|
||||||
|
|
||||||
|
wlr_output_lock_attach_render(output, true);
|
||||||
if (frame->overlay_cursor) {
|
if (frame->overlay_cursor) {
|
||||||
wlr_output_lock_software_cursors(output, true);
|
wlr_output_lock_software_cursors(output, true);
|
||||||
frame->cursor_locked = true;
|
frame->cursor_locked = true;
|
||||||
|
|
Loading…
Reference in New Issue