mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
screencopy: send failed after output disconnect
This prevents screencopy applications from hanging because a failed event never got sent when the output was disconnected or disabled after the call to buffer().
This commit is contained in:
parent
ce3e413e83
commit
724b5e1b8d
2 changed files with 30 additions and 0 deletions
|
@ -43,6 +43,8 @@ struct wlr_screencopy_frame_v1 {
|
||||||
|
|
||||||
struct wlr_output *output;
|
struct wlr_output *output;
|
||||||
struct wl_listener output_precommit;
|
struct wl_listener output_precommit;
|
||||||
|
struct wl_listener output_destroy;
|
||||||
|
struct wl_listener output_enable;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,6 +31,8 @@ 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_precommit.link);
|
wl_list_remove(&frame->output_precommit.link);
|
||||||
|
wl_list_remove(&frame->output_destroy.link);
|
||||||
|
wl_list_remove(&frame->output_enable.link);
|
||||||
wl_list_remove(&frame->buffer_destroy.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);
|
||||||
|
@ -88,6 +90,24 @@ static void frame_handle_output_precommit(struct wl_listener *listener,
|
||||||
frame_destroy(frame);
|
frame_destroy(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void frame_handle_output_enable(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_screencopy_frame_v1 *frame =
|
||||||
|
wl_container_of(listener, frame, output_enable);
|
||||||
|
if (!frame->output->enabled) {
|
||||||
|
zwlr_screencopy_frame_v1_send_failed(frame->resource);
|
||||||
|
frame_destroy(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void frame_handle_output_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_screencopy_frame_v1 *frame =
|
||||||
|
wl_container_of(listener, frame, output_destroy);
|
||||||
|
zwlr_screencopy_frame_v1_send_failed(frame->resource);
|
||||||
|
frame_destroy(frame);
|
||||||
|
}
|
||||||
|
|
||||||
static void frame_handle_buffer_destroy(struct wl_listener *listener,
|
static void frame_handle_buffer_destroy(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct wlr_screencopy_frame_v1 *frame =
|
struct wlr_screencopy_frame_v1 *frame =
|
||||||
|
@ -145,6 +165,12 @@ static void frame_handle_copy(struct wl_client *client,
|
||||||
wl_signal_add(&output->events.precommit, &frame->output_precommit);
|
wl_signal_add(&output->events.precommit, &frame->output_precommit);
|
||||||
frame->output_precommit.notify = frame_handle_output_precommit;
|
frame->output_precommit.notify = frame_handle_output_precommit;
|
||||||
|
|
||||||
|
wl_signal_add(&output->events.destroy, &frame->output_enable);
|
||||||
|
frame->output_enable.notify = frame_handle_output_enable;
|
||||||
|
|
||||||
|
wl_signal_add(&output->events.destroy, &frame->output_destroy);
|
||||||
|
frame->output_destroy.notify = frame_handle_output_destroy;
|
||||||
|
|
||||||
wl_resource_add_destroy_listener(buffer_resource, &frame->buffer_destroy);
|
wl_resource_add_destroy_listener(buffer_resource, &frame->buffer_destroy);
|
||||||
frame->buffer_destroy.notify = frame_handle_buffer_destroy;
|
frame->buffer_destroy.notify = frame_handle_buffer_destroy;
|
||||||
|
|
||||||
|
@ -211,6 +237,8 @@ static void capture_output(struct wl_client *client,
|
||||||
wl_list_insert(&manager->frames, &frame->link);
|
wl_list_insert(&manager->frames, &frame->link);
|
||||||
|
|
||||||
wl_list_init(&frame->output_precommit.link);
|
wl_list_init(&frame->output_precommit.link);
|
||||||
|
wl_list_init(&frame->output_enable.link);
|
||||||
|
wl_list_init(&frame->output_destroy.link);
|
||||||
wl_list_init(&frame->buffer_destroy.link);
|
wl_list_init(&frame->buffer_destroy.link);
|
||||||
|
|
||||||
if (output == NULL || !output->enabled) {
|
if (output == NULL || !output->enabled) {
|
||||||
|
|
Loading…
Reference in a new issue