aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-06-22 16:26:00 +0200
committerSimon Ser <contact@emersion.fr>2023-08-24 18:27:22 +0200
commit4a2210577c7c4f84a99ca03386b8910d2f419ab6 (patch)
tree830d52342ceabb1724d1ea9a671ccf7df37e6960
parentd84b3832f4616ee2a18f3ad4c0cd9cd996458d2c (diff)
Hide xwayland_shell_v1 from regular clients
Regular clients are not allowed to use this interface. wlroots already sends a protocol error if a non-Xwayland client tries to use this interface, but let's remove all temptation by hiding it completely.
-rw-r--r--sway/server.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sway/server.c b/sway/server.c
index 50f0a702..db873dca 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -49,6 +49,7 @@
#include "sway/tree/root.h"
#if HAVE_XWAYLAND
+#include <wlr/xwayland/shell.h>
#include "sway/xwayland.h"
#endif
@@ -73,11 +74,25 @@ static void handle_drm_lease_request(struct wl_listener *listener, void *data) {
}
#endif
+static bool filter_global(const struct wl_client *client,
+ const struct wl_global *global, void *data) {
+#if HAVE_XWAYLAND
+ struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
+ if (global == xwayland->shell_v1->global) {
+ return xwayland->server != NULL && client == xwayland->server->client;
+ }
+#endif
+
+ return true;
+}
+
bool server_init(struct sway_server *server) {
sway_log(SWAY_DEBUG, "Initializing Wayland server");
server->wl_display = wl_display_create();
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
+ wl_display_set_global_filter(server->wl_display, filter_global, NULL);
+
server->backend = wlr_backend_autocreate(server->wl_display, &server->session);
if (!server->backend) {
sway_log(SWAY_ERROR, "Unable to create backend");