tinywl: Use wlr_output_manager

This commit is contained in:
Alexander Orzechowski 2024-05-05 13:37:29 -04:00
parent bf3ee92741
commit 5a72ea9ac1

View file

@ -8,13 +8,13 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h> #include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_manager.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_pointer.h> #include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_scene.h> #include <wlr/types/wlr_scene.h>
@ -35,8 +35,7 @@ enum tinywl_cursor_mode {
struct tinywl_server { struct tinywl_server {
struct wl_display *wl_display; struct wl_display *wl_display;
struct wlr_backend *backend; struct wlr_backend *backend;
struct wlr_renderer *renderer; struct wlr_output_manager output_manager;
struct wlr_allocator *allocator;
struct wlr_scene *scene; struct wlr_scene *scene;
struct wlr_scene_output_layout *scene_layout; struct wlr_scene_output_layout *scene_layout;
@ -599,9 +598,10 @@ static void server_new_output(struct wl_listener *listener, void *data) {
wl_container_of(listener, server, new_output); wl_container_of(listener, server, new_output);
struct wlr_output *wlr_output = data; struct wlr_output *wlr_output = data;
/* Configures the output created by the backend to use our allocator /* Configures the output created by the backend using the output manager
* and our renderer. Must be done once, before commiting the output */ * to allocate a renderer and a allocator for us. Must be done once,
wlr_output_init_render(wlr_output, server->allocator, server->renderer); * before commiting the output */
wlr_output_manager_init_output(&server->output_manager, wlr_output);
/* The output may be disabled, switch it on. */ /* The output may be disabled, switch it on. */
struct wlr_output_state state; struct wlr_output_state state;
@ -910,28 +910,16 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user /* This is a helper that will automatically create renderers and allocators
* can also specify a renderer using the WLR_RENDERER env var. * for each output. This serves as the bridge between the output and the
* The renderer is responsible for defining the various pixel formats it * backend for rendering.
* supports for shared memory, this configures that for clients. */ */
server.renderer = wlr_renderer_autocreate(server.backend); if (!wlr_output_manager_init(&server.output_manager, server.backend)) {
if (server.renderer == NULL) { wlr_log(WLR_ERROR, "failed to create wlr_output_manager");
wlr_log(WLR_ERROR, "failed to create wlr_renderer");
return 1; return 1;
} }
wlr_renderer_init_wl_display(server.renderer, server.wl_display); wlr_output_manager_init_wl_display(&server.output_manager, server.wl_display);
/* Autocreates an allocator for us.
* The allocator is the bridge between the renderer and the backend. It
* handles the buffer creation, allowing wlroots to render onto the
* screen */
server.allocator = wlr_allocator_autocreate(server.backend,
server.renderer);
if (server.allocator == NULL) {
wlr_log(WLR_ERROR, "failed to create wlr_allocator");
return 1;
}
/* This creates some hands-off wlroots interfaces. The compositor is /* This creates some hands-off wlroots interfaces. The compositor is
* necessary for clients to allocate surfaces, the subcompositor allows to * necessary for clients to allocate surfaces, the subcompositor allows to
@ -1063,10 +1051,8 @@ int main(int argc, char *argv[]) {
wl_display_destroy_clients(server.wl_display); wl_display_destroy_clients(server.wl_display);
wlr_scene_node_destroy(&server.scene->tree.node); wlr_scene_node_destroy(&server.scene->tree.node);
wlr_xcursor_manager_destroy(server.cursor_mgr); wlr_xcursor_manager_destroy(server.cursor_mgr);
wlr_cursor_destroy(server.cursor);
wlr_allocator_destroy(server.allocator);
wlr_renderer_destroy(server.renderer);
wlr_backend_destroy(server.backend); wlr_backend_destroy(server.backend);
wlr_output_manager_finish(&server.output_manager);
wl_display_destroy(server.wl_display); wl_display_destroy(server.wl_display);
return 0; return 0;
} }