aboutsummaryrefslogtreecommitdiff
path: root/examples/pointer.c
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2021-09-24 09:34:51 -0400
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-11-18 09:37:57 -0500
commit6d6e70b9e0e40b6d38ba9276127b869bae893d43 (patch)
tree7a459cc6e4283fd3783e66d43bc5cfd0a21b945a /examples/pointer.c
parent142d10e591c0f349843f718d87b44c8ba2b33476 (diff)
examples: init wlr_output with allocator and renderer
Diffstat (limited to 'examples/pointer.c')
-rw-r--r--examples/pointer.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/pointer.c b/examples/pointer.c
index 1abdf1cf..bf3701a4 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -9,6 +9,7 @@
#include <wayland-server-core.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
+#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_keyboard.h>
@@ -24,6 +25,8 @@
struct sample_state {
struct wl_display *display;
struct compositor_state *compositor;
+ struct wlr_renderer *renderer;
+ struct wlr_allocator *allocator;
struct wlr_xcursor_manager *xcursor_manager;
struct wlr_cursor *cursor;
double cur_x, cur_y;
@@ -95,7 +98,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
struct sample_output *sample_output = wl_container_of(listener, sample_output, frame);
struct sample_state *state = sample_output->state;
struct wlr_output *wlr_output = sample_output->output;
- struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend);
+ struct wlr_renderer *renderer = state->renderer;
assert(renderer);
wlr_output_attach_render(wlr_output, NULL);
@@ -250,6 +253,9 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
static void new_output_notify(struct wl_listener *listener, void *data) {
struct wlr_output *output = data;
struct sample_state *sample = wl_container_of(listener, sample, new_output);
+
+ wlr_output_init_render(output, sample->allocator, sample->renderer);
+
struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
sample_output->output = output;
sample_output->state = sample;
@@ -331,6 +337,10 @@ int main(int argc, char *argv[]) {
if (!wlr) {
exit(1);
}
+
+ state.renderer = wlr_renderer_autocreate(wlr);
+ state.allocator = wlr_allocator_autocreate(wlr, state.renderer);
+
state.cursor = wlr_cursor_create();
state.layout = wlr_output_layout_create();
wlr_cursor_attach_output_layout(state.cursor, state.layout);