diff options
Diffstat (limited to 'sway/server.c')
-rw-r--r-- | sway/server.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/sway/server.c b/sway/server.c index f51fcfe2..b187fcd5 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -9,9 +9,11 @@ | |||
9 | #include <wlr/backend/multi.h> | 9 | #include <wlr/backend/multi.h> |
10 | #include <wlr/backend/noop.h> | 10 | #include <wlr/backend/noop.h> |
11 | #include <wlr/backend/session.h> | 11 | #include <wlr/backend/session.h> |
12 | #include <wlr/config.h> | ||
12 | #include <wlr/render/wlr_renderer.h> | 13 | #include <wlr/render/wlr_renderer.h> |
13 | #include <wlr/types/wlr_compositor.h> | 14 | #include <wlr/types/wlr_compositor.h> |
14 | #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> | ||
15 | #include <wlr/types/wlr_export_dmabuf_v1.h> | 17 | #include <wlr/types/wlr_export_dmabuf_v1.h> |
16 | #include <wlr/types/wlr_gamma_control_v1.h> | 18 | #include <wlr/types/wlr_gamma_control_v1.h> |
17 | #include <wlr/types/wlr_idle.h> | 19 | #include <wlr/types/wlr_idle.h> |
@@ -24,7 +26,11 @@ | |||
24 | #include <wlr/types/wlr_tablet_v2.h> | 26 | #include <wlr/types/wlr_tablet_v2.h> |
25 | #include <wlr/types/wlr_viewporter.h> | 27 | #include <wlr/types/wlr_viewporter.h> |
26 | #include <wlr/types/wlr_xcursor_manager.h> | 28 | #include <wlr/types/wlr_xcursor_manager.h> |
29 | #include <wlr/types/wlr_xdg_activation_v1.h> | ||
27 | #include <wlr/types/wlr_xdg_decoration_v1.h> | 30 | #include <wlr/types/wlr_xdg_decoration_v1.h> |
31 | #include <wlr/types/wlr_xdg_foreign_registry.h> | ||
32 | #include <wlr/types/wlr_xdg_foreign_v1.h> | ||
33 | #include <wlr/types/wlr_xdg_foreign_v2.h> | ||
28 | #include <wlr/types/wlr_xdg_output_v1.h> | 34 | #include <wlr/types/wlr_xdg_output_v1.h> |
29 | #include "config.h" | 35 | #include "config.h" |
30 | #include "list.h" | 36 | #include "list.h" |
@@ -52,6 +58,18 @@ bool server_privileged_prepare(struct sway_server *server) { | |||
52 | return true; | 58 | return true; |
53 | } | 59 | } |
54 | 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 | |||
55 | bool server_init(struct sway_server *server) { | 73 | bool server_init(struct sway_server *server) { |
56 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); | 74 | sway_log(SWAY_DEBUG, "Initializing Wayland server"); |
57 | 75 | ||
@@ -144,12 +162,34 @@ bool server_init(struct sway_server *server) { | |||
144 | server->foreign_toplevel_manager = | 162 | server->foreign_toplevel_manager = |
145 | wlr_foreign_toplevel_manager_v1_create(server->wl_display); | 163 | wlr_foreign_toplevel_manager_v1_create(server->wl_display); |
146 | 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 | |||
147 | wlr_export_dmabuf_manager_v1_create(server->wl_display); | 176 | wlr_export_dmabuf_manager_v1_create(server->wl_display); |
148 | wlr_screencopy_manager_v1_create(server->wl_display); | 177 | wlr_screencopy_manager_v1_create(server->wl_display); |
149 | wlr_data_control_manager_v1_create(server->wl_display); | 178 | wlr_data_control_manager_v1_create(server->wl_display); |
150 | wlr_primary_selection_v1_device_manager_create(server->wl_display); | 179 | wlr_primary_selection_v1_device_manager_create(server->wl_display); |
151 | wlr_viewporter_create(server->wl_display); | 180 | wlr_viewporter_create(server->wl_display); |
152 | 181 | ||
182 | struct wlr_xdg_foreign_registry *foreign_registry = | ||
183 | wlr_xdg_foreign_registry_create(server->wl_display); | ||
184 | wlr_xdg_foreign_v1_create(server->wl_display, foreign_registry); | ||
185 | wlr_xdg_foreign_v2_create(server->wl_display, foreign_registry); | ||
186 | |||
187 | server->xdg_activation_v1 = wlr_xdg_activation_v1_create(server->wl_display); | ||
188 | server->xdg_activation_v1_request_activate.notify = | ||
189 | xdg_activation_v1_handle_request_activate; | ||
190 | wl_signal_add(&server->xdg_activation_v1->events.request_activate, | ||
191 | &server->xdg_activation_v1_request_activate); | ||
192 | |||
153 | // Avoid using "wayland-0" as display socket | 193 | // Avoid using "wayland-0" as display socket |
154 | char name_candidate[16]; | 194 | char name_candidate[16]; |
155 | for (int i = 1; i <= 32; ++i) { | 195 | for (int i = 1; i <= 32; ++i) { |
@@ -186,7 +226,6 @@ bool server_init(struct sway_server *server) { | |||
186 | } | 226 | } |
187 | 227 | ||
188 | server->dirty_nodes = create_list(); | 228 | server->dirty_nodes = create_list(); |
189 | server->transactions = create_list(); | ||
190 | 229 | ||
191 | server->input = input_manager_create(server); | 230 | server->input = input_manager_create(server); |
192 | input_manager_get_default_seat(); // create seat0 | 231 | input_manager_get_default_seat(); // create seat0 |
@@ -202,7 +241,6 @@ void server_fini(struct sway_server *server) { | |||
202 | wl_display_destroy_clients(server->wl_display); | 241 | wl_display_destroy_clients(server->wl_display); |
203 | wl_display_destroy(server->wl_display); | 242 | wl_display_destroy(server->wl_display); |
204 | list_free(server->dirty_nodes); | 243 | list_free(server->dirty_nodes); |
205 | list_free(server->transactions); | ||
206 | } | 244 | } |
207 | 245 | ||
208 | bool server_start(struct sway_server *server) { | 246 | bool server_start(struct sway_server *server) { |