Skip to content

Commit

Permalink
Support for wlr_drm_lease_v1 (#2083)
Browse files Browse the repository at this point in the history
* Try to make DRM leasing work

* Attempt number two to make this work

* Fix logging and formatting

* Run uncrustify
  • Loading branch information
CharlieQLe authored Dec 29, 2023
1 parent a1d2607 commit 76765ca
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/wayfire/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class compositor_core_t : public wf::object_base_t, public signal::provider_t
wlr_presentation *presentation;
wlr_primary_selection_v1_device_manager *primary_selection_v1;
wlr_viewporter *viewporter;
wlr_drm_lease_v1_manager *drm_v1;

wlr_xdg_foreign_registry *foreign_registry;
wlr_xdg_foreign_v1 *foreign_v1;
Expand Down
1 change: 1 addition & 0 deletions src/api/wayfire/nonstd/wlroots-full.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extern "C"
#endif
#include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_xdg_output_v1.h>
#include <wlr/types/wlr_drm_lease_v1.h>

// Input
#include <wlr/types/wlr_seat.h>
Expand Down
1 change: 1 addition & 0 deletions src/api/wayfire/nonstd/wlroots.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C"
struct wlr_text_input_manager_v3;
struct wlr_presentation;
struct wlr_primary_selection_v1_device_manager;
struct wlr_drm_lease_v1_manager;

struct wlr_xdg_foreign_v1;
struct wlr_xdg_foreign_v2;
Expand Down
1 change: 1 addition & 0 deletions src/core/core-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class compositor_core_impl_t : public compositor_core_t
wf::wl_listener_wrapper input_inhibit_deactivated;
wf::wl_listener_wrapper pointer_constraint_added;
wf::wl_listener_wrapper idle_inhibitor_created;
wf::wl_listener_wrapper drm_lease_request;
std::shared_ptr<scene::root_node_t> scene_root;

compositor_state_t state = compositor_state_t::UNKNOWN;
Expand Down
17 changes: 17 additions & 0 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ void wf::compositor_core_impl_t::init()
protocols.export_dmabuf = wlr_export_dmabuf_manager_v1_create(display);
protocols.output_manager = wlr_xdg_output_manager_v1_create(display,
output_layout->get_handle());
protocols.drm_v1 = wlr_drm_lease_v1_manager_create(display, backend);
drm_lease_request.set_callback([&] (void *data)
{
auto req = static_cast<wlr_drm_lease_request_v1*>(data);
struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req);
if (!lease)
{
wlr_drm_lease_request_v1_reject(req);
}
});
if (protocols.drm_v1)
{
drm_lease_request.connect(&protocols.drm_v1->events.request);
} else
{
LOGE("Failed to create wlr_drm_lease_device_v1; VR will not be available!");
}

/* input-inhibit setup */
protocols.input_inhibit = wlr_input_inhibit_manager_create(display);
Expand Down
12 changes: 12 additions & 0 deletions src/core/output-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,18 @@ class output_layout_t::impl
LOGI("new output: ", output->name,
" (\"", output->make, " ", output->model, " ", output->serial, "\")");

if (output->non_desktop)
{
LOGD("Non-desktop output ", output->name, " found");
if (get_core().protocols.drm_v1)
{
LOGD("Drm lease offered to ", output->name);
wlr_drm_lease_v1_manager_offer_output(get_core().protocols.drm_v1, output);
}

return;
}

if (!wlr_output_init_render(output,
get_core().allocator, get_core().renderer))
{
Expand Down

0 comments on commit 76765ca

Please sign in to comment.