From c9f0dbc159f0d5408f28477c62e6ee8038726f1d Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 24 Apr 2025 14:12:43 +0100 Subject: [PATCH] Change all timespec pointers in events to owned Follow-up from !4803. Make things consistent by making all `struct timespec`s in events owned. Reduces the need for thinking about ownership/lifetimes. --- include/wlr/types/wlr_output.h | 4 ++-- types/ext_image_capture_source_v1/output.c | 4 ++-- types/output/output.c | 4 ++-- types/wlr_cursor.c | 2 +- types/wlr_export_dmabuf_v1.c | 4 ++-- types/wlr_screencopy_v1.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 9c08a2c34..31b757062 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -245,13 +245,13 @@ struct wlr_output_event_damage { struct wlr_output_event_precommit { struct wlr_output *output; - struct timespec *when; + struct timespec when; const struct wlr_output_state *state; }; struct wlr_output_event_commit { struct wlr_output *output; - struct timespec *when; + struct timespec when; const struct wlr_output_state *state; }; diff --git a/types/ext_image_capture_source_v1/output.c b/types/ext_image_capture_source_v1/output.c index e5ef78f93..a2726c759 100644 --- a/types/ext_image_capture_source_v1/output.c +++ b/types/ext_image_capture_source_v1/output.c @@ -40,7 +40,7 @@ struct wlr_ext_output_image_capture_source_v1 { struct wlr_ext_output_image_capture_source_v1_frame_event { struct wlr_ext_image_capture_source_v1_frame_event base; struct wlr_buffer *buffer; - struct timespec *when; + struct timespec when; }; static void output_source_start(struct wlr_ext_image_capture_source_v1 *base, @@ -85,7 +85,7 @@ static void output_source_copy_frame(struct wlr_ext_image_capture_source_v1 *bas if (wlr_ext_image_copy_capture_frame_v1_copy_buffer(frame, event->buffer, source->output->renderer)) { wlr_ext_image_copy_capture_frame_v1_ready(frame, - source->output->transform, event->when); + source->output->transform, &event->when); } } diff --git a/types/output/output.c b/types/output/output.c index a352a5e59..346a3aa40 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -728,7 +728,7 @@ bool output_prepare_commit(struct wlr_output *output, const struct wlr_output_st struct wlr_output_event_precommit pre_event = { .output = output, - .when = &now, + .when = now, .state = state, }; wl_signal_emit_mutable(&output->events.precommit, &pre_event); @@ -750,7 +750,7 @@ void output_apply_commit(struct wlr_output *output, const struct wlr_output_stat clock_gettime(CLOCK_MONOTONIC, &now); struct wlr_output_event_commit event = { .output = output, - .when = &now, + .when = now, .state = state, }; wl_signal_emit_mutable(&output->events.commit, &event); diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 44b74e926..7f99fef0c 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -650,7 +650,7 @@ static void output_cursor_output_handle_output_commit( struct wlr_surface *surface = output_cursor->cursor->state->surface; if (surface && output_cursor->output_cursor->visible && (event->state->committed & WLR_OUTPUT_STATE_BUFFER)) { - wlr_surface_send_frame_done(surface, event->when); + wlr_surface_send_frame_done(surface, &event->when); } } diff --git a/types/wlr_export_dmabuf_v1.c b/types/wlr_export_dmabuf_v1.c index ea4a53880..4e629dcfd 100644 --- a/types/wlr_export_dmabuf_v1.c +++ b/types/wlr_export_dmabuf_v1.c @@ -85,11 +85,11 @@ static void frame_output_handle_commit(struct wl_listener *listener, attribs.fd[i], size, attribs.offset[i], attribs.stride[i], i); } - time_t tv_sec = event->when->tv_sec; + time_t tv_sec = event->when.tv_sec; uint32_t tv_sec_hi = (sizeof(tv_sec) > 4) ? tv_sec >> 32 : 0; uint32_t tv_sec_lo = tv_sec & 0xFFFFFFFF; zwlr_export_dmabuf_frame_v1_send_ready(frame->resource, - tv_sec_hi, tv_sec_lo, event->when->tv_nsec); + tv_sec_hi, tv_sec_lo, event->when.tv_nsec); frame_destroy(frame); } diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index c49ed6bdf..58e8dc8ba 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -334,7 +334,7 @@ static void frame_handle_output_commit(struct wl_listener *listener, zwlr_screencopy_frame_v1_send_flags(frame->resource, 0); frame_send_damage(frame); - frame_send_ready(frame, event->when); + frame_send_ready(frame, &event->when); frame_destroy(frame); return;