diff options
author | Simon Zeni <simon@bl4ckb0ne.ca> | 2019-06-27 13:55:34 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-09-09 15:25:19 +0200 |
commit | 30c28ff8f774546c6e930ed3acf717434df55371 (patch) | |
tree | 259db63a0caaf17c4c12a42ca0190ecf94ff5da9 /sway | |
parent | view: fix child position calc (diff) | |
download | sway-30c28ff8f774546c6e930ed3acf717434df55371.tar.gz sway-30c28ff8f774546c6e930ed3acf717434df55371.tar.zst sway-30c28ff8f774546c6e930ed3acf717434df55371.zip |
introduce wlr_drm_lease_v1
This prevents sway from extending the desktop to i.e. VR headsets, and makes
them available for DRM leasing.
Non-desktop wlr_outputs will be offered through the wlr_drm_lease_v1_manager
interface for client to lease.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/output.c | 14 | ||||
-rw-r--r-- | sway/server.c | 24 |
2 files changed, 37 insertions, 1 deletions
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 @@ | |||
4 | #include <strings.h> | 4 | #include <strings.h> |
5 | #include <time.h> | 5 | #include <time.h> |
6 | #include <wayland-server-core.h> | 6 | #include <wayland-server-core.h> |
7 | #include <wlr/backend/drm.h> | ||
7 | #include <wlr/render/wlr_renderer.h> | 8 | #include <wlr/render/wlr_renderer.h> |
8 | #include <wlr/types/wlr_buffer.h> | 9 | #include <wlr/types/wlr_buffer.h> |
10 | #include <wlr/types/wlr_drm_lease_v1.h> | ||
9 | #include <wlr/types/wlr_matrix.h> | 11 | #include <wlr/types/wlr_matrix.h> |
10 | #include <wlr/types/wlr_output_damage.h> | 12 | #include <wlr/types/wlr_output_damage.h> |
11 | #include <wlr/types/wlr_output_layout.h> | 13 | #include <wlr/types/wlr_output_layout.h> |
@@ -836,7 +838,17 @@ static void handle_present(struct wl_listener *listener, void *data) { | |||
836 | void handle_new_output(struct wl_listener *listener, void *data) { | 838 | void handle_new_output(struct wl_listener *listener, void *data) { |
837 | struct sway_server *server = wl_container_of(listener, server, new_output); | 839 | struct sway_server *server = wl_container_of(listener, server, new_output); |
838 | struct wlr_output *wlr_output = data; | 840 | struct wlr_output *wlr_output = data; |
839 | sway_log(SWAY_DEBUG, "New output %p: %s", wlr_output, wlr_output->name); | 841 | sway_log(SWAY_DEBUG, "New output %p: %s (non-desktop: %d)", |
842 | wlr_output, wlr_output->name, wlr_output->non_desktop); | ||
843 | |||
844 | if (wlr_output->non_desktop) { | ||
845 | sway_log(SWAY_DEBUG, "Not configuring non-desktop output"); | ||
846 | if (server->drm_lease_manager) { | ||
847 | wlr_drm_lease_v1_manager_offer_output(server->drm_lease_manager, | ||
848 | wlr_output); | ||
849 | } | ||
850 | return; | ||
851 | } | ||
840 | 852 | ||
841 | struct sway_output *output = output_create(wlr_output); | 853 | struct sway_output *output = output_create(wlr_output); |
842 | if (!output) { | 854 | 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 @@ | |||
13 | #include <wlr/render/wlr_renderer.h> | 13 | #include <wlr/render/wlr_renderer.h> |
14 | #include <wlr/types/wlr_compositor.h> | 14 | #include <wlr/types/wlr_compositor.h> |
15 | #include <wlr/types/wlr_data_control_v1.h> | 15 | #include <wlr/types/wlr_data_control_v1.h> |
16 | #include <wlr/types/wlr_drm_lease_v1.h> | ||
16 | #include <wlr/types/wlr_export_dmabuf_v1.h> | 17 | #include <wlr/types/wlr_export_dmabuf_v1.h> |
17 | #include <wlr/types/wlr_gamma_control_v1.h> | 18 | #include <wlr/types/wlr_gamma_control_v1.h> |
18 | #include <wlr/types/wlr_idle.h> | 19 | #include <wlr/types/wlr_idle.h> |
@@ -57,6 +58,18 @@ bool server_privileged_prepare(struct sway_server *server) { | |||
57 | return true; | 58 | return true; |
58 | } | 59 | } |
59 | 60 | ||
61 | static void handle_drm_lease_request(struct wl_listener *listener, void *data) { | ||
62 | /* We only offer non-desktop outputs, but in the future we might want to do | ||
63 | * more logic here. */ | ||
64 | |||
65 | struct wlr_drm_lease_request_v1 *req = data; | ||
66 | struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req); | ||
67 | if (!lease) { | ||
68 | sway_log(SWAY_ERROR, "Failed to grant lease request"); | ||
69 | wlr_drm_lease_request_v1_reject(req); | ||
70 | } | ||
71 | } | ||
72 | |||
60 | bool server_init(struct sway_server *server) { | 73 | bool server_init(struct sway_server *server) { |
61 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); | 74 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); |
62 | 75 | ||
@@ -149,6 +162,17 @@ bool server_init(struct sway_server *server) { | |||
149 | server->foreign_toplevel_manager = | 162 | server->foreign_toplevel_manager = |
150 | wlr_foreign_toplevel_manager_v1_create(server->wl_display); | 163 | wlr_foreign_toplevel_manager_v1_create(server->wl_display); |
151 | 164 | ||
165 | server->drm_lease_manager= | ||
166 | wlr_drm_lease_v1_manager_create(server->wl_display, server->backend); | ||
167 | if (server->drm_lease_manager) { | ||
168 | server->drm_lease_request.notify = handle_drm_lease_request; | ||
169 | wl_signal_add(&server->drm_lease_manager->events.request, | ||
170 | &server->drm_lease_request); | ||
171 | } else { | ||
172 | sway_log(SWAY_DEBUG, "Failed to create wlr_drm_lease_device_v1"); | ||
173 | sway_log(SWAY_INFO, "VR will not be available"); | ||
174 | } | ||
175 | |||
152 | wlr_export_dmabuf_manager_v1_create(server->wl_display); | 176 | wlr_export_dmabuf_manager_v1_create(server->wl_display); |
153 | wlr_screencopy_manager_v1_create(server->wl_display); | 177 | wlr_screencopy_manager_v1_create(server->wl_display); |
154 | wlr_data_control_manager_v1_create(server->wl_display); | 178 | wlr_data_control_manager_v1_create(server->wl_display); |