20
20
#include < wlr/types/wlr_presentation_time.h>
21
21
#include < wlr/types/wlr_primary_selection_v1.h>
22
22
#include < wlr/types/wlr_screencopy_v1.h>
23
+ #include < wlr/types/wlr_security_context_v1.h>
23
24
#include < wlr/types/wlr_single_pixel_buffer_v1.h>
24
25
#include < wlr/types/wlr_viewporter.h>
25
26
#include < wlr/types/wlr_xcursor_manager.h>
29
30
#include < wlr/types/wlr_xdg_output_v1.h>
30
31
#include < wlr/util/box.h>
31
32
#include < wlr/util/log.h>
33
+ #include < wlr/xwayland/shell.h>
32
34
#include " wlr-wrap-end.hpp"
33
35
34
36
void Server::focus_view (std::shared_ptr<View>&& view, wlr_surface* surface) {
@@ -361,6 +363,23 @@ void output_manager_apply_notify(wl_listener* listener, void* data) {
361
363
server.seat ->cursor .reload_image ();
362
364
}
363
365
366
+ bool filter_globals (const struct wl_client * client, const struct wl_global * global, void * data) {
367
+ const auto & server = *static_cast <Server*>(data);
368
+ const auto * wlr_xwayland = server.xwayland ->wlr ;
369
+
370
+ if (global == wlr_xwayland->shell_v1 ->global ) {
371
+ return wlr_xwayland->server != nullptr && client == wlr_xwayland->server ->client ;
372
+ }
373
+
374
+ const auto * security_context =
375
+ wlr_security_context_manager_v1_lookup_client (server.security_context_manager , (wl_client*) client);
376
+ if (server.is_restricted (global)) {
377
+ return security_context == nullptr ;
378
+ }
379
+
380
+ return true ;
381
+ }
382
+
364
383
void early_exit (wl_display* display, const std::string& err) {
365
384
wlr_log (WLR_ERROR, " %s" , err.c_str ());
366
385
wl_display_destroy_clients (display);
@@ -417,6 +436,9 @@ Server::Server() : listeners(*this) {
417
436
wlr_subcompositor_create (display);
418
437
wlr_data_device_manager_create (display);
419
438
439
+ security_context_manager = wlr_security_context_manager_v1_create (display);
440
+ wl_display_set_global_filter (display, filter_globals, nullptr );
441
+
420
442
// https://wayfire.org/2020/08/04/Wayfire-0-5.html
421
443
wlr_primary_selection_v1_device_manager_create (display);
422
444
@@ -479,16 +501,16 @@ Server::Server() : listeners(*this) {
479
501
listeners.activation_request_activation .notify = request_activation_notify;
480
502
wl_signal_add (&xdg_activation->events .request_activate , &listeners.activation_request_activation );
481
503
482
- wlr_data_control_manager_v1_create (display);
504
+ data_control_manager = wlr_data_control_manager_v1_create (display);
483
505
foreign_toplevel_manager = wlr_foreign_toplevel_manager_v1_create (display);
484
506
485
507
xwayland = std::make_shared<XWayland>(*this );
486
508
487
509
wlr_viewporter_create (display);
488
510
wlr_single_pixel_buffer_manager_v1_create (display);
489
- wlr_screencopy_manager_v1_create (display);
490
- wlr_export_dmabuf_manager_v1_create (display);
491
- wlr_gamma_control_manager_v1_create (display);
511
+ screencopy_manager = wlr_screencopy_manager_v1_create (display);
512
+ export_dmabuf_manager = wlr_export_dmabuf_manager_v1_create (display);
513
+ gamma_control_manager = wlr_gamma_control_manager_v1_create (display);
492
514
493
515
wlr_xdg_foreign_registry* foreign_registry = wlr_xdg_foreign_registry_create (display);
494
516
wlr_xdg_foreign_v1_create (display, foreign_registry);
@@ -505,3 +527,29 @@ Server::Server() : listeners(*this) {
505
527
506
528
content_type_manager = wlr_content_type_manager_v1_create (display, 1 );
507
529
}
530
+
531
+ bool Server::is_restricted (const wl_global* global) const {
532
+ if (drm_manager != nullptr ) {
533
+ wlr_drm_lease_device_v1* drm_lease_dev;
534
+ wl_list_for_each (drm_lease_dev, &drm_manager->devices , link) {
535
+ if (global == drm_lease_dev->global ) {
536
+ return true ;
537
+ }
538
+ }
539
+ }
540
+
541
+ // clang-format off
542
+ return
543
+ global == data_control_manager->global ||
544
+ global == foreign_toplevel_manager->global ||
545
+ global == export_dmabuf_manager->global ||
546
+ global == gamma_control_manager->global ||
547
+ global == layer_shell->global ||
548
+ global == output_manager->global ||
549
+ global == output_power_manager->global ||
550
+ global == seat->virtual_keyboard_mgr ->global ||
551
+ global == seat->virtual_pointer_mgr ->global ||
552
+ global == screencopy_manager->global ||
553
+ global == security_context_manager->global ;
554
+ // clang-format on
555
+ }
0 commit comments