From 2693e78109974a4b0a4434f9000207072ced3ba8 Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Sat, 29 Jul 2023 11:26:39 +0100 Subject: [PATCH] examples: switch to new frame scheduling --- examples/fullscreen-shell.c | 12 ++++++++++-- examples/output-layers.c | 12 ++++++++++-- examples/output-layout.c | 10 +++++++++- examples/pointer.c | 10 +++++++++- examples/rotation.c | 10 +++++++++- examples/simple.c | 11 ++++++++++- examples/tablet.c | 11 ++++++++++- examples/touch.c | 11 ++++++++++- 8 files changed, 77 insertions(+), 10 deletions(-) diff --git a/examples/fullscreen-shell.c b/examples/fullscreen-shell.c index c12f126e9..2850f7336 100644 --- a/examples/fullscreen-shell.c +++ b/examples/fullscreen-shell.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,7 @@ struct fullscreen_output { struct wl_list link; struct fullscreen_server *server; struct wlr_output *wlr_output; + struct wlr_frame_scheduler *frame_scheduler; struct wlr_surface *surface; struct wl_listener surface_destroy; @@ -113,6 +115,8 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { wlr_render_pass_submit(pass); wlr_output_commit_state(output->wlr_output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(output->frame_scheduler); } static void output_set_surface(struct fullscreen_output *output, @@ -156,10 +160,12 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { struct fullscreen_output *output = calloc(1, sizeof(*output)); output->wlr_output = wlr_output; output->server = server; - output->frame.notify = output_handle_frame; - wl_signal_add(&wlr_output->events.frame, &output->frame); wl_list_insert(&server->outputs, &output->link); + output->frame_scheduler = wlr_frame_scheduler_autocreate(wlr_output); + output->frame.notify = output_handle_frame; + wl_signal_add(&output->frame_scheduler->events.frame, &output->frame); + wlr_output_layout_add_auto(server->output_layout, wlr_output); wlr_output_create_global(wlr_output, server->wl_display); @@ -172,6 +178,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { } wlr_output_commit_state(wlr_output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(output->frame_scheduler); } static void server_handle_present_surface(struct wl_listener *listener, diff --git a/examples/output-layers.c b/examples/output-layers.c index d7fadac3a..90f750f3d 100644 --- a/examples/output-layers.c +++ b/examples/output-layers.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ struct output { struct wl_list link; struct server *server; struct wlr_output *wlr_output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_list surfaces; struct wl_listener frame; @@ -157,6 +159,8 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { } wl_array_release(&layers_arr); + + wlr_frame_scheduler_schedule_frame(output->frame_scheduler); } static void server_handle_new_output(struct wl_listener *listener, void *data) { @@ -169,10 +173,12 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { output->wlr_output = wlr_output; output->server = server; wl_list_init(&output->surfaces); - output->frame.notify = output_handle_frame; - wl_signal_add(&wlr_output->events.frame, &output->frame); wl_list_insert(&server->outputs, &output->link); + output->frame_scheduler = wlr_frame_scheduler_autocreate(wlr_output); + output->frame.notify = output_handle_frame; + wl_signal_add(&output->frame_scheduler->events.frame, &output->frame); + struct wlr_output_state state; wlr_output_state_init(&state); wlr_output_state_set_enabled(&state, true); @@ -183,6 +189,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { wlr_output_commit_state(wlr_output, &state); wlr_output_state_finish(&state); + wlr_frame_scheduler_schedule_frame(output->frame_scheduler); + wlr_output_create_global(wlr_output, server->wl_display); } diff --git a/examples/output-layout.c b/examples/output-layout.c index 3a3eeb24f..8243e09a5 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ struct sample_state { struct sample_output { struct sample_state *sample; struct wlr_output *output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_listener frame; struct wl_listener destroy; }; @@ -143,6 +145,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_render_pass_submit(pass); wlr_output_commit_state(wlr_output, &output_state); wlr_output_state_finish(&output_state); + + wlr_frame_scheduler_schedule_frame(output->frame_scheduler); } static void update_velocities(struct sample_state *sample, @@ -157,6 +161,7 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { wlr_output_layout_remove(sample->layout, sample_output->output); wl_list_remove(&sample_output->frame.link); wl_list_remove(&sample_output->destroy.link); + wlr_frame_scheduler_destroy(sample_output->frame_scheduler); free(sample_output); } @@ -170,7 +175,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { wlr_output_layout_add_auto(sample->layout, output); sample_output->output = output; sample_output->sample = sample; - wl_signal_add(&output->events.frame, &sample_output->frame); + sample_output->frame_scheduler = wlr_frame_scheduler_autocreate(output); + wl_signal_add(&sample_output->frame_scheduler->events.frame, &sample_output->frame); sample_output->frame.notify = output_frame_notify; wl_signal_add(&output->events.destroy, &sample_output->destroy); sample_output->destroy.notify = output_remove_notify; @@ -184,6 +190,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { } wlr_output_commit_state(output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void keyboard_key_notify(struct wl_listener *listener, void *data) { diff --git a/examples/pointer.c b/examples/pointer.c index fed37a5b3..3518c0e82 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,7 @@ struct touch_point { struct sample_output { struct sample_state *state; struct wlr_output *output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_listener frame; struct wl_listener destroy; }; @@ -115,6 +117,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_render_pass_submit(pass); wlr_output_commit_state(wlr_output, &output_state); wlr_output_state_finish(&output_state); + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void handle_cursor_motion(struct wl_listener *listener, void *data) { @@ -255,6 +259,7 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { wlr_output_layout_remove(sample->layout, sample_output->output); wl_list_remove(&sample_output->frame.link); wl_list_remove(&sample_output->destroy.link); + wlr_frame_scheduler_destroy(sample_output->frame_scheduler); free(sample_output); } @@ -267,7 +272,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = calloc(1, sizeof(*sample_output)); sample_output->output = output; sample_output->state = sample; - wl_signal_add(&output->events.frame, &sample_output->frame); + sample_output->frame_scheduler = wlr_frame_scheduler_autocreate(output); + wl_signal_add(&sample_output->frame_scheduler->events.frame, &sample_output->frame); sample_output->frame.notify = output_frame_notify; wl_signal_add(&output->events.destroy, &sample_output->destroy); sample_output->destroy.notify = output_remove_notify; @@ -282,6 +288,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { } wlr_output_commit_state(output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } diff --git a/examples/rotation.c b/examples/rotation.c index 351973f61..e183e462c 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ struct sample_state { struct sample_output { struct sample_state *sample; struct wlr_output *output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_listener frame; struct wl_listener destroy; float x_offs, y_offs; @@ -93,6 +95,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { sample_output->y_offs = 0; } sample->last_frame = now; + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void update_velocities(struct sample_state *sample, @@ -108,6 +112,7 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = wl_container_of(listener, sample_output, destroy); wl_list_remove(&sample_output->frame.link); wl_list_remove(&sample_output->destroy.link); + wlr_frame_scheduler_destroy(sample_output->frame_scheduler); free(sample_output); } @@ -123,7 +128,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { sample_output->output = output; sample_output->sample = sample; - wl_signal_add(&output->events.frame, &sample_output->frame); + sample_output->frame_scheduler = wlr_frame_scheduler_autocreate(output); + wl_signal_add(&sample_output->frame_scheduler->events.frame, &sample_output->frame); sample_output->frame.notify = output_frame_notify; wl_signal_add(&output->events.destroy, &sample_output->destroy); sample_output->destroy.notify = output_remove_notify; @@ -139,6 +145,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { } wlr_output_commit_state(output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void keyboard_key_notify(struct wl_listener *listener, void *data) { diff --git a/examples/simple.c b/examples/simple.c index 81ed2e0e9..2026eba2b 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ struct sample_state { struct sample_output { struct sample_state *sample; struct wlr_output *output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_listener frame; struct wl_listener destroy; }; @@ -78,6 +80,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_output_commit_state(wlr_output, &state); wlr_output_state_finish(&state); sample->last_frame = now; + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void output_remove_notify(struct wl_listener *listener, void *data) { @@ -86,6 +90,7 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { wlr_log(WLR_DEBUG, "Output removed"); wl_list_remove(&sample_output->frame.link); wl_list_remove(&sample_output->destroy.link); + wlr_frame_scheduler_destroy(sample_output->frame_scheduler); free(sample_output); } @@ -99,7 +104,9 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = calloc(1, sizeof(*sample_output)); sample_output->output = output; sample_output->sample = sample; - wl_signal_add(&output->events.frame, &sample_output->frame); + + sample_output->frame_scheduler = wlr_frame_scheduler_autocreate(output); + wl_signal_add(&sample_output->frame_scheduler->events.frame, &sample_output->frame); sample_output->frame.notify = output_frame_notify; wl_signal_add(&output->events.destroy, &sample_output->destroy); sample_output->destroy.notify = output_remove_notify; @@ -113,6 +120,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { } wlr_output_commit_state(output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void keyboard_key_notify(struct wl_listener *listener, void *data) { diff --git a/examples/tablet.c b/examples/tablet.c index 8f0754df1..839ddf709 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +67,7 @@ struct tablet_pad_state { struct sample_output { struct sample_state *sample; struct wlr_output *output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_listener frame; struct wl_listener destroy; }; @@ -160,6 +162,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_output_commit_state(wlr_output, &output_state); wlr_output_state_finish(&output_state); sample->last_frame = now; + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void tablet_tool_axis_notify(struct wl_listener *listener, void *data) { @@ -261,6 +265,7 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = wl_container_of(listener, sample_output, destroy); wl_list_remove(&sample_output->frame.link); wl_list_remove(&sample_output->destroy.link); + wlr_frame_scheduler_destroy(sample_output->frame_scheduler); free(sample_output); } @@ -273,7 +278,9 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = calloc(1, sizeof(*sample_output)); sample_output->output = output; sample_output->sample = sample; - wl_signal_add(&output->events.frame, &sample_output->frame); + + sample_output->frame_scheduler = wlr_frame_scheduler_autocreate(output); + wl_signal_add(&sample_output->frame_scheduler->events.frame, &sample_output->frame); sample_output->frame.notify = output_frame_notify; wl_signal_add(&output->events.destroy, &sample_output->destroy); sample_output->destroy.notify = output_remove_notify; @@ -287,6 +294,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { } wlr_output_commit_state(output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void keyboard_key_notify(struct wl_listener *listener, void *data) { diff --git a/examples/touch.c b/examples/touch.c index e1bd73818..7511eee36 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ struct touch_state { struct sample_output { struct sample_state *sample; struct wlr_output *output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_listener frame; struct wl_listener destroy; }; @@ -96,6 +98,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { wlr_output_commit_state(wlr_output, &output_state); wlr_output_state_finish(&output_state); sample->last_frame = now; + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void touch_down_notify(struct wl_listener *listener, void *data) { @@ -164,6 +168,7 @@ static void output_remove_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = wl_container_of(listener, sample_output, destroy); wl_list_remove(&sample_output->frame.link); wl_list_remove(&sample_output->destroy.link); + wlr_frame_scheduler_destroy(sample_output->frame_scheduler); free(sample_output); } @@ -176,7 +181,9 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = calloc(1, sizeof(*sample_output)); sample_output->output = output; sample_output->sample = sample; - wl_signal_add(&output->events.frame, &sample_output->frame); + + sample_output->frame_scheduler = wlr_frame_scheduler_autocreate(output); + wl_signal_add(&sample_output->frame_scheduler->events.frame, &sample_output->frame); sample_output->frame.notify = output_frame_notify; wl_signal_add(&output->events.destroy, &sample_output->destroy); sample_output->destroy.notify = output_remove_notify; @@ -190,6 +197,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { } wlr_output_commit_state(output, &state); wlr_output_state_finish(&state); + + wlr_frame_scheduler_schedule_frame(sample_output->frame_scheduler); } static void keyboard_key_notify(struct wl_listener *listener, void *data) {