|
7 | 7 | #include <unistd.h>
|
8 | 8 | #include <wayland-server-core.h>
|
9 | 9 | #include <wlr/backend.h>
|
| 10 | +#include <wlr/allocator/wlr_allocator.h> |
10 | 11 | #include <wlr/render/wlr_renderer.h>
|
11 | 12 | #include <wlr/types/wlr_cursor.h>
|
12 | 13 | #include <wlr/types/wlr_compositor.h>
|
@@ -34,6 +35,7 @@ struct tinywl_server {
|
34 | 35 | struct wl_display *wl_display;
|
35 | 36 | struct wlr_backend *backend;
|
36 | 37 | struct wlr_renderer *renderer;
|
| 38 | + struct wlr_allocator *allocator; |
37 | 39 |
|
38 | 40 | struct wlr_xdg_shell *xdg_shell;
|
39 | 41 | struct wl_listener new_xdg_surface;
|
@@ -676,6 +678,10 @@ static void server_new_output(struct wl_listener *listener, void *data) {
|
676 | 678 | }
|
677 | 679 | }
|
678 | 680 |
|
| 681 | + /* Give our current allocator to the new output to handle swapchain |
| 682 | + * management. */ |
| 683 | + wlr_output_set_allocator(wlr_output, server->allocator); |
| 684 | + |
679 | 685 | /* Allocates and configures our state for this output */
|
680 | 686 | struct tinywl_output *output =
|
681 | 687 | calloc(1, sizeof(struct tinywl_output));
|
@@ -847,6 +853,12 @@ int main(int argc, char *argv[]) {
|
847 | 853 | server.renderer = wlr_backend_get_renderer(server.backend);
|
848 | 854 | wlr_renderer_init_wl_display(server.renderer, server.wl_display);
|
849 | 855 |
|
| 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 | + |
850 | 862 | /* This creates some hands-off wlroots interfaces. The compositor is
|
851 | 863 | * necessary for clients to allocate surfaces and the data device manager
|
852 | 864 | * handles the clipboard. Each of these wlroots interfaces has room for you
|
|
0 commit comments