diff --git a/include/sway/server.h b/include/sway/server.h index 3a5670d9..f3522a49 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,9 @@ struct sway_server { struct wl_listener xdg_decoration; struct wl_list xdg_decorations; // sway_xdg_decoration::link + struct wlr_drm_lease_v1_manager *drm_lease_manager; + struct wl_listener drm_lease_request; + struct wlr_presentation *presentation; struct wlr_pointer_constraints_v1 *pointer_constraints; diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 2f2ab4bc..a980e958 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -4,8 +4,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -836,7 +838,17 @@ static void handle_present(struct wl_listener *listener, void *data) { void handle_new_output(struct wl_listener *listener, void *data) { struct sway_server *server = wl_container_of(listener, server, new_output); struct wlr_output *wlr_output = data; - sway_log(SWAY_DEBUG, "New output %p: %s", wlr_output, wlr_output->name); + sway_log(SWAY_DEBUG, "New output %p: %s (non-desktop: %d)", + wlr_output, wlr_output->name, wlr_output->non_desktop); + + if (wlr_output->non_desktop) { + sway_log(SWAY_DEBUG, "Not configuring non-desktop output"); + if (server->drm_lease_manager) { + wlr_drm_lease_v1_manager_offer_output(server->drm_lease_manager, + wlr_output); + } + return; + } struct sway_output *output = output_create(wlr_output); if (!output) { diff --git a/sway/server.c b/sway/server.c index 2e5ab104..b187fcd5 100644 --- a/sway/server.c +++ b/sway/server.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,18 @@ bool server_privileged_prepare(struct sway_server *server) { return true; } +static void handle_drm_lease_request(struct wl_listener *listener, void *data) { + /* We only offer non-desktop outputs, but in the future we might want to do + * more logic here. */ + + struct wlr_drm_lease_request_v1 *req = data; + struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req); + if (!lease) { + sway_log(SWAY_ERROR, "Failed to grant lease request"); + wlr_drm_lease_request_v1_reject(req); + } +} + bool server_init(struct sway_server *server) { sway_log(SWAY_DEBUG, "Initializing Wayland server"); @@ -149,6 +162,17 @@ bool server_init(struct sway_server *server) { server->foreign_toplevel_manager = wlr_foreign_toplevel_manager_v1_create(server->wl_display); + server->drm_lease_manager= + wlr_drm_lease_v1_manager_create(server->wl_display, server->backend); + if (server->drm_lease_manager) { + server->drm_lease_request.notify = handle_drm_lease_request; + wl_signal_add(&server->drm_lease_manager->events.request, + &server->drm_lease_request); + } else { + sway_log(SWAY_DEBUG, "Failed to create wlr_drm_lease_device_v1"); + sway_log(SWAY_INFO, "VR will not be available"); + } + wlr_export_dmabuf_manager_v1_create(server->wl_display); wlr_screencopy_manager_v1_create(server->wl_display); wlr_data_control_manager_v1_create(server->wl_display);