From 60f4cafad089b59c4791898670b723e3e133574d Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 2 Mar 2024 17:37:04 +0100 Subject: [PATCH] river: only expose xwayland_shell_v1 to Xwayland This is a private protocol only intended for the Xwayland client. --- river/Server.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/river/Server.zig b/river/Server.zig index 4af027d..b3c47f1 100644 --- a/river/Server.zig +++ b/river/Server.zig @@ -168,6 +168,8 @@ pub fn init(self: *Self, runtime_xwayland: bool) !void { _ = try wlr.SinglePixelBufferManagerV1.create(self.wl_server); _ = try wlr.Viewporter.create(self.wl_server); _ = try wlr.FractionalScaleManagerV1.create(self.wl_server, 1); + + self.wl_server.setGlobalFilter(*Self, globalFilter, self); } /// Free allocated memory and clean up. Note: order is important here @@ -222,6 +224,22 @@ pub fn start(self: Self) !void { } } +fn globalFilter(client: *const wl.Client, global: *const wl.Global, self: *Self) bool { + // Only expose the xwalyand_shell_v1 global to the Xwayland process. + if (build_options.xwayland) { + if (self.xwayland) |xwayland| { + if (global == xwayland.shell_v1.global) { + if (xwayland.server) |server| { + return client == server.client; + } + return false; + } + } + } + + return true; +} + /// Handle SIGINT and SIGTERM by gracefully stopping the server fn terminate(_: c_int, wl_server: *wl.Server) c_int { wl_server.terminate();