Implement the drm-lease-v1 protocol
Some checks failed
Continuous integration build / compile (clang, alpine:edge, disabled) (push) Has been cancelled
Continuous integration build / compile (clang, alpine:edge, enabled) (push) Has been cancelled
Continuous integration build / compile (clang, archlinux:base-devel, disabled) (push) Has been cancelled
Continuous integration build / compile (clang, archlinux:base-devel, enabled) (push) Has been cancelled
Continuous integration build / compile (gcc, alpine:edge, disabled) (push) Has been cancelled
Continuous integration build / compile (gcc, alpine:edge, enabled) (push) Has been cancelled
Continuous integration build / compile (gcc, archlinux:base-devel, disabled) (push) Has been cancelled
Continuous integration build / compile (gcc, archlinux:base-devel, enabled) (push) Has been cancelled
Continuous integration build / format (push) Has been cancelled
Continuous integration build / scan-build (push) Has been cancelled

This commit is contained in:
Yuxuan Shui 2026-01-04 20:27:18 +00:00 committed by Simon Ser
parent 73bf1c8bd6
commit dcd64ae48b
3 changed files with 46 additions and 0 deletions

29
cage.c
View file

@ -19,6 +19,7 @@
#include <unistd.h> #include <unistd.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/config.h>
#include <wlr/render/allocator.h> #include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
@ -80,6 +81,19 @@ handle_display_destroy(struct wl_listener *listener, void *data)
server->terminated = true; server->terminated = true;
} }
#if WLR_HAS_DRM_BACKEND
static void
handle_drm_lease_request(struct wl_listener *listener, void *data)
{
struct wlr_drm_lease_request_v1 *req = data;
struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req);
if (!lease) {
wlr_log(WLR_ERROR, "Failed to grant lease");
wlr_drm_lease_request_v1_reject(req);
}
}
#endif
static int static int
sigchld_handler(int fd, uint32_t mask, void *data) sigchld_handler(int fd, uint32_t mask, void *data)
{ {
@ -497,6 +511,16 @@ main(int argc, char *argv[])
server.output_manager_test.notify = handle_output_manager_test; server.output_manager_test.notify = handle_output_manager_test;
wl_signal_add(&server.output_manager_v1->events.test, &server.output_manager_test); wl_signal_add(&server.output_manager_v1->events.test, &server.output_manager_test);
#if WLR_HAS_DRM_BACKEND
server.drm_lease_v1 = wlr_drm_lease_v1_manager_create(server.wl_display, server.backend);
if (server.drm_lease_v1) {
server.drm_lease_request.notify = handle_drm_lease_request;
wl_signal_add(&server.drm_lease_v1->events.request, &server.drm_lease_request);
} else {
wlr_log(WLR_INFO, "Failed to create wlr_drm_lease_manager_v1");
}
#endif
if (!wlr_gamma_control_manager_v1_create(server.wl_display)) { if (!wlr_gamma_control_manager_v1_create(server.wl_display)) {
wlr_log(WLR_ERROR, "Unable to create the gamma control manager"); wlr_log(WLR_ERROR, "Unable to create the gamma control manager");
ret = 1; ret = 1;
@ -612,6 +636,11 @@ main(int argc, char *argv[])
#endif #endif
wl_display_destroy_clients(server.wl_display); wl_display_destroy_clients(server.wl_display);
#if WLR_HAS_DRM_BACKEND
if (server.drm_lease_v1) {
wl_list_remove(&server.drm_lease_request.link);
}
#endif
wl_list_remove(&server.new_virtual_pointer.link); wl_list_remove(&server.new_virtual_pointer.link);
wl_list_remove(&server.new_virtual_keyboard.link); wl_list_remove(&server.new_virtual_keyboard.link);
wl_list_remove(&server.output_manager_apply.link); wl_list_remove(&server.output_manager_apply.link);

View file

@ -237,6 +237,16 @@ handle_new_output(struct wl_listener *listener, void *data)
struct cg_server *server = wl_container_of(listener, server, new_output); struct cg_server *server = wl_container_of(listener, server, new_output);
struct wlr_output *wlr_output = data; struct wlr_output *wlr_output = data;
if (wlr_output->non_desktop) {
wlr_log(WLR_DEBUG, "Not configuring non-desktop output: %s", wlr_output->name);
#if WLR_HAS_DRM_BACKEND
if (server->drm_lease_v1) {
wlr_drm_lease_v1_manager_offer_output(server->drm_lease_v1, wlr_output);
}
#endif
return;
}
if (!wlr_output_init_render(wlr_output, server->allocator, server->renderer)) { if (!wlr_output_init_render(wlr_output, server->allocator, server->renderer)) {
wlr_log(WLR_ERROR, "Failed to initialize output rendering"); wlr_log(WLR_ERROR, "Failed to initialize output rendering");
return; return;

View file

@ -4,6 +4,8 @@
#include "config.h" #include "config.h"
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/config.h>
#include <wlr/types/wlr_drm_lease_v1.h>
#include <wlr/types/wlr_idle_inhibit_v1.h> #include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h> #include <wlr/types/wlr_idle_notify_v1.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
@ -59,6 +61,11 @@ struct cg_server {
struct wl_listener output_manager_apply; struct wl_listener output_manager_apply;
struct wl_listener output_manager_test; struct wl_listener output_manager_test;
#if WLR_HAS_DRM_BACKEND
struct wlr_drm_lease_v1_manager *drm_lease_v1;
struct wl_listener drm_lease_request;
#endif
struct wlr_relative_pointer_manager_v1 *relative_pointer_manager; struct wlr_relative_pointer_manager_v1 *relative_pointer_manager;
struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;