diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 85f69636..e70650d1 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -71,6 +71,11 @@ CCompositor::CCompositor() { wlr_renderer_init_wl_display(m_sWLRRenderer, m_sWLDisplay); + if (wlr_renderer_get_dmabuf_texture_formats(m_sWLRRenderer) != NULL) { + wlr_drm_create(m_sWLDisplay, m_sWLRRenderer); + m_sWLRDmabuf = wlr_linux_dmabuf_v1_create(m_sWLDisplay, m_sWLRRenderer); + } + m_sWLRAllocator = wlr_allocator_autocreate(m_sWLRBackend, m_sWLRRenderer); if (!m_sWLRAllocator) { @@ -141,6 +146,12 @@ CCompositor::CCompositor() { m_sWLRToplevelMgr = wlr_foreign_toplevel_manager_v1_create(m_sWLDisplay); + m_sWRLDRMLeaseMgr = wlr_drm_lease_v1_manager_create(m_sWLDisplay, m_sWLRBackend); + if (!m_sWRLDRMLeaseMgr) { + Debug::log(CRIT, "Failed to create wlr_drm_lease_v1_manager"); + Debug::log(INFO, "VR will not be available"); + } + m_sWLRTabletManager = wlr_tablet_v2_create(m_sWLDisplay); m_sWLRForeignRegistry = wlr_xdg_foreign_registry_create(m_sWLDisplay); @@ -211,6 +222,9 @@ void CCompositor::initAllSignals() { addWLSignal(&m_sWLRIMEMgr->events.input_method, &Events::listen_newIME, m_sWLRIMEMgr, "IMEMgr"); addWLSignal(&m_sWLRTextInputMgr->events.text_input, &Events::listen_newTextInput, m_sWLRTextInputMgr, "TextInputMgr"); + if(m_sWRLDRMLeaseMgr) + addWLSignal(&m_sWRLDRMLeaseMgr->events.request, &Events::listen_leaseRequest, &m_sWRLDRMLeaseMgr, "DRM"); + if (m_sWLRSession) addWLSignal(&m_sWLRSession->events.active, &Events::listen_sessionActive, m_sWLRSession, "Session"); } diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 1b285d3b..2a8c7fcb 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -38,6 +38,8 @@ public: wlr_compositor* m_sWLRCompositor; wlr_subcompositor* m_sWLRSubCompositor; wlr_data_device_manager* m_sWLRDataDevMgr; + wlr_drm* m_sWRLDRM; + wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr; wlr_xdg_activation_v1* m_sWLRXDGActivation; wlr_output_layout* m_sWLROutputLayout; wlr_idle* m_sWLRIdle; diff --git a/src/events/Events.hpp b/src/events/Events.hpp index 5c4ba2d9..a7c8c5bc 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -12,6 +12,9 @@ namespace Events { LISTENER(change); LISTENER(newOutput); + // DRM events + LISTENER(leaseRequest); + // Layer events LISTENER(newLayerSurface); DYNLISTENFUNC(destroyLayerSurface); diff --git a/src/events/Misc.cpp b/src/events/Misc.cpp index e6e29f11..4e2f532c 100644 --- a/src/events/Misc.cpp +++ b/src/events/Misc.cpp @@ -25,6 +25,15 @@ void Events::listener_outputMgrTest(wl_listener* listener, void* data) { g_pHyprRenderer->outputMgrApplyTest(CONFIG, true); } +void Events::listener_leaseRequest(wl_listener* listener, void* data) { + const auto REQUEST = (wlr_drm_lease_request_v1*)data; + struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST); + if (!lease) { + Debug::log(ERR, "Failed to grant lease request!"); + wlr_drm_lease_request_v1_reject(REQUEST); + } +} + void Events::listener_requestSetPrimarySel(wl_listener* listener, void* data) { const auto EVENT = (wlr_seat_request_set_primary_selection_event*)data; wlr_seat_set_primary_selection(g_pCompositor->m_sSeat.seat, EVENT->source, EVENT->serial); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 7359e6b7..84a571a8 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -56,6 +56,14 @@ void CMonitor::onConnect(bool noRule) { return; } + if (output->non_desktop) { + Debug::log(LOG, "Not configuring non-desktop output"); + if (g_pCompositor->m_sWRLDRMLeaseMgr) { + wlr_drm_lease_v1_manager_offer_output(g_pCompositor->m_sWRLDRMLeaseMgr, output); + } + return; + } + if (!m_bRenderingInitPassed) { wlr_output_init_render(output, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer); m_bRenderingInitPassed = true; diff --git a/src/includes.hpp b/src/includes.hpp index de21d7c7..6f5c91b3 100644 --- a/src/includes.hpp +++ b/src/includes.hpp @@ -37,12 +37,15 @@ extern "C" { #include #include +#include #include #include #include #include #include #include +#include +#include #include #include #include