diff --git a/examples/cairo-buffer.c b/examples/cairo-buffer.c index 688b99103..0bee666f3 100644 --- a/examples/cairo-buffer.c +++ b/examples/cairo-buffer.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -104,10 +105,11 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { struct output *output = calloc(1, sizeof(struct output)); output->wlr = wlr_output; output->server = server; - output->frame.notify = output_handle_frame; - wl_signal_add(&wlr_output->events.frame, &output->frame); output->scene_output = wlr_scene_output_create(server->scene, wlr_output); + output->scene_output->frame_scheduler = wlr_frame_scheduler_autocreate(wlr_output); + output->frame.notify = output_handle_frame; + wl_signal_add(&output->scene_output->frame_scheduler->frame, &output->frame); struct wlr_output_state state; wlr_output_state_init(&state); diff --git a/examples/fullscreen-shell.c b/examples/fullscreen-shell.c index aa55adb8f..5e06a1d3a 100644 --- a/examples/fullscreen-shell.c +++ b/examples/fullscreen-shell.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,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; @@ -158,10 +160,12 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { calloc(1, sizeof(struct fullscreen_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->frame, &output->frame); + wlr_output_layout_add_auto(server->output_layout, wlr_output); wlr_output_create_global(wlr_output); diff --git a/examples/output-layers.c b/examples/output-layers.c index cec3b50b4..28b476161 100644 --- a/examples/output-layers.c +++ b/examples/output-layers.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,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; @@ -170,10 +172,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->frame, &output->frame); + struct wlr_output_state state; wlr_output_state_init(&state); wlr_output_state_set_enabled(&state, true); diff --git a/examples/output-layout.c b/examples/output-layout.c index 99d403e0d..399f789f7 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,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; }; @@ -172,7 +174,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->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; diff --git a/examples/pointer.c b/examples/pointer.c index 869865035..5eeb25030 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,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; }; @@ -269,7 +271,8 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = calloc(1, sizeof(struct 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->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; diff --git a/examples/rotation.c b/examples/rotation.c index e092a3634..80b102310 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,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; @@ -125,7 +127,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->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; diff --git a/examples/scene-graph.c b/examples/scene-graph.c index 7b7e14d66..75c4710b3 100644 --- a/examples/scene-graph.c +++ b/examples/scene-graph.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -76,10 +77,11 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) { calloc(1, sizeof(struct output)); output->wlr = wlr_output; output->server = server; - output->frame.notify = output_handle_frame; - wl_signal_add(&wlr_output->events.frame, &output->frame); output->scene_output = wlr_scene_output_create(server->scene, wlr_output); + output->scene_output->frame_scheduler = wlr_frame_scheduler_autocreate(wlr_output); + output->frame.notify = output_handle_frame; + wl_signal_add(&output->scene_output->frame_scheduler->frame, &output->frame); struct wlr_output_state state; wlr_output_state_init(&state); diff --git a/examples/simple.c b/examples/simple.c index 781ee0e9f..35cd1343c 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,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; }; @@ -101,7 +103,9 @@ static void new_output_notify(struct wl_listener *listener, void *data) { calloc(1, sizeof(struct 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->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; diff --git a/examples/tablet.c b/examples/tablet.c index c992e0a4b..229e7e4cb 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -10,6 +10,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; }; @@ -273,7 +275,9 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = calloc(1, sizeof(struct 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->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; diff --git a/examples/touch.c b/examples/touch.c index f32b5bbac..82a42ed03 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,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; }; @@ -178,7 +180,9 @@ static void new_output_notify(struct wl_listener *listener, void *data) { struct sample_output *sample_output = calloc(1, sizeof(struct 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->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; diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 61c089282..41ad807ba 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,7 @@ struct tinywl_output { struct wl_list link; struct tinywl_server *server; struct wlr_output *wlr_output; + struct wlr_frame_scheduler *frame_scheduler; struct wl_listener frame; struct wl_listener request_state; struct wl_listener destroy; @@ -621,9 +623,12 @@ static void server_new_output(struct wl_listener *listener, void *data) { output->wlr_output = wlr_output; output->server = server; + /* Creates a frame scheduler, which is responsible for telling us when to render. */ + output->frame_scheduler = wlr_frame_scheduler_autocreate(wlr_output); + /* Sets up a listener for the frame event. */ output->frame.notify = output_frame; - wl_signal_add(&wlr_output->events.frame, &output->frame); + wl_signal_add(&output->frame_scheduler->frame, &output->frame); /* Sets up a listener for the state request event. */ output->request_state.notify = output_request_state; @@ -645,6 +650,10 @@ static void server_new_output(struct wl_listener *listener, void *data) { * output (such as DPI, scale factor, manufacturer, etc). */ wlr_output_layout_add_auto(server->output_layout, wlr_output); + + /* Make the scene aware of the frame scheduler so that it can trigger frames. */ + struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(server->scene, wlr_output); + scene_output->frame_scheduler = output->frame_scheduler; } static void xdg_toplevel_map(struct wl_listener *listener, void *data) {