Codebase list wlroots / 3df602a
export-dmabuf: disable hardware cursors if desired Also make the frame resource inert when sending "ready". emersion 5 years ago
3 changed file(s) with 29 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
4444
4545 /* Target */
4646 struct wl_output *target_output;
47 bool with_cursor;
4748
4849 /* Main frame callback */
4950 struct zwlr_export_dmabuf_frame_v1 *frame_callback;
453454
454455 static void register_cb(struct capture_context *ctx) {
455456 ctx->frame_callback = zwlr_export_dmabuf_manager_v1_capture_output(
456 ctx->export_manager, 0, ctx->target_output);
457 ctx->export_manager, ctx->with_cursor, ctx->target_output);
457458
458459 zwlr_export_dmabuf_frame_v1_add_listener(ctx->frame_callback,
459460 &frame_listener, ctx);
801802 }
802803
803804 ctx.target_output = o->output;
805 ctx.with_cursor = true;
804806 ctx.hw_device_type = av_hwdevice_find_type_by_name(argv[2]);
805807 ctx.hardware_device = argv[3];
806808
88 #ifndef WLR_TYPES_WLR_EXPORT_DMABUF_V1_H
99 #define WLR_TYPES_WLR_EXPORT_DMABUF_V1_H
1010
11 #include <stdbool.h>
1112 #include <wayland-server.h>
1213 #include <wlr/render/dmabuf.h>
1314
2021
2122 struct wlr_dmabuf_attributes attribs;
2223 struct wlr_output *output;
24
25 bool cursor_locked;
2326
2427 struct wl_listener output_swap_buffers;
2528 };
2828 .destroy = frame_handle_destroy,
2929 };
3030
31 static void frame_handle_resource_destroy(struct wl_resource *resource) {
32 struct wlr_export_dmabuf_frame_v1 *frame = frame_from_resource(resource);
31 static void frame_destroy(struct wlr_export_dmabuf_frame_v1 *frame) {
32 if (frame == NULL) {
33 return;
34 }
35 if (frame->cursor_locked) {
36 wlr_output_lock_software_cursors(frame->output, false);
37 }
3338 wl_list_remove(&frame->link);
3439 wl_list_remove(&frame->output_swap_buffers.link);
3540 wlr_dmabuf_attributes_finish(&frame->attribs);
41 // Make the frame resource inert
42 wl_resource_set_user_data(frame->resource, NULL);
3643 free(frame);
44 }
45
46 static void frame_handle_resource_destroy(struct wl_resource *resource) {
47 struct wlr_export_dmabuf_frame_v1 *frame = frame_from_resource(resource);
48 frame_destroy(frame);
3749 }
3850
3951 static void frame_output_handle_swap_buffers(struct wl_listener *listener,
5062 uint32_t tv_sec_lo = tv_sec & 0xFFFFFFFF;
5163 zwlr_export_dmabuf_frame_v1_send_ready(frame->resource,
5264 tv_sec_hi, tv_sec_lo, event->when->tv_nsec);
65 frame_destroy(frame);
5366 }
5467
5568
95108 if (!output->impl->export_dmabuf) {
96109 zwlr_export_dmabuf_frame_v1_send_cancel(frame->resource,
97110 ZWLR_EXPORT_DMABUF_FRAME_V1_CANCEL_REASON_PERMANENT);
111 frame_destroy(frame);
98112 return;
99113 }
100114
102116 if (!wlr_output_export_dmabuf(output, attribs)) {
103117 zwlr_export_dmabuf_frame_v1_send_cancel(frame->resource,
104118 ZWLR_EXPORT_DMABUF_FRAME_V1_CANCEL_REASON_TEMPORARY);
105 return;
119 frame_destroy(frame);
120 return;
121 }
122
123 if (overlay_cursor) {
124 wlr_output_lock_software_cursors(frame->output, true);
125 frame->cursor_locked = true;
106126 }
107127
108128 uint32_t frame_flags = ZWLR_EXPORT_DMABUF_FRAME_V1_FLAGS_TRANSIENT;