Merge branch 'commit_timing_v1' into 'master'

commit-timing-v1: new protocol implementation

See merge request wlroots/wlroots!4617
This commit is contained in:
Sergio Gómez 2026-02-03 17:04:10 +00:00
commit d04d3dce4d
9 changed files with 575 additions and 0 deletions

View file

@ -6,6 +6,11 @@
static const long NSEC_PER_SEC = 1000000000;
/**
* Get the current time, in nanoseconds.
*/
int64_t get_current_time_nsec(void);
/**
* Get the current time, in milliseconds.
*/

View file

@ -0,0 +1,91 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_TIMING_H
#define WLR_TYPES_WLR_TIMING_H
#include <wlr/types/wlr_compositor.h>
struct wlr_commit_timing_manager_v1_new_timer_event {
struct wlr_commit_timer_v1 *timer;
};
struct wlr_commit_timer_v1_commit {
struct wlr_commit_timer_v1 *timer;
/**
* Commits' wlr_surface pending sequence when locking through
* wlr_surface_lock_pending(). Used to unlock the commit when the 'unlock_timer' goes off.
*/
uint32_t pending_seq;
/**
* Timer for when this commit should be unlocked for presentation.
*/
struct wl_event_source *unlock_source;
struct wl_list link; // wlr_commit_timer_v1::commits
};
struct wlr_commit_timer_v1_state {
uint64_t base_present_nsec;
int32_t refresh;
uint64_t timestamp_nsec; // holds the timestamp for the .set_timestamp protocol request
};
struct wlr_commit_timer_v1 {
struct wlr_commit_timing_manager_v1 *timing_manager;
struct wl_resource *resource;
struct wl_display *wl_display;
struct wlr_addon addon;
struct wlr_surface *surface;
struct wlr_output *output;
struct wlr_commit_timer_v1_state state;
struct {
struct wl_signal destroy;
} events;
struct {
struct wl_listener client_commit;
struct wl_listener output_present;
struct wl_listener output_destroy;
} WLR_PRIVATE;
struct wl_list commits; // wlr_commit_timer_v1_commit.link
struct wl_list scene_link; // wlr_scene.commit_timers
};
struct wlr_commit_timing_manager_v1 {
struct wl_global *global;
struct wl_listener display_destroy;
struct {
struct wl_signal new_timer;
struct wl_signal destroy;
} events;
};
/**
* Set the output from which we will get the refresh cycle timings for this wlr_commit_timer_v1.
*/
void wlr_commit_timer_v1_set_output(struct wlr_commit_timer_v1 *timer, struct wlr_output *output);
/**
* Create the wp_commit_timing_manager_v1_interface global, which can be used by clients to
* set timestamps for surface commit request presentation.
*/
struct wlr_commit_timing_manager_v1 *wlr_commit_timing_manager_v1_create(struct wl_display *display,
uint32_t version);
#endif

View file

@ -104,6 +104,8 @@ struct wlr_scene {
struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;
struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
struct wlr_color_manager_v1 *color_manager_v1;
struct wlr_commit_timing_manager_v1 *commit_timing_manager_v1;
struct wl_list commit_timers; // wlr_commit_timer_v1.scene_link
bool restack_xwayland_surfaces;
@ -112,6 +114,9 @@ struct wlr_scene {
struct wl_listener gamma_control_manager_v1_destroy;
struct wl_listener gamma_control_manager_v1_set_gamma;
struct wl_listener color_manager_v1_destroy;
struct wl_listener commit_timing_manager_v1_destroy;
struct wl_listener commit_timing_manager_v1_new_timer;
struct wl_listener commit_timer_v1_destroy;
enum wlr_scene_debug_damage_option debug_damage_option;
bool direct_scanout;
@ -381,6 +386,12 @@ void wlr_scene_set_gamma_control_manager_v1(struct wlr_scene *scene,
*/
void wlr_scene_set_color_manager_v1(struct wlr_scene *scene, struct wlr_color_manager_v1 *manager);
/**
* Handles commit_timing_manager_v1 for all surfaces and their primary outputs in the scene.
*/
void wlr_scene_set_commit_timing_manager_v1(struct wlr_scene *scene,
struct wlr_commit_timing_manager_v1 *timing_manager);
/**
* Add a node displaying nothing but its children.
*/