Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit b5169f3

Browse files
committed
tinywl: create allocator and set it to wlr_output
1 parent 20d86bc commit b5169f3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tinywl/tinywl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <unistd.h>
88
#include <wayland-server-core.h>
99
#include <wlr/backend.h>
10+
#include <wlr/allocator/wlr_allocator.h>
1011
#include <wlr/render/wlr_renderer.h>
1112
#include <wlr/types/wlr_cursor.h>
1213
#include <wlr/types/wlr_compositor.h>
@@ -34,6 +35,7 @@ struct tinywl_server {
3435
struct wl_display *wl_display;
3536
struct wlr_backend *backend;
3637
struct wlr_renderer *renderer;
38+
struct wlr_allocator *allocator;
3739

3840
struct wlr_xdg_shell *xdg_shell;
3941
struct wl_listener new_xdg_surface;
@@ -676,6 +678,10 @@ static void server_new_output(struct wl_listener *listener, void *data) {
676678
}
677679
}
678680

681+
/* Give our current allocator to the new output to handle swapchain
682+
* management. */
683+
wlr_output_set_allocator(wlr_output, server->allocator);
684+
679685
/* Allocates and configures our state for this output */
680686
struct tinywl_output *output =
681687
calloc(1, sizeof(struct tinywl_output));
@@ -847,6 +853,12 @@ int main(int argc, char *argv[]) {
847853
server.renderer = wlr_backend_get_renderer(server.backend);
848854
wlr_renderer_init_wl_display(server.renderer, server.wl_display);
849855

856+
/* The allocator is the bridge between the renderer and the backend.
857+
* It handles the buffer managment between the two, allowing wlroots
858+
* to render onto the screen */
859+
server.allocator = wlr_allocator_autocreate(server.backend,
860+
server.renderer);
861+
850862
/* This creates some hands-off wlroots interfaces. The compositor is
851863
* necessary for clients to allocate surfaces and the data device manager
852864
* handles the clipboard. Each of these wlroots interfaces has room for you

0 commit comments

Comments
 (0)