mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
Implement DRM leasing for non-desktop outputs
This prevents sway from extending the desktop to i.e. VR headsets, and makes them available for DRM leasing.
This commit is contained in:
parent
6e34aac2f1
commit
f5eaca47da
3 changed files with 34 additions and 1 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_input_method_v2.h>
|
||||
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
|
||||
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_output_management_v1.h>
|
||||
#include <wlr/types/wlr_output_power_management_v1.h>
|
||||
|
|
@ -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_device_v1 *drm_lease_device;
|
||||
struct wl_listener drm_lease_requested;
|
||||
|
||||
struct wlr_presentation *presentation;
|
||||
|
||||
struct wlr_pointer_constraints_v1 *pointer_constraints;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend/drm.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_output_damage.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
|
|
@ -877,7 +879,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_device && wlr_output_is_drm(wlr_output)) {
|
||||
wlr_drm_lease_device_v1_offer_output(
|
||||
server->drm_lease_device, wlr_output);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct sway_output *output = output_create(wlr_output);
|
||||
if (!output) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_data_control_v1.h>
|
||||
#include <wlr/types/wlr_drm_lease_v1.h>
|
||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
|
|
@ -58,6 +59,14 @@ bool server_privileged_prepare(struct sway_server *server) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static void handle_drm_lease_requested(
|
||||
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;
|
||||
wlr_drm_lease_device_v1_grant_lease_request(req->device, req);
|
||||
}
|
||||
|
||||
bool server_init(struct sway_server *server) {
|
||||
sway_log(SWAY_DEBUG, "Initializing Wayland server");
|
||||
|
||||
|
|
@ -150,6 +159,14 @@ bool server_init(struct sway_server *server) {
|
|||
server->foreign_toplevel_manager =
|
||||
wlr_foreign_toplevel_manager_v1_create(server->wl_display);
|
||||
|
||||
server->drm_lease_device =
|
||||
wlr_drm_lease_device_v1_create(server->wl_display, server->backend);
|
||||
if (server->drm_lease_device) {
|
||||
server->drm_lease_requested.notify = handle_drm_lease_requested;
|
||||
wl_signal_add(&server->drm_lease_device->events.lease_requested,
|
||||
&server->drm_lease_requested);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue