diff options
author | 2019-06-27 13:55:34 -0400 | |
---|---|---|
committer | 2021-09-09 15:25:19 +0200 | |
commit | 30c28ff8f774546c6e930ed3acf717434df55371 (patch) | |
tree | 259db63a0caaf17c4c12a42ca0190ecf94ff5da9 | |
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.
-rw-r--r-- | include/sway/server.h | 4 | ||||
-rw-r--r-- | sway/desktop/output.c | 14 | ||||
-rw-r--r-- | sway/server.c | 24 |
3 files changed, 41 insertions, 1 deletions
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 @@ | |||
9 | #include <wlr/types/wlr_data_device.h> | 9 | #include <wlr/types/wlr_data_device.h> |
10 | #include <wlr/types/wlr_input_method_v2.h> | 10 | #include <wlr/types/wlr_input_method_v2.h> |
11 | #include <wlr/types/wlr_foreign_toplevel_management_v1.h> | 11 | #include <wlr/types/wlr_foreign_toplevel_management_v1.h> |
12 | #include <wlr/types/wlr_drm_lease_v1.h> | ||
12 | #include <wlr/types/wlr_layer_shell_v1.h> | 13 | #include <wlr/types/wlr_layer_shell_v1.h> |
13 | #include <wlr/types/wlr_output_management_v1.h> | 14 | #include <wlr/types/wlr_output_management_v1.h> |
14 | #include <wlr/types/wlr_output_power_management_v1.h> | 15 | #include <wlr/types/wlr_output_power_management_v1.h> |
@@ -72,6 +73,9 @@ struct sway_server { | |||
72 | struct wl_listener xdg_decoration; | 73 | struct wl_listener xdg_decoration; |
73 | struct wl_list xdg_decorations; // sway_xdg_decoration::link | 74 | struct wl_list xdg_decorations; // sway_xdg_decoration::link |
74 | 75 | ||
76 | struct wlr_drm_lease_v1_manager *drm_lease_manager; | ||
77 | struct wl_listener drm_lease_request; | ||
78 | |||
75 | struct wlr_presentation *presentation; | 79 | struct wlr_presentation *presentation; |
76 | 80 | ||
77 | struct wlr_pointer_constraints_v1 *pointer_constraints; | 81 | 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 @@ | |||
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); |