drm_lease: move calls to lease manager to the top of createmon() and cleanupmon() to avoid initialising state of outputs or dereferencing

This commit is contained in:
Alex Denes 2026-04-21 17:24:44 +00:00
parent f584a2dead
commit e55349448e
No known key found for this signature in database
GPG Key ID: F92BA85F61F4C173
2 changed files with 30 additions and 27 deletions

View File

@ -3,7 +3,7 @@ Adds support for drm-lease-v1 for embedded displays such as VR headsets
### Download
- [git branch](/caskd/dwl/src/branch/patches/drm_lease)
- [main 2025-06-18](/dwl/dwl-patches/raw/branch/main/patches/drm_lease/drm_lease.patch)
- [main 2026-02-25](/dwl/dwl-patches/raw/branch/main/patches/drm_lease/drm_lease.patch)
### Authors
- [caskd](https://codeberg.org/caskd)
caskd@redxen.eu

View File

@ -1,15 +1,15 @@
From b2adc829556dc2fd357e7aaa630a7a42d150f87b Mon Sep 17 00:00:00 2001
From 155578f30dc91363e7580c3020ad464ab561acd3 Mon Sep 17 00:00:00 2001
From: Micah Gorrell <micah.gorrell@venafi.com>
Date: Fri, 26 May 2023 08:17:20 -0600
Subject: [PATCH] Implemented support for the DRM lease protocol, as needed to
use devices such as VR headsets
---
dwl.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
dwl.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/dwl.c b/dwl.c
index 101a45f..535d532 100644
index 101a45f..4740dfe 100644
--- a/dwl.c
+++ b/dwl.c
@@ -23,6 +23,7 @@
@ -44,18 +44,24 @@ index 101a45f..535d532 100644
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@@ -747,6 +751,10 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_output_layout_remove(output_layout, m->wlr_output);
wlr_scene_output_destroy(m->scene_output);
@@ -727,10 +731,16 @@ cleanup(void)
void
cleanupmon(struct wl_listener *listener, void *data)
{
+ struct wlr_output *wlr_output = data;
Monitor *m = wl_container_of(listener, m, destroy);
LayerSurface *l, *tmp;
size_t i;
+ if (drm_lease_manager) {
+ wlr_drm_lease_v1_manager_withdraw_output (drm_lease_manager, m->wlr_output);
+ if (drm_lease_manager && wlr_output->non_desktop) {
+ wlr_drm_lease_v1_manager_withdraw_output (drm_lease_manager, wlr_output);
+ return;
+ }
+
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
free(m);
@@ -783,6 +791,9 @@ cleanuplisteners(void)
/* m->layers[i] are intentionally not unlinked */
for (i = 0; i < LENGTH(m->layers); i++) {
wl_list_for_each_safe(l, tmp, &m->layers[i], link)
@@ -783,6 +793,9 @@ cleanuplisteners(void)
wl_list_remove(&request_start_drag.link);
wl_list_remove(&start_drag.link);
wl_list_remove(&new_session_lock.link);
@ -65,22 +71,19 @@ index 101a45f..535d532 100644
#ifdef XWAYLAND
wl_list_remove(&new_xwayland_surface.link);
wl_list_remove(&xwayland_ready.link);
@@ -1050,6 +1061,14 @@ createmon(struct wl_listener *listener, void *data)
if (!wlr_output_init_render(wlr_output, alloc, drw))
return;
@@ -1047,6 +1060,11 @@ createmon(struct wl_listener *listener, void *data)
struct wlr_output_state state;
Monitor *m;
+ if (wlr_output->non_desktop) {
+ if (drm_lease_manager) {
+ if (drm_lease_manager && wlr_output->non_desktop) {
+ wlr_drm_lease_v1_manager_offer_output(drm_lease_manager, wlr_output);
+ }
+
+ return;
+ }
+
m = wlr_output->data = ecalloc(1, sizeof(*m));
m->wlr_output = wlr_output;
if (!wlr_output_init_render(wlr_output, alloc, drw))
return;
@@ -2183,6 +2202,16 @@ requestdecorationmode(struct wl_listener *listener, void *data)
@@ -2183,6 +2201,16 @@ requestdecorationmode(struct wl_listener *listener, void *data)
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
@ -97,7 +100,7 @@ index 101a45f..535d532 100644
void
requeststartdrag(struct wl_listener *listener, void *data)
{
@@ -2648,10 +2677,18 @@ setup(void)
@@ -2648,10 +2676,18 @@ setup(void)
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
wl_signal_add(&output_mgr->events.test, &output_mgr_test);
@ -117,5 +120,5 @@ index 101a45f..535d532 100644
/*
* Initialise the XWayland X server.
--
2.53.0
2.54.0